-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootpartgen-2020.1
83 lines (69 loc) · 2.33 KB
/
bootpartgen-2020.1
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
#!/bin/bash
#
# when this script is executed, the current working directory shall contain:
#
# device-tree-xlnx/
#
# fsbl.elf
# original-devicetree.dtb
# u-boot.elf
# uImage
# uramdisk.image.gz
#
# fpga.bit
# fpga.xsa
#
set -e
trap 'echo "Error at line $LINENO in $BASH_SOURCE"' ERR
command -v bootgen > /dev/null
command -v xsct > /dev/null
command -v dtc > /dev/null
test -d device-tree-xlnx
test -f fsbl.elf
test -f original-devicetree.dtb
test -f u-boot.elf
test -f uImage
test -f uramdisk.image.gz
test -f fpga.bit
test -f fpga.xsa
mkdir -p bootpart
echo Writing bootpart/BOOT.BIN
bootgen -w on -o bootpart/BOOT.BIN -image <( printf '
the_ROM_image:
{
[bootloader]fsbl.elf
fpga.bit
u-boot.elf
}
' )
echo Writing bootpart/devicetree.dtb
mkdir -p .tmp_hsi_
cd .tmp_hsi_
ln -s ../fpga.xsa .
ln -s ../device-tree-xlnx .
xsct -quiet < <( printf %s '
hsi open_hw_design fpga.xsa
hsi set_repo_path device-tree-xlnx
hsi create_sw_design device-tree -os device_tree -proc ps7_cortexa9_0
hsi generate_target -dir .
' ) > /dev/null
cd ..
mv .tmp_hsi_/pl.dtsi fpga.dtsi
rm -rf .tmp_hsi_
sed -i 's/amba_pl: amba_pl/amba_pl: amba/' fpga.dtsi
sed -i 's/interrupts = <0 29 4>;/interrupts = <0 29 1>;/' fpga.dtsi
sed -i 's/interrupt-parent = <&intc>;/interrupt-parent = <0x3>;/' fpga.dtsi
dtc -I dtb -O dts -o devicetree.dts original-devicetree.dtb
echo '/include/ "fpga.dtsi"' >> devicetree.dts
dtc -I dts -O dtb -o bootpart/devicetree.dtb devicetree.dts
rm devicetree.dts
IPNAME=$(grep "compatible = \"xlnx,.*\"" fpga.dtsi | sed "s/\t//g" | sed "s/compatible = \"xlnx,//g" | sed "s/\";//g")
rm fpga.dtsi
BOOTARGS="console=ttyPS0,115200 root=/dev/mmcblk0p2 rootwait rw earlyprintk uio_pdrv_genirq.of_id=xlnx,${IPNAME}"
SDBOOT='if mmcinfo; then run uenvboot; echo Copying Linux from SD to RAM... && load mmc 0 ${kernel_load_address} ${kernel_image} && load mmc 0 ${devicetree_load_address} ${devicetree_image} && load mmc 0 ${ramdisk_load_address} ${ramdisk_image} && bootm ${kernel_load_address} - ${devicetree_load_address}; fi'
echo Writing bootpart/uEnv.txt
printf 'bootargs=%s\nsdboot=%s\n' "$BOOTARGS" "$SDBOOT" > bootpart/uEnv.txt
echo Writing bootpart/uImage
cp uImage bootpart/uImage
echo Writing bootpart/uramdisk.image.gz
cp uramdisk.image.gz bootpart/uramdisk.image.gz