aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2020-12-30 18:24:51 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2021-03-15 16:57:34 +0100
commit4d9f69322cdaaec10a8f37c67c772f5c3b21e841 (patch)
tree887878e283c642f28f6b78de002dfd6ddf451898
parentcb740fbe25e2410ae6f1c30c1e46941bf8ca0902 (diff)
downloadupstream-4d9f69322cdaaec10a8f37c67c772f5c3b21e841.tar.gz
upstream-4d9f69322cdaaec10a8f37c67c772f5c3b21e841.tar.bz2
upstream-4d9f69322cdaaec10a8f37c67c772f5c3b21e841.zip
tools: otrx: allow own magic
This allows to specify an own magic instead of using the default magic value TRX_MAGIC. If no own magic is specified the default one will be used. Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--tools/firmware-utils/src/otrx.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/firmware-utils/src/otrx.c b/tools/firmware-utils/src/otrx.c
index 223e032f2b..3bbbac39e3 100644
--- a/tools/firmware-utils/src/otrx.c
+++ b/tools/firmware-utils/src/otrx.c
@@ -287,7 +287,6 @@ static int otrx_create_write_hdr(FILE *trx, struct trx_header *hdr) {
uint8_t buf[1024];
uint32_t crc32;
- hdr->magic = cpu_to_le32(TRX_MAGIC);
hdr->version = 1;
fseek(trx, 0, SEEK_SET);
@@ -324,9 +323,13 @@ static int otrx_create(int argc, char **argv) {
ssize_t sbytes;
size_t curr_idx = 0;
size_t curr_offset = sizeof(hdr);
+ char *e;
+ uint32_t magic;
int c;
int err = 0;
+ hdr.magic = cpu_to_le32(TRX_MAGIC);
+
if (argc < 3) {
fprintf(stderr, "No TRX file passed\n");
err = -EINVAL;
@@ -343,7 +346,7 @@ static int otrx_create(int argc, char **argv) {
fseek(trx, curr_offset, SEEK_SET);
optind = 3;
- while ((c = getopt(argc, argv, "f:A:a:b:")) != -1) {
+ while ((c = getopt(argc, argv, "f:A:a:b:M:")) != -1) {
switch (c) {
case 'f':
if (curr_idx >= TRX_MAX_PARTS) {
@@ -400,6 +403,14 @@ static int otrx_create(int argc, char **argv) {
curr_offset += sbytes;
}
break;
+ case 'M':
+ errno = 0;
+ magic = strtoul(optarg, &e, 0);
+ if (errno || (e == optarg) || *e)
+ fprintf(stderr, "illegal magic string %s\n", optarg);
+ else
+ hdr.magic = cpu_to_le32(magic);
+ break;
}
if (err)
break;