]> git.wh0rd.org - patches.git/blob - u-boot-envcrc-export.patch
initial import
[patches.git] / u-boot-envcrc-export.patch
1 Index: common/environment.c
2 ===================================================================
3 --- common/environment.c (revision 950)
4 +++ common/environment.c (working copy)
5 @@ -44,7 +44,7 @@
6 * Generate embedded environment table
7 * inside U-Boot image, if needed.
8 */
9 -#if defined(ENV_IS_EMBEDDED)
10 +#if defined(ENV_IS_EMBEDDED) || (defined(ENV_IS_EMBEDDED_CUSTOM) && defined(USE_HOSTCC))
11 /*
12 * Only put the environment in it's own section when we are building
13 * U-Boot proper. The host based program "tools/envcrc" does not need
14 Index: tools/envcrc.c
15 ===================================================================
16 --- tools/envcrc.c (revision 950)
17 +++ tools/envcrc.c (working copy)
18 @@ -23,6 +23,7 @@
19
20 #include <stdio.h>
21 #include <stdlib.h>
22 +#include <string.h>
23 #include <unistd.h>
24
25 #ifndef __ASSEMBLY__
26 @@ -68,14 +69,14 @@
27
28 extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
29
30 -#ifdef ENV_IS_EMBEDDED
31 +#if defined(ENV_IS_EMBEDDED) || defined(ENV_IS_EMBEDDED_CUSTOM)
32 extern unsigned int env_size;
33 extern unsigned char environment;
34 #endif /* ENV_IS_EMBEDDED */
35
36 int main (int argc, char **argv)
37 {
38 -#ifdef ENV_IS_EMBEDDED
39 +#if defined(ENV_IS_EMBEDDED) || defined(ENV_IS_EMBEDDED_CUSTOM)
40 int crc;
41 unsigned char *envptr = &environment,
42 *dataptr = envptr + ENV_HEADER_SIZE;
43 @@ -85,10 +86,27 @@ int main (int argc, char **argv)
44
45 /* Check if verbose mode is activated passing a parameter to the program */
46 if (argc > 1) {
47 - printf ("CRC32 from offset %08X to %08X of environment = %08X\n",
48 - (unsigned int) (dataptr - envptr),
49 - (unsigned int) (dataptr - envptr) + datasize,
50 - crc);
51 + if (!strcmp(argv[1], "--binary")) {
52 + int le = (argc > 2 ? !strcmp(argv[2], "le") : 1);
53 + size_t i, start, end, step;
54 + if (le) {
55 + start = 0;
56 + end = ENV_HEADER_SIZE;
57 + step = 1;
58 + } else {
59 + start = ENV_HEADER_SIZE - 1;
60 + end = -1;
61 + step = -1;
62 + }
63 + for (i = start; i != end; i += step)
64 + printf ("%c", (crc & (0xFF << (i * 8))) >> (i * 8));
65 + fwrite (dataptr, 1, datasize, stdout);
66 + } else {
67 + printf ("CRC32 from offset %08X to %08X of environment = %08X\n",
68 + (unsigned int) (dataptr - envptr),
69 + (unsigned int) (dataptr - envptr) + datasize,
70 + crc);
71 + }
72 } else {
73 printf ("0x%08X\n", crc);
74 }