blob: 7a18eea1fcf1477773146e88cdc2bf022103f7c4 (
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
#
# boot.scr
#
# Boot script for Beagle Hybrid / Panda Hybrid / GTA04 / Neo900
#
# Author: H. Nikolaus Schaller
# Copyright Golden Delicious Computers 2010-2014
# licensed under GPL 2.0
#
#
# NAND Flash addresses (@ 256 MByte/2 GBit)
#
# 0x0000 0000 0x0007 ffff 08 0000 512 KB X-Loader (flash image) - note the loader must fit into 64k SRAM!
# 0x0008 0000 0x001c ffff 15 0000 1.3 MB U-Boot (flash image)
# 0x001d 0000 0x0020 ffff 04 0000 256 KB splash.rgb16z
# 0x0021 0000 0x0024 ffff 04 0000 256 KB menu.rgb16z
# 0x0025 0000 0x0025 ffff 01 0000 64 KB boot.scr
# 0x0026 0000 0x0027 ffff 02 0000 128 KB U-Boot parameters written by saveenv
# 0x0028 0000 0x0067 ffff 40 0000 4 MB Kernel (flash image loaded by nandboot)
# 0x0068 0000 0x0fff ffff 250 MB (or more) file system (e.g. jffs)
#
# To flash into NAND from command line:
#
# 1. break into U-Boot command line
# 2. flash=yes
# 3. boot
#
# booting tries to load:
# boot script /boot.scr (FAT) from partition 1, then /boot/boot.scr (EXT) from partition 1, then NAND
# splash images /image.rgb16 (FAT) from partition 1, then /boot/image.rgb16 (EXT) partition 1, then NAND
# kernel on up to 4 partitions /boot/uImage (EXT) or /uImage (FAT) or if none found then NAND
# bootargs.scr on the same paritions /boot/bootargs.scr (EXT) or /bootargs.scr (FAT) -- default is initialized to NAND or SD (if kernel is found)
#
VERSION=0123456789 # incremented by build script so that we re-initialize the boot environment or reflash x-loader and u-boot
echo "*** if you boot from NAND don-t worry about error messages when U-Boot tries to read a non-existing MMC ***"
i2c dev 0
status init
status set 8 # give fast feedback that U-Boot did start (red power led)
# we have to add an "x" because the test command treats empty string as equal to anything
if test "x${scriptversion}" != "x${VERSION}"
then
# set up default environment
# this setting boots from MMC if available and falls back to NAND
# (except for MLO/X-Loader which is located depending on the AUX button)
echo *** initializing GTA04 environment ***
setenv bootdelay 1
setenv imgtempaddr 0x80800000 # address where we load compressed splash image
setenv bootaddr 0x81800000 # address where we load the boot script
setenv loadaddrfdt 0x81c00000 # address where we load the flattened device tree
setenv loadaddr 0x82000000 # address where we load the kernel
# setenv console ttyS2,115200n8
# for newer kernels with OMAP console (unfortunately U-Boot can't find out)
setenv console ttyO2,115200n8
setenv defaultdisplay lcd
setenv bootorder "1 2 3 4"
setenv nand 4 # mtd4 is nand
setenv vram 12M
setenv omapfbvram 0:8M,1:4M
# load boot script from mmc (first FAT partition only) or nand wherever we find it
# i2c dev 0
# mmc rescan 0
# if load mmc 0 ${bootaddr} boot.scr
# then
# echo did load bootscript from mmc
# elif nand read ${bootaddr} 250000 10000
# then
# echo did load bootscript from nand
# fi
setenv loadbootscript 'i2c dev 0; mmc rescan 0; if load mmc 0 ${bootaddr} boot.scr; then echo did load bootscript from mmc; elif nand read ${bootaddr} 250000 10000; then echo did load bootscript from nand; fi'
# load zipped/uncompressed image from mmc (first FAT partition only) or nand wherever we find it
# i2c dev 0
# mmc rescan 0
# if load mmc 0 ${imgaddr} ${imgfile}.rgb16
# then
# ;
# elif load mmc 0 ${imgtempaddr} ${imgfile}.rgb16z
# then
# unzip ${imgtempaddr} ${imgaddr}
# elif nand read ${imgtempaddr} ${imgnandaddr} 40000
# then
# unzip ${imgtempaddr} ${imgaddr}
# fi
setenv loadimg 'i2c dev 0; mmc rescan 0; if load mmc 0 ${imgaddr} ${imgfile}.rgb16; then; elif load mmc 0 ${imgtempaddr} ${imgfile}.rgb16z; then unzip ${imgtempaddr} ${imgaddr}; elif nand read ${imgtempaddr} ${imgnandaddr} 40000; then unzip ${imgtempaddr} ${imgaddr}; fi'
setenv showimg 'run loadimg; lcm fb ${imgaddr};'
# predefine default boot arguments (unless overwritten by bootargs.scr)
setenv mmcargs 'setenv bootargs console=${console} mpurate=${mpurate} mux=${mux} vram=${vram} omapfb.vram=${omapfbvram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} ubi.mtd=${nand} root=${mmcroot} rootfstype=${mmcrootfstype}'
setenv mmcroot '/dev/mmcblk0p2 rw'
setenv mmcrootfstype 'ext4,ext3,btrfs rootwait'
setenv nandargs 'setenv bootargs console=${console} mpurate=${mpurate} mux=${mux} vram=${vram} omapfb.vram=${omapfbvram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} ubi.mtd=${nand} root=${nandroot} rootfstype=${nandrootfstype}'
setenv nandroot 'ubi0:gta04-rootfs'
setenv nandrootfstype 'ubifs'
# load kernel and boot script from mmc (any of 4 partitions FAT or ext) or nand wherever we find it
setenv kernelloading 'status set 18' # orange
setenv kernelloaded 'status set 10' # green
# run kernelloading
# i2c dev 0
# mmc rescan 0
# DONE=0
# KERNEL=0
# FDT=0
# run nandargs # start with default arguments for rootfs in NAND
# for p in $bootorder
# do
# if itest $DONE == 0
# then
# if load mmc 0:${p} ${loadaddr} uImage
# then
# echo found kernel /uImage on partition $p
# run mmcargs # start with default mmc args
# KERNEL=1
# DONE=1
# elif load mmc 0:${p} ${loadaddr} /boot/uImage
# then
# echo found kernel /boot/uImage on partition $p
# setenv mmcroot "/dev/mmcblk0p${p} rw"
# run mmcargs # start with default mmc args
# KERNEL=1
# DONE=1
# fi
# if load mmc 0:${p} ${imgtempaddr} bootargs.scr
# then
# setenv PARTITION $p
# setenv PARTITIONTYPE FAT
# source ${imgtempaddr}
# DONE=1
# elif load mmc 0:${p} ${imgtempaddr} /boot/bootargs.scr
# then
# setenv PARTITION $p
# setenv PARTITIONTYPE EXT
# source ${imgtempaddr}
# DONE=1
# fi
# if load mmc 0:${p} ${loadaddrfdt} ${devicetree}.dtb
# then
# FDT=1
# elif load mmc 0:${p} ${loadaddrfdt} /boot/${devicetree}.dtb
# then
# FDT=1
# fi
# fi
# done
# if itest $KERNEL == 0
# then
# if nand read ${loadaddr} 280000 400000
# then
# echo fallback to NAND kernel
# FDT=0
# else
# status blink
# fi
# fi
# run kernelloaded
setenv loadkernel 'run kernelloading;i2c dev 0;mmc rescan 0;DONE=0;KERNEL=0;FDT=0;run nandargs;echo trying partitions $bootorder;for p in $bootorder;do;if itest $DONE == 0;then;if load mmc 0:${p} ${loadaddr} uImage;then;echo found kernel on partition $p;run mmcargs;KERNEL=1;DONE=1;elif load mmc 0:${p} ${loadaddr} /boot/uImage;then;echo found kernel on EXT partition $p;setenv mmcroot "/dev/mmcblk0p${p} rw";run mmcargs;KERNEL=1;DONE=1;fi;if load mmc 0:${p} ${imgtempaddr} bootargs.scr;then;setenv PARTITION $p;setenv PARTITIONTYPE FAT;source ${imgtempaddr};DONE=1;elif load mmc 0:${p} ${imgtempaddr} /boot/bootargs.scr;then;setenv PARTITION $p;setenv PARTITIONTYPE EXT;source ${imgtempaddr};DONE=1;fi;if load mmc 0:${p} ${loadaddrfdt} ${devicetree}.dtb;then;FDT=1;elif load mmc 0:${p} ${loadaddrfdt} /boot/${devicetree}.dtb;then;FDT=1;fi;fi;done;if itest $KERNEL == 0;then;if nand read ${loadaddr} 280000 400000;then;echo fallback to NAND kernel;FDT=0;else;status blink;fi;fi;run kernelloaded'
# boot with kernel/rootfs from specified source
setenv boot 'if itest $FDT == 1; then bootm ${loadaddr} - ${loadaddrfdt}; else bootm ${loadaddr}; fi;'
setenv mmcboot 'if run loadkernel; then run boot; fi;'
setenv nandboot 'run kernelloading; if nand read ${loadaddr} 280000 400000; then run nandargs; run kernelloaded; bootm ${loadaddr}; fi;'
# run the boot script - and fall back to direct kernel boot
setenv bootcmd 'if run loadbootscript; then run bootscript; else run mmcboot; fi;'
setenv bootscript 'echo Running bootscript ...; source ${bootaddr}'
# write script version number permanently
setenv scriptversion "${VERSION}"
flash=yes # trigger flashing
fi
echo *** initializing LCM ***
if lcm start || test "${flash}" = "yes"
then
if test "x${flash}" = "xyes"
then
lcm color ff0000 # will flash - turn screen red
else
echo *** loading splash from MMC ***
setenv imgaddr 80400000
setenv imgfile splash
setenv imgnandaddr 1d0000
run showimg
fi
if test "x${flash}" = "xyes" || test "x${forcemenu}" = "xyes" || status check 1 # we want to flash or AUX button is (still) pressed
then
if test "x${forcemenu}" = "xyes"
then # reset
setenv forcemenu
saveenv
fi
echo *** initializing TSC for boot menu ***
tsc init # tsc selection will be 0
while true
do
if test "x${flash}" != "xyes"
then
echo *** loading boot menu image ***
setenv imgaddr 80600000
setenv imgfile menu
setenv imgnandaddr 210000
run showimg
tsc choose 3 3 # 3 columns 3 rows -> value 1 .. 9
# restore boot image
# setenv imgaddr 80400000
# setenv imgfile splash
# setenv imgnandaddr 1d0000
# run showimg
fi
if tsc selection 7
then
lcm color 00ff00 # turn screen green (feedback to touch press)
lcm fb 0
echo *** LED mirror ***
status mirror
elif tsc selection 8
then
lcm color 0000ff # turn screen blue
lcm fb 0
echo *** LED blink ***
# systest all
status blink
elif tsc selection 9
then
echo *** TSC test ***
tsc gloop
elif tsc selection 99
then
lcm color 00ff00 # turn screen green (feedback to touch press)
lcm fb 0
echo *** LCD boot ***
setenv defaultdisplay lcd
run mmcboot
elif tsc selection 5
then
lcm color 00ff00 # turn screen green (feedback to touch press)
lcm fb 0
setenv bootorder ""
echo *** NAND boot ***
setenv defaultdisplay lcd
saveenv
run mmcboot
elif tsc selection 6
then
lcm color 555555 # turn screen green (feedback to touch press)
lcm fb 0
sleep 1
poweroff
# OLD
echo *** DVI boot ***
if run loadkernel
then
setenv bootdelay 10
setenv defaultdisplay dvi # this is not made persistent!
setenv dvimode 1024x768MR-16@60
lcm backlight 0
lcm off
lcm power 0
run mmcboot
fi
elif tsc selection 1
then
lcm color 00ff00 # turn screen green (feedback to touch press)
lcm fb 0
echo *** MMC boot partition 1***
setenv bootorder "1 2 3 4"
echo new boot order $bootorder
setenv defaultdisplay lcd
saveenv
run mmcboot
elif tsc selection 2
then
lcm color 55ff00 # turn screen green (feedback to touch press)
lcm fb 0
echo *** MMC boot partition 1***
setenv bootorder "2 3 4 1"
echo new boot order $bootorder
setenv defaultdisplay lcd
saveenv
run mmcboot
elif tsc selection 3
then
lcm color 00ff55 # turn screen green (feedback to touch press)
lcm fb 0
echo *** MMC boot partition 1***
setenv bootorder "3 4 1 2"
echo new boot order $bootorder
setenv defaultdisplay lcd
saveenv
run mmcboot
elif tsc selection 4
then
lcm color 55ff55 # turn screen green (feedback to touch press)
lcm fb 0
echo *** MMC boot partition 1***
setenv bootorder "4 1 2 3"
echo new boot order $bootorder
setenv defaultdisplay lcd
saveenv
run mmcboot
elif test "x${flash}" = "xyes" || tsc selection 99
then
echo *** NAND flash ***
# note: MLO is configured to load U-Boot from MMC
# while X-Loader is loading U-Boot from NAND
status set 10
i2c dev 0
if fatload mmc 0 0x80200000 x-load.flash
then
status set 18
echo *** flashing Xloader ***
# nand unlock
nandecc hw
# write some copies
nand erase 0 80000
nand write 0x80200000 0 20000
nand write 0x80200000 20000 20000
nand write 0x80200000 40000 20000
nand write 0x80200000 60000 20000
echo *** Xloader flashed ***
fi
status set 10
# the official u-boot partition goes from 0x80000 to 0x27ffff i.e. 2 MByte
if fatload mmc 0 0x80300000 u-boot.flash
then
echo *** flashing U-Boot ***
status set 18
nandecc sw
nand erase 80000 1e0000
nand write 0x80300000 80000 150000
echo *** write our new environment ***
saveenv
# read&write compressed splash image to nand
# there is just room for 614 kByte
# since u-boot is approx 260 kByte
status set 10
if fatload mmc 0 0x80300000 splash.rgb16z
then
echo *** flashing splash ***
status set 18
nandecc sw
nand write 0x80300000 1d0000 40000
status set 10
fi
status set 10
if fatload mmc 0 0x80300000 menu.rgb16z
then
echo *** flashing menu ***
status set 18
nandecc sw
nand write 0x80300000 210000 40000
status set 18
fi
status set 10
if fatload mmc 0 0x80300000 boot.scr
then
echo *** flashing boot.scr ***
status set 18
nandecc sw
nand write 0x80300000 250000 10000
fi
echo *** U-Boot flashed ***
fi
# please flash kernel and rootfs from Linux
status set 8
flash=no # don't flash again
echo
echo *********************************
echo *** Flashing Done ***
echo *** Device will reboot ***
echo *********************************
echo
run mmcboot
# reset # resets CPU only but not BootROM boot order!
# we simply show the menu
else
echo *** Could not decode ***
status blink
fi
done
else # default boot w/o menu
echo *** booting Linux ***
if run loadkernel
then
# lcm backlight 0 # switch off before booting (?)
printenv
lcm power 0
lcm off # avoid wash-out
run boot
fi
fi
else # LCM did not init (e.g. we run without display)
echo *** DVI boot ***
if run loadkernel
then
setenv bootdelay 10
setenv defaultdisplay dvi
setenv dvimode 1024x768MR-16@60
run boot
fi
fi
echo *** Could not run ***
lcm color ff0000
lcm fb 0
status blink
|