4 * Generate a u-boot parameter block with correct crc
6 * (C) 1007 Guthrie Consulting
18 #define __ASM_STUB_PROCESSOR_H__
21 #include <environment.h>
24 #define MK_STR(x) XMK_STR(x)
26 extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
35 #warning LAN_IP NOT DEFINED
40 #warning LAN_SERVERIP NOT DEFINED
43 static char *environment
[] = {
49 "fbargs=setenv bootargs root=/dev/mtdblock3 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
50 "rdba=setenv bootargs root=/dev/ram rw initrd=0x21200000,6000000 ramdisk_size=20000 init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
51 "rdram=run rdba; tftp 21000000 uImage; tftp 21200000 root.squashfs; bootm 21000000\0"
52 "flash=run fbargs; bootm 0xc0042000\0"
53 "bootargs=setenv bootargs root=/dev/mtdblock3 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
54 "bootcmd=bootm 0xc0042000\0"
55 "ipaddr=" MK_STR(LAN_IP
) "\0"
56 "serverip=" MK_STR(LAN_SERVERIP
) "\0"
60 int main(int argc
, char *argv
[]) {
73 printf ("Invalid arguments\n");
79 if (strcmp(argv
[3], "--serial") == 0) {
81 sprintf(newser
, "serial#=%s", argv
[4]);
85 if (strcmp(argv
[1], "--mac") == 0) {
87 sprintf(newmac
, "ethaddr=%s", argv
[2]);
95 printf("Invalid arguments\n");
100 src
= srcptr
= *environment
;
101 envptr
= (env_t
*)malloc(CFG_ENV_SIZE
);
102 dataptr
= (char *)envptr
+ ENV_HEADER_SIZE
;
105 //printf("%d, %s\n", strlen(srcptr), srcptr);
106 paramlen
+= strlen(srcptr
) + 1;
107 srcptr
+= strlen(srcptr
) + 1;
110 printf("Make u-boot params\n");
111 printf("Params size is %d\n", CFG_ENV_SIZE
);
113 memset(envptr
, 0, CFG_ENV_SIZE
);
114 memcpy(dataptr
, src
, paramlen
);
118 memcpy(dataptr
, newmac
, strlen(newmac
));
119 dataptr
+= strlen(newmac
) + 1;
123 memcpy(dataptr
, newser
, strlen(newser
));
124 dataptr
+= strlen(newser
) + 1;
127 envptr
->crc
= crc32(0, envptr
->data
, ENV_SIZE
);
129 params
= fopen("/dev/mtd1", "w");
130 fwrite(envptr
, CFG_ENV_SIZE
, 1, params
);
This page took 0.054559 seconds and 5 git commands to generate.