usb-boot 2.61 KB
Newer Older
1
#!/bin/sh -e
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# Copyright (C) 2013  Henrik Nordstrom <henrik@henriknordstrom.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

23
top=`dirname $0`
24
if [ $# -lt 2 ]; then
Michal Suchanek's avatar
Michal Suchanek committed
25
	echo "Usage: $0 u-boot-spl.bin u-boot.bin [boot.scr] [kernel script.bin [initramfs]]"
26
27
	exit 1
fi
28
board=$1; shift || (echo "ERROR: u-boot-spl.bin must be specified"; exit 1;)
29
uboot=$1; shift || (echo "ERROR: u-boot.bin must be specified"; exit 1;)
Alejandro Mery's avatar
Alejandro Mery committed
30
bootscr=$top/felboot/ramboot.scr
31
32
33
34
35
36
37
if [ ! -f $bootscr ]; then
	bootscr=$top/bin/ramboot.scr
fi
case "$1" in
*.scr)	bootscr="$1"; shift
	;;
esac
38
39
40
41
42
43
44
45
46
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
47
48
fel() {
	echo fel "$@"
49
	$top/fel $@
50
}
51
52
53
54
55
56
57
58
59
60
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
61
if [ ! -f $felboot ]; then
62
63
64
65
66
	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"
67
68
	exit 1
fi
69
if [ ! -f $bootscr ]; then
70
	echo "ERROR: Can't find boot script '${bootscr}'"
71
72
	exit 1
fi
73
74
fel write 0x2000 $felboot
fel exe 0x2000
75
sleep 1 # Wait for DRAM initialization to complete
76
77
78
if [ -n "$uboot" ]; then
	fel write 0x4a000000 $uboot
fi
79
80
81
if [ -n "$bootscr" ]; then
	fel write 0x41000000 $bootscr
fi
82
if [ -n "$kernel" ]; then
83
 if [ -n "$scriptbin" ]; then
84
85
86
87
88
89
90
91
  fel write 0x43000000 $scriptbin
 fi
 fel write 0x44000000 $kernel
 if [ -n "$initramfs" ]; then
  fel write 0x4c000000 $initramfs
 fi
fi
fel exe 0x4a000000