forked from linux-sunxi/sunxi-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usb-boot
executable file
·70 lines (70 loc) · 1.51 KB
/
usb-boot
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
#!/bin/sh -e
top=`dirname $0`
if [ $# -lt 2 ]; then
echo "Usage: $0 u-boot-spl.bin u-boot.bin [boot.scr] [kernel script.bin [initramfs]]"
exit 1
fi
board=$1; shift || (echo "ERROR: u-boot-spl.bin must be specified"; exit 1;)
uboot=$1; shift || (echo "ERROR: u-boot.bin must be specified"; exit 1;)
bootscr=$top/felboot/ramboot.scr
if [ ! -f $bootscr ]; then
bootscr=$top/bin/ramboot.scr
fi
case "$1" in
*.scr) bootscr="$1"; shift
;;
esac
if [ $# -ge 1 ]; then
kernel=$1; shift || true
fi
if [ $# -ge 1 ]; then
scriptbin=$1; shift || true
fi
if [ $# -ge 1 ]; then
initramfs=$1; shift || true
fi
fel() {
echo fel "$@"
$top/fel $@
}
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
if [ ! -f $felboot ]; then
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"
exit 1
fi
if [ ! -f $bootscr ]; then
echo "ERROR: Can't fint boot script '${bootscr}'"
exit 1
fi
fel write 0x2000 $felboot
fel exe 0x2000
sleep 1 # Wait for DRAM initialization to complete
if [ -n "$uboot" ]; then
fel write 0x4a000000 $uboot
fi
if [ -n "$bootscr" ]; then
fel write 0x41000000 $bootscr
fi
if [ -n "$kernel" ]; then
if [ -n "$scriptbin" ]; then
fel write 0x43000000 $scriptbin
fi
fel write 0x44000000 $kernel
if [ -n "$initramfs" ]; then
fel write 0x4c000000 $initramfs
fi
fi
fel exe 0x4a000000