Changed default rootfs size for at91 to 2112k
[openwrt.git] / target / linux / at91-2.6 / image / u-boot / ubclient / ubpar.c
1 /*
2 * ubparams.c
3 *
4 * Generate a u-boot parameter block with correct crc
5 *
6 * (C) 1007 Guthrie Consulting
7 * hamish@prodigi.ch
8 *
9 */
10
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <string.h>
14
15 #ifndef __ASSEMBLY__
16 #define __ASSEMBLY__
17 #endif
18 #define __ASM_STUB_PROCESSOR_H__
19 #include <config.h>
20 #undef __ASSEMBLY__
21 #include <environment.h>
22
23 #define XMK_STR(x) #x
24 #define MK_STR(x) XMK_STR(x)
25
26 extern unsigned long crc32 (unsigned long, const unsigned char *, unsigned int);
27
28 #if !defined(ENV_CRC)
29 #define ENV_CRC ~0
30 #endif
31
32 static char *environment[] = {
33 "bootdelay=3\0"
34 "baudrate=115200\0"
35 "stdin=serial\0"
36 "stdout=serial\0"
37 "stderr=serial\0"
38 "partitions=mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),2112k(rootfs),33k(nvram),-(rootfs_data)\0"
39 "fbargs=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),2112k(rootfs),33k(nvram),-(rootfs_data) root=/dev/mtdblock4 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
40 "rdba=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),2112k(rootfs),33k(nvram),-(rootfs_data) root=/dev/ram rw initrd=0x21200000,6000000 ramdisk_size=20000 init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
41 "rdram=run rdba; tftp 21000000 vImage; tftp 21200000 root.squashfs; bootm 21000000\0"
42 "flash=run fbargs; bootm 0xc0042000\0"
43 "bootargs=setenv bootargs mtdparts=AT45DB642.spi0:132k(bootloader),33k(ubparams),99k(spare),1056k(linux),2112k(rootfs),33k(nvram),-(rootfs_data) root=/dev/mtdblock4 ro init=/etc/preinit console=/dev/ttyS0,115200,mem=32M\0"
44 "bootcmd=bootm 0xc0042000\0"
45 "ipaddr=10.0.1.73\0"
46 "serverip=10.0.1.210\0"
47 "\0"
48 };
49
50 int main(int argc, char *argv[]) {
51 env_t *envptr;
52 char *src, *srcptr;
53 char *dataptr;
54 FILE *params;
55 int argfail = 1;
56 char newmac[30];
57 char newser[30];
58 int paramlen = 0;
59 int progmac = 0;
60 int progser = 0;
61
62 if (argc < 3) {
63 printf ("Invalid arguments\n");
64 return 1;
65 }
66
67 switch (argc) {
68 case 5:
69 if (strcmp(argv[3], "--serial") == 0) {
70 argfail = 0;
71 sprintf(newser, "serial#=%s", argv[4]);
72 progser = 1;
73 }
74 case 3:
75 if (strcmp(argv[1], "--mac") == 0) {
76 argfail = 0;
77 sprintf(newmac, "ethaddr=%s", argv[2]);
78 progmac = 1;
79 }
80 else
81 argfail = 1;
82 }
83
84 if (argfail) {
85 printf("Invalid arguments\n");
86 return 1;
87 }
88
89
90 src = srcptr = *environment;
91 envptr = (env_t *)malloc(CFG_ENV_SIZE);
92 dataptr = (char *)envptr + ENV_HEADER_SIZE;
93
94 while(*srcptr) {
95 //printf("%d, %s\n", strlen(srcptr), srcptr);
96 paramlen += strlen(srcptr) + 1;
97 srcptr += strlen(srcptr) + 1;
98 }
99
100 printf("Make u-boot params\n");
101 printf("Params size is %d\n", CFG_ENV_SIZE);
102
103 memset(envptr, 0, CFG_ENV_SIZE);
104 memcpy(dataptr, src, paramlen);
105 dataptr += paramlen;
106
107 if (progmac) {
108 memcpy(dataptr, newmac, strlen(newmac));
109 dataptr += strlen(newmac) + 1;
110 }
111
112 if (progser) {
113 memcpy(dataptr, newser, strlen(newser));
114 dataptr += strlen(newser) + 1;
115 }
116
117 envptr->crc = crc32(0, envptr->data, ENV_SIZE);
118
119 params = fopen("params", "w");
120 fwrite(envptr, CFG_ENV_SIZE, 1, params);
121 fclose(params);
122
123 free(envptr);
124 return 0;
125 }
This page took 0.0481510000000001 seconds and 5 git commands to generate.