-
Notifications
You must be signed in to change notification settings - Fork 18
/
readme.gxb
126 lines (98 loc) · 5.06 KB
/
readme.gxb
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
# the following is relevant for gxbb (s905)
# building atf
git clone https://github.com/ARM-software/arm-trusted-firmware.git
mv arm-trusted-firmware arm-trusted-firmware-gxb
cd arm-trusted-firmware-gxb
git checkout v2.3
make realclean
make PLAT=gxbb DEBUG=1 bl31
# result: build/gxbb/debug/bl31.bin
# the below did not work - see way below for a working mainline atf solution
# # build doimage tool to add the required header to bl31.bin -> bl31.img
# cd tools/amlogic
# make
# cd ../../
# # see https://freenode.irclog.whitequark.org/linux-amlogic/2020-07-24#27575108
# tools/amlogic/doimage build/gxbb/debug/bl31.bin build/gxbb/debug/bl31.img
# cp build/gxbb/debug/bl31.img build/gxbb/debug/gxb-bl31.img
cp build/gxbb/debug/bl31.bin build/gxbb/debug/gxb-bl31.bin
cd ..
# building u-boot
git clone https://gitlab.denx.de/u-boot/u-boot.git/
mv u-boot u-boot-mainline-gxb
cd u-boot-mainline-gxb
git checkout v2020.07
# add usb kbd and uEnv.txt support and set some own string instead
# of p201 to make clear this is modified
patch -p1 < /compile/doc/u-boot-misc/misc.gxb/add-usb-kbd-uenv-txt-and-own-strings.patch
# use this patch instead if serial console is wanted instead of hdmi/usbkbd
#patch -p1 < /compile/doc/u-boot-misc/misc.gxb/add-uenv-txt-and-own-strings.patch
make p201_defconfig
make
cp u-boot.bin gxb-u-boot.bin
cd ..
# boot block creation - all the below cases were trested and verified to work
# the parts marked with x86_64 binary have to be run on an x86_64 system or
# maybe even via qemu for x86_64 on arm (not tested, but should be possible)
# getting the trees containing the blobs required to assemble the boot block
cd /compile/source/u-boot-gxb-blob-sources
git clone --depth 1 https://github.com/BayLibre/u-boot.git -b n-amlogic-openlinux-20170606 u-boot-amlogic-baylibre-20170606
git clone --depth 1 https://github.com/hardkernel/u-boot.git -b odroidc2-v2015.01 u-boot-odroid-c2
git clone --depth 1 https://github.com/friendlyarm/u-boot.git -b nanopi-k2-v2015.01 u-boot-nanopi-k2
wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/nanopi-k2_fip_20170412.tar.gz
mkdir u-boot-workdir-gxb
cd u-boot-workdir-gxb
tar xzf /compile/source/u-boot-gxb-blob-sources/nanopi-k2_fip_20170412.tar.gz
cp ../u-boot-mainline-gxb/u-boot.bin .
mkdir build
export FIPDIR=fip
cp $FIPDIR/gxb/bl2.bin build/
cp $FIPDIR/gxb/acs.bin build/
cp $FIPDIR/gxb/bl21.bin build/
cp $FIPDIR/gxb/bl30.bin build/
cp $FIPDIR/gxb/bl301.bin build/
cp $FIPDIR/gxb/bl31.img build/
cp u-boot.bin build/bl33.bin
$FIPDIR/blx_fix.sh build/bl30.bin build/zero_tmp build/bl30_zero.bin build/bl301.bin build/bl301_zero.bin build/bl30_new.bin bl30
# x86_64 binary
$FIPDIR/fip_create --bl30 build/bl30_new.bin --bl31 build/bl31.img --bl33 build/bl33.bin build/fip.bin
# x86_64 binary
python $FIPDIR/acs_tool.pyc build/bl2.bin build/bl2_acs.bin build/acs.bin 0
$FIPDIR/blx_fix.sh build/bl2_acs.bin build/zero_tmp build/bl2_zero.bin build/bl21.bin build/bl21_zero.bin build/bl2_new.bin bl2
cat build/bl2_new.bin build/fip.bin > build/boot_new.bin
# x86_64 binary
$FIPDIR/gxb/aml_encrypt_gxb --bootsig --input build/boot_new.bin --output build/u-boot.bin
# prepare it for imagebuilder/sonaremin
dd if=/dev/zero of=boot-amlogic_gxb-aarch64.dd bs=512 count=1
cat build/u-boot.bin >> boot-amlogic_gxb-aarch64.dd
# write to sd card
dd if=build/u-boot.bin of=/dev/sd-card conv=fsync,notrunc bs=512 seek=1
# write to emmc (untested)
dd if=build/u-boot.bin of=/dev/emmc-device conv=fsync,notrunc bs=1 count=446
dd if=build/u-boot.bin of=/dev/emmc-device conv=fsync,notrunc bs=512 skip=1 seek=1
# see https://freenode.irclog.whitequark.org/linux-amlogic/2020-07-24 for below
# for doing the same with the self built atf instead of the blob one - just replace
#cp $FIPDIR/gxb/bl31.img build/
# with:
# take the header from the blob bl31.img
dd if=$FIPDIR/gxb/bl31.img of=build/bl31.img bs=512 count=1
# and append out self built atf bl31.bin
cat ../arm-trusted-firmware-gxb/build/gxbb/debug/bl31.bin >> build/bl31.img
# and run everything else like above ...
# afterwards: just to make clear where certain files in the release section come from
cp build/bl31.img build/gxb-bl31.img
cp boot-amlogic_gxb-aarch64.dd boot-amlogic_gxb_atf-aarch64.dd
# some older notes which were not relevant in the end
# # maybe the resulting u-boot.bin needs the bl31.bin part rehashed
# # building tool to rehash bl31.bin in the created bootloader
# # see https://fredericb.info/2016/10/amlogic-s905-soc-bypassing-not-so.html
# git clone https://github.com/frederic/aml_bootloader_tool.git
# cd aml_bootloader_tool
# apt-get install libtomcrypt-dev
# gcc -o aml_bootloader_tool aml_bootloader_tool.c -ltomcrypt
# cd ..
# /compile/source/aml_bootloader_tool/aml_bootloader_tool build/u-boot.bin H 2
# # did not work neither ... giving up for now
# # the below try with the self compiled atf did not work - maybe related: https://freenode.irclog.whitequark.org/linux-amlogic/2018-10-09 ... i guess the bl31.bin from the atf compile needs to somehow be encrypted
# # or signed to work properly ...
# # see also: https://freenode.irclog.whitequark.org/linux-amlogic/2018-09-17#23084770