aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware-utils/src
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2010-03-27 17:38:26 +0000
committerGabor Juhos <juhosg@openwrt.org>2010-03-27 17:38:26 +0000
commit567def1d7f82ef990e678998fe33a0c02f61edc5 (patch)
tree990a69360371a55def1773b24df779616f1414c2 /tools/firmware-utils/src
parent596c2ea83de186b516aa7afd46c2c9ef29521cd3 (diff)
downloadmaster-187ad058-567def1d7f82ef990e678998fe33a0c02f61edc5.tar.gz
master-187ad058-567def1d7f82ef990e678998fe33a0c02f61edc5.tar.bz2
master-187ad058-567def1d7f82ef990e678998fe33a0c02f61edc5.zip
firmware-utils/trx: add relative offset parameter
* will be used for the WRT160NL board * patch by Bernhard Loos * note: rejected parts has been fixed git-svn-id: svn://svn.openwrt.org/openwrt/trunk@20522 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'tools/firmware-utils/src')
-rw-r--r--tools/firmware-utils/src/trx.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/firmware-utils/src/trx.c b/tools/firmware-utils/src/trx.c
index 728deac37f..44bd06a068 100644
--- a/tools/firmware-utils/src/trx.c
+++ b/tools/firmware-utils/src/trx.c
@@ -83,7 +83,7 @@ void usage(void) __attribute__ (( __noreturn__ ));
void usage(void)
{
fprintf(stderr, "Usage:\n");
- fprintf(stderr, " trx [-2] [-o outfile] [-m maxlen] [-a align] [-b offset] \\\n");
+ fprintf(stderr, " trx [-2] [-o outfile] [-m maxlen] [-a align] [-b absolute offset] [-x relative offset]\n");
fprintf(stderr, " [-f file] [-f file [-f file [-f file (v2 only)]]]\n");
exit(EXIT_FAILURE);
}
@@ -97,6 +97,7 @@ int main(int argc, char **argv)
char *e;
int c, i, append = 0;
size_t n;
+ ssize_t n2;
uint32_t cur_len;
unsigned long maxlen = TRX_MAX_LEN;
struct trx_header *p;
@@ -118,7 +119,7 @@ int main(int argc, char **argv)
in = NULL;
i = 0;
- while ((c = getopt(argc, argv, "-:2o:m:a:b:f:A:")) != -1) {
+ while ((c = getopt(argc, argv, "-:2o:m:a:x:b:f:A:")) != -1) {
switch (c) {
case '2':
/* take care that nothing was written to buf so far */
@@ -219,6 +220,25 @@ int main(int argc, char **argv)
cur_len = n;
}
break;
+ case 'x':
+ errno = 0;
+ n2 = strtol(optarg, &e, 0);
+ if (errno || (e == optarg) || *e) {
+ fprintf(stderr, "illegal numeric string\n");
+ usage();
+ }
+ if (n2 < 0) {
+ if (-n2 > cur_len) {
+ fprintf(stderr, "WARNING: current length smaller then -x %d offset\n",n2);
+ cur_len = 0;
+ } else
+ cur_len += n2;
+ } else {
+ memset(buf + cur_len, 0, n2);
+ cur_len += n2;
+ }
+
+ break;
default:
usage();
}