summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2012-11-20 11:14:57 +0100
committerTobias Klauser <tklauser@distanz.ch>2012-11-20 11:14:57 +0100
commite1a400a031b99f54f45d017cf2658d332974c73b (patch)
tree943e3000512d7bc77ca4bc177c083942bb6fc205
parent44ca44a58e5b326b31b0d6eee2d84eaa63c1b0d2 (diff)
mkubootenv: Implement -n commandline option to disable CRC32 generation
-rw-r--r--mkubootenv/mkubootenv.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/mkubootenv/mkubootenv.c b/mkubootenv/mkubootenv.c
index 8e49cbb..26b5334 100644
--- a/mkubootenv/mkubootenv.c
+++ b/mkubootenv/mkubootenv.c
@@ -11,8 +11,8 @@
*
* The environment is preceeded by a 32 bit CRC over the data part.
*
- * Copyright (c) 2009, Zurich University of Applied Sciences
- * Copyright (c) 2009, Tobias Klauser <klto@zhaw.ch>
+ * Copyright (c) 2009-2012, Zurich University of Applied Sciences
+ * Copyright (c) 2009-2012, Tobias Klauser <tklauser@distanz.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -154,10 +154,9 @@ static void uboot_env_cleanup_file(struct file *f)
close(f->fd);
}
-static void uboot_env_to_img(struct file *s, struct file *t)
+static void uboot_env_to_img(struct file *s, struct file *t, bool do_crc)
{
uint8_t *p, *q, *end;
- uint32_t *crc;
dbg("source file (env): %s\n", s->name);
dbg("target image file (bin): %s\n", t->name);
@@ -179,8 +178,10 @@ static void uboot_env_to_img(struct file *s, struct file *t)
*p = 0;
/* now for the real CRC32 */
- crc = (uint32_t *) t->ptr;
- *crc = crc32(0, t->ptr + CRC32_SIZE, t->size - CRC32_SIZE);
+ if (do_crc) {
+ uint32_t *crc = (uint32_t *) t->ptr;
+ *crc = crc32(0, t->ptr + CRC32_SIZE, t->size - CRC32_SIZE);
+ }
}
static void uboot_img_to_env(struct file *s, struct file *t)
@@ -206,10 +207,12 @@ static void uboot_img_to_env(struct file *s, struct file *t)
static void usage_and_exit(int status)
{
printf("usage: mkubootenv [-s <size>] <source file> <target file>\n"
- " -s <size> set size of the target image file to <size> bytes. If <size> is\n"
+ " -s <size> Set size of the target image file to <size> bytes. If <size> is\n"
" bigger than the source file, the target image gets padded with null\n"
" bytes. If <size> is smaller than the source file, an error is emitted.\n"
- " -r reverse operation: get plaintext env file (target) from binary image\n"
+ " -n Disable CRC32 calculation. The CRC32 of the generated image will be\n"
+ " filled with zeros. This option is ignored in reverse mode.\n"
+ " -r Reverse operation: get plaintext env file (target) from binary image\n"
" file (source)\n");
exit(status);
}
@@ -220,6 +223,7 @@ int main(int argc, char **argv)
int status = EXIT_FAILURE;
ssize_t img_size = -1;
bool reverse = false;
+ bool do_crc = true;
struct file s, t; /* source and target file */
if (argc < 2)
@@ -247,6 +251,9 @@ int main(int argc, char **argv)
case 'r':
reverse = true;
break;
+ case 'n':
+ do_crc = false;
+ break;
case 'h':
status = EXIT_SUCCESS;
/* fall through */
@@ -295,7 +302,7 @@ int main(int argc, char **argv)
if (uboot_env_prepare_target(&t))
goto cleanup_source;
- uboot_env_to_img(&s, &t);
+ uboot_env_to_img(&s, &t, do_crc);
} else {
uint8_t *p;
uint8_t *end;