forked from Mellanox/bfscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-bfb
executable file
·177 lines (161 loc) · 4.73 KB
/
build-bfb
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
#!/bin/sh
# Build a BlueField bootstream file to boot off a disk that has
# the disk.img file burned into it (or boot.img, if used with --no-gpt).
# By default assume we are running in the directory where the script lives.
set -e
usage ()
{
echo "syntax: build-bfb [--bfb INPUT_BFBFILE] [--kernel IMAGE] \\"
echo " [--root ROOTPATH] [--bootarg BOOTARG] [--bootdesc BOOTDESC] \\"
echo " [--initramfs INITRAMFS] [--uart 0|1|rshim|all] [--sys SYSTEM] \\"
echo " [--mmc-cap CAPSULE --spi-img FIRMWARE] [--no-gpt] [-i] \\"
echo " rshim|mmc0|nvme0 OUTPUT"
}
bfb=
kernel=Image
initramfs=initramfs
use_initramfs=
verbose=
gpt=1
kernelargs=
root=
uart=
sys=
mmc_cap=
spi_img=
options=`getopt -n build-bfb -o ivh \
-l help,kernel:,initramfs:,bfb:,verbose,no-gpt,bootdesc:,bootarg:,sys:,uart:,root:,mmc-cap:,spi-img: -- "$@"`
eval set -- $options
while [ "$1" != -- ]; do
case $1 in
--help|-h) usage; exit 0 ;;
--kernel) shift; kernel=$1 ;;
--initramfs) shift; initramfs=$1 ;;
-i) use_initramfs=1 ;;
--bfb) shift; bfb=$1 ;;
--verbose|-v) verbose=1 ;;
--no-gpt) gpt= ;;
--bootdesc) shift; bootdesc="$1" ;;
--bootarg) shift; kernelargs="$kernelargs $1" ;;
--uart) shift; uart="$1" ;;
--sys) shift; sys="$1" ;;
--root) shift; root=$1 ;;
--mmc-cap) shift; mmc_cap=$1 ;;
--spi-img) shift; spi_img=$1 ;;
esac
shift
done
shift
if [ $# -ne 2 ]; then
usage >&2
exit 1
fi
device=$1
output=$2
if [ -z "$bfb" ]; then
if [ -z "$sys" ]; then
echo "build-bfb: must specify system or provide bfb" >&2
exit 1
else
bfb=../boot/default.bfb
fi
fi
if [ -z "$uart" ]; then
case $sys in
MBE1x0x)
# Use UART 1 for Bluewhale
uart="1"
;;
sim)
uart="0"
use_initramfs=1
gpt=
;;
hw)
uart="all"
;;
*)
uart="0"
;;
esac
fi
case $device in
mmc0)
bootdesc=${bootdesc:-"Linux from mmc0"}
uefidev="VenHw(8C91E049-9BF9-440E-BBAD-7DC5FC082C02)"
linuxdev=mmcblk0
;;
nvme0)
bootdesc=${bootdesc:-"Linux from nvme0"}
uefidev="PciRoot(0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/Pci(0x0,0x0)/NVMe(0x1,00-00-00-00-00-00-00-00)"
linuxdev=nvme0n1
;;
rshim)
bootdesc=${bootdesc:-"Linux from rshim"}
if [ -n "$gpt" ]; then
echo "build-bfb: using device 'rshim' requires --no-gpt" >&2
exit 1
fi
extra_mkbootargs="--image $kernel"
if [ -n "$use_initramfs" ]; then
extra_mkbootargs="$extra_mkbootargs --initramfs $initramfs"
fi
uefidev="VenHw(F019E406-8C9C-11E5-8797-001ACA00BFC4)"
;;
*)
echo "build-bfb: must specify device as rshim, mmc0, or nvme0" >&2
exit 1
;;
esac
if [ -n "$use_initramfs" ]; then
# Ignore the root partition
kernelargs="$kernelargs initrd=initramfs"
else
if [ -z "$root" ]; then
# If no root specified for a GPT boot, assume root is 2nd partition
if [ -n "$gpt" ]; then
root="/dev/${linuxdev}p2"
else
echo "build-bfb --no-gpt: must specify --root or -i" >&2
exit 1
fi
fi
# Ignore the initramfs in the boot partition
kernelargs="$kernelargs root=$root rootwait"
fi
if [ -n "$mmc_cap" ]; then
extra_mkbootargs="$extra_mkbootargs --mmc-cap $mmc_cap"
fi
if [ -n "$spi_img" ]; then
extra_mkbootargs="$extra_mkbootargs --spi-img $spi_img"
fi
if [ -n "$gpt" ]; then
# Note that we assume the partition table generated in build-image.
kernelpath="$uefidev/HD(1,GPT,3DCADB7E-BCCC-4897-A766-3C070EDD7C25,0x800,0xAE800)/Image"
else
kernelpath="$uefidev/Image"
fi
if [ ."$uart" = ."0" ]; then
consolearg="console=ttyAMA0 earlycon=pl011,0x01000000"
elif [ ."$uart" = ."1" ]; then
consolearg="console=ttyAMA1 earlycon=pl011,0x01800000"
elif [ ."$uart" = ."rshim" ]; then
consolearg="console=hvc0"
elif [ ."$uart" = ."all" ]; then
consolearg="console=ttyAMA1 console=hvc0 console=ttyAMA0 earlycon=pl011,0x01000000 earlycon=pl011,0x01800000"
else
echo "build-bfb --uart: UART must be 0, 1, rshim or all" >&2
exit 1
fi
if [ -n "$verbose" ]; then
echo "boot desc: $bootdesc"
echo "boot path: $kernelpath"
echo "boot args: $consolearg $kernelargs"
if [ -n "$extra_mkbootargs" ]; then
echo "extra tile-mkboot args: $extra_mkbootargs"
fi
fi
mlx-mkbfb --boot-desc "=$bootdesc" --boot-path "=$kernelpath" \
--boot-args "=$consolearg $kernelargs" \
$extra_mkbootargs $bfb $output.tmp
mv -f $output.tmp $output