summaryrefslogtreecommitdiffstats
path: root/target/device/Atmel/arch-arm/u-boot/2009.01-rc3/u-boot-2009.01-rc1-009-factory.patch
blob: 7d1c958dcda967cfaf0f5eec53b1182f51399504 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
diff -urN u-boot-2009.01-0rig//common/cmd_factory.c u-boot-2009.01/common/cmd_factory.c
--- u-boot-2009.01-0rig//common/cmd_factory.c	1970-01-01 01:00:00.000000000 +0100
+++ u-boot-2009.01/common/cmd_factory.c	2009-01-02 19:32:07.000000000 +0100
@@ -0,0 +1,308 @@
+/*
+ * (C) Copyright 2000
+ * Ulf Samuelsson	<ulf.samuelsson@atmelcom>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * Boot support
+ */
+#include <config.h>
+#include <common.h>
+#include <command.h>
+#include <dataflash.h>
+
+/* 
+ * 
+ * The typical use of this file, is to update config.h
+ * from an external build system
+ * 
+ */
+
+
+/*
+ * Macros to transform values
+ * into environment strings.
+ */
+#define XMK_STR(x)		#x
+#define MK_STR(x)		XMK_STR(x)
+
+void		setargs(void);
+
+int do_factory_defaults (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+#if	defined(CONFIG_ETHADDR)
+	setenv("ethaddr",	MK_STR(CONFIG_ETHADDR));
+#endif
+#if	defined(CONFIG_ETH1ADDR)
+	setenv("eth1addr",	MK_STR(CONFIG_ETH1ADDR));
+#endif
+#if	defined(CONFIG_HOSTNAME)
+	setenv("hostname",	MK_STR(CONFIG_HOSTNAME));
+#endif
+#if	defined(CONFIG_IPADDR)
+	setenv("ipaddr",	MK_STR(CONFIG_IPADDR));
+#endif
+#if	defined(CONFIG_SERVERIP)
+	setenv("serverip",	MK_STR(CONFIG_SERVERIP));
+#endif
+#if	defined(CONFIG_GATEWAY)
+	setenv("gatewayip",	MK_STR(CONFIG_GATEWAY));
+#endif
+#if	defined(CONFIG_NETMASK)
+	setenv("netmask",	MK_STR(CONFIG_NETMASK));
+#endif
+#if	defined(KERNEL_START)
+	setenv("kernel",	MK_STR(KERNEL_START));
+#endif
+#if	defined(KERNEL_LOCATION)
+	setenv("OS",		MK_STR(KERNEL_LOCATION));
+#endif
+#if	defined(FILESYSTEM_START)
+	setenv("ramdisk",	MK_STR(FILESYSTEM_START));
+	setenv("initrd",	MK_STR(FILESYSTEM_START)","MK_STR(FILESYSTEM_SIZE));
+#endif
+#if	defined(FILESYSTEM_LOCATION)
+	setenv("FS",		MK_STR(FS_LOCATION));
+#endif
+#if	defined(END_OF_FLASH)
+	setenv("endflash",	MK_STR(END_OF_FLASH));
+#endif
+#if	defined(CONFIG_LOAD_SCRIPTS)
+	/* By updating the "fs-date" environment variable and running "fs"
+	   You set "rd-1" and "rd-2"
+	*/ 
+	setenv("rd-1",		"rootfs.arm-"MK_STR(DATE)".ext2");
+	setenv("rd-2",		"rootfs.arm-"MK_STR(DATE)".jffs2");
+	setenv("rd-3",		"rootfs.arm-linux.ext2");
+	setenv("rd-4",		"rootfs.arm-linux.jffs2");
+	setenv("ver",		"1");
+
+	setenv("config",	"tftp  ${ramdisk} autoscript.${hostname} ; autoscr ${ramdisk} ");
+
+#if	defined(KERNEL_VERSION)
+	setenv("kernel-version",MK_STR(KERNEL_VERSION));
+#endif
+#if	defined(DATE)
+	setenv("kernel-date",	MK_STR(DATE));
+	setenv("fs-date",	MK_STR(DATE));
+	setenv("rd",		"rootfs.arm-"MK_STR(DATE)".ext2");
+#endif
+#if	defined(KERNEL_VERSION)
+	setenv("linux",		MK_STR(BOARD_NAME)"-linux-"MK_STR(KERNEL_VERSION)"-"MK_STR(DATE)".gz");
+#endif
+	setenv("get-ramdisk",	"tftp	${ramdisk}	${rd};		setenv rd-size	${filesize}");
+	setenv("store-ramdisk",	"cp.b	${ramdisk}	${FS}		${rd-size}");
+	setenv("load-ramdisk",	"cp.b	${FS}		${ramdisk}	${rd-size}");
+	setenv("flash-ramdisk",	"run	get-ramdisk;	run		store-ramdisk");
+
+	setenv("get-kernel",	"tftp	${kernel}	${linux};	setenv	kernel-size	${filesize}");
+	setenv("store-kernel",	"cp.b	${kernel}	${OS}		${kernel-size};		saveenv");
+	setenv("load-kernel",	"cp.b	${OS}		${kernel}	${kernel-size};		saveenv");
+	setenv("flash-kernel",	"run	get-kernel;	run		store-kernel");
+
+	setenv("get",		"run get-kernel		; run get-ramdisk");
+	setenv("flash",		"run flash-kernel	; run flash-ramdisk ; saveenv");
+	setenv("load",		"run load-kernel	; run load-ramdisk");
+
+	setenv("bootcmd",	"run load ; bootm "MK_STR(KERNEL_START));
+
+	setenv("fstype",	"ram");
+	setenv("flashfs",	"/dev/mtdblock2");
+	setenv("ramfs",		"/dev/ram");
+
+	setenv("rootfstype",	"jffs2");
+	setenv("access",	"rw");
+	setenv("ramdisk_size",	"15360");
+	setenv("console",	"ttyS0,115200");
+
+
+#if	defined(MEMORY_SIZE)
+	setenv("mem",		MK_STR(MEMORY_SIZE));
+#else
+	setenv("mem",		"32M");	/* Cautious default */
+#endif
+
+	setenv("update",	"os; fs; setargs");
+	setenv("cmpk",		"run flash-kernel; cp.b ${OS} ${ramdisk} ${kernel-size}; cmp ${kernel} ${ramdisk} ${kernel-size}"); 
+#endif	/* CONFIG_LOAD_SCRIPTS */
+#if	defined(CONFIG_AT91RM9200)
+	setenv("machid24",	"0x0fb");
+	setenv("machid26",	"0x2c1");
+	setenv("machid",	"0x2c1");
+	setenv("k24",		"setenv machid ${machid24}; os");
+	setenv("k26",		"setenv machid ${machid26}; os");
+#endif
+	AT91F_DataflashSetEnv ();
+#if	defined(CONFIG_LOAD_SCRIPTS)
+	setargs();
+#endif
+	return (saveenv() ? 1 : 0);
+}
+
+
+
+U_BOOT_CMD(
+	factory,	1,	1,	do_factory_defaults,
+	"factory\t- Create a default environment\n",
+	"\n"
+);
+
+#if	defined(CONFIG_LOAD_SCRIPTS)
+void		setargs(void)
+{
+	char cmd[512];
+	char fstype[512];
+
+	sprintf(fstype,getenv("fstype"));
+	if((fstype[0] != 'f') && (fstype[0] != 'r')) {
+		fstype[0] = 'r';
+	}
+
+	if(fstype[0] == 'f') {
+		sprintf(cmd,"root=%s rootfstype=%s ip=%s:%s:%s:%s console=%s,mem=%s",
+			getenv("flashfs"),
+			getenv("rootfstype"),
+			getenv("ipaddr"),
+			getenv("serverip"),
+			getenv("gatewayip"),
+			getenv("netmask"),
+			getenv("console"),
+			getenv("mem")
+		);
+		cmd[511] = '\0';
+		printf("len=%d: %s\n",strlen(cmd),cmd);
+		if(strlen(cmd) > 500) {
+			printf("Error: Environment too large during 'setargs'\n");
+		} else {
+			setenv("bootargs",cmd);
+			setenv("bootcmd",	"run load-kernel ; bootm 21000000");
+		}
+	} else if(fstype[0] == 'r') {
+		sprintf(cmd,"root=%s %s initrd=%s ramdisk_size=%s ip=%s:%s:%s:%s console=%s,mem=%s",
+			getenv("ramfs"),
+			getenv("access"),
+			getenv("initrd"),
+			getenv("ramdisk_size"),
+			getenv("ipaddr"),
+			getenv("serverip"),
+			getenv("gatewayip"),
+			getenv("netmask"),
+			getenv("console"),
+			getenv("mem")
+		);
+		printf("len=%d: %s\n",strlen(cmd),cmd);
+		cmd[511] = '\0';
+		if(strlen(cmd) > 500) {
+			printf("Error: Environment too large during 'setargs'\n");
+		} else {
+			setenv("bootargs",cmd);
+			setenv("bootcmd",	"run load ; bootm 21000000");
+		}
+	} else {
+		setenv("bootargs","no args");
+	}
+}
+
+int do_setargs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	setargs();
+	return 0;
+}
+
+U_BOOT_CMD(
+	setargs,	1,	1,	do_setargs,
+	"setargs\t- Create a bootargs from:"
+	"fstype=flash:	(${flash} ${access} ${initrd} ${ramdisk_size}) "
+	"fstype=ram:	(${ram}   ${access} ${initrd} ${ramdisk_size}) "
+	"${ipaddr} ${serverip} ${gatewayip} ${netmask} "
+	"${console} ${mem}\n"
+	,	"\n"
+);
+
+int do_os (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	char *kchip;
+	char *kdate;
+	char *kver;
+	char cmd[512];
+	kchip = getenv("hostname");
+	kdate = getenv("kernel-date");
+	kver = getenv("kernel-version");
+	if((strlen(kdate) + strlen(kver) + 32) >  500) {
+		printf("Error: Environment too large during 'os': ");
+		printf("len=%d\n", strlen(kdate) + strlen(kver) + 32);
+	} else if(kver != NULL) {
+		if(kdate != NULL) {
+			sprintf(cmd,"%s-linux-%s-%s.gz",kchip,kver,kdate);
+		} else {
+			sprintf(cmd,"%s-linux-%s.gz",kchip,kver);
+		}
+		printf("Setting kernel to %s\n",cmd);
+		setenv("linux",cmd);
+		return 0;
+	}
+	return 1;
+}
+
+U_BOOT_CMD(
+	os,	1,	1,	do_os,
+	"os\t- Select linux version  ${hostname}-linux-${kernel-name}-${kernel-date}\n"
+	,	"\n"
+);
+
+
+int do_fs (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	char *ver;
+	char *fsdate;
+	char *hostname;
+	char cmd[512];
+	fsdate		= getenv("fs-date");
+	hostname	= getenv("hostname");
+
+	if(fsdate != NULL) {
+		sprintf(cmd,"rootfs.arm-%s.ext2",fsdate);
+		setenv("rd-1",cmd);
+		sprintf(cmd,"rootfs.arm-%s.jffs2",fsdate);
+		setenv("rd-2",cmd);
+	}
+	ver = getenv("ver");		/* Find out which version we are using*/
+	if(cmd==NULL) {
+		setenv("ver","1");
+	}
+	ver = getenv("ver");		/* Find out which version we are using*/
+	sprintf(cmd,"rd-%s",ver);	/* create rd${ver}*/
+	ver=getenv(cmd);
+	sprintf(cmd,"%s",ver);
+	printf("Setting ramdisk to %s\n",cmd);
+	setenv("rd",cmd);
+	return 0;
+}
+
+
+U_BOOT_CMD(
+	fs,	1,	1,	do_fs,
+	"fs\t- Select ramdisk version == rd-${ver}\n"
+	,	"\n"
+);
+#endif /* #if	defined(CONFIG_LOAD_SCRIPTS) */
+
+
diff -urN u-boot-2009.01-0rig//common/Makefile u-boot-2009.01/common/Makefile
--- u-boot-2009.01-0rig//common/Makefile	2008-12-16 23:48:27.000000000 +0100
+++ u-boot-2009.01/common/Makefile	2009-01-02 19:17:16.000000000 +0100
@@ -84,6 +84,7 @@
 COBJS-$(CONFIG_CMD_EEPROM) += cmd_eeprom.o
 COBJS-$(CONFIG_CMD_ELF) += cmd_elf.o
 COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o
+COBJS-$(CONFIG_CMD_FACTORY) += cmd_factory.o
 COBJS-$(CONFIG_CMD_FAT) += cmd_fat.o
 COBJS-$(CONFIG_CMD_FDC)$(CONFIG_CMD_FDOS) += cmd_fdc.o
 COBJS-$(CONFIG_OF_LIBFDT) += cmd_fdt.o fdt_support.o