usb-boot 1.44 KB
Newer Older
1
#!/bin/sh -e
2
top=`dirname $0`
3
if [ $# -lt 2 ]; then
4
	echo "Usage: $0 u-boot-spl.bin u-boot.bin [boot.scr|-] [kernel script.bin [initramfs]]"
5
6
	exit 1
fi
7
board=$1; shift || (echo "ERROR: u-boot-spl.bin must be specified"; exit 1;)
8
uboot=$1; shift || (echo "ERROR: u-boot.bin must be specified"; exit 1;)
Alejandro Mery's avatar
Alejandro Mery committed
9
bootscr=$top/felboot/ramboot.scr
10
11
12
13
14
15
16
if [ ! -f $bootscr ]; then
	bootscr=$top/bin/ramboot.scr
fi
case "$1" in
*.scr)	bootscr="$1"; shift
	;;
esac
17
18
19
kernel=$1; shift || true
scriptbin=$1; shift || true
initramfs=$1; shift || true
20
21
fel() {
	echo fel "$@"
22
	$top/fel $@
23
}
24
25
26
27
28
29
30
31
32
33
case $board in
*/*)	felboot=$board
	;;
*)
	felboot=$top/felboot/fel-boot-${board}.bin
	if [ ! -f $felboot ]; then
		felboot=$top/bin/fel-boot-${board}.bin
	fi
	;;
esac
34
if [ ! -f $felboot ]; then
35
36
37
38
39
	echo "ERROR: Can't find SPL FEL binary ${board}"
	exit 1
fi
if [ `wc -c $felboot | cut '-d ' -f1` -gt 15616 ]; then
	echo "ERROR: SPL FEL binary too large. Must be the FEL version of SPL"
40
41
	exit 1
fi
42
43
44
45
if [ ! -f $bootscr ]; then
	echo "ERROR: Can't fint boot script '${bootscr}'"
	exit 1
fi
46
47
fel write 0x2000 $felboot
fel exe 0x2000
48
sleep 1 # Wait for DRAM initialization to complete
49
50
51
if [ -n "$uboot" ]; then
	fel write 0x4a000000 $uboot
fi
52
53
54
if [ -n "$bootscr" ]; then
	fel write 0x41000000 $bootscr
fi
55
if [ -n "$kernel" ]; then
56
 if [ -n "$scriptbin" ]; then
57
58
59
60
61
62
63
64
  fel write 0x43000000 $scriptbin
 fi
 fel write 0x44000000 $kernel
 if [ -n "$initramfs" ]; then
  fel write 0x4c000000 $initramfs
 fi
fi
fel exe 0x4a000000