blob: 4a1be47b35021db786ba48b018678260b47b6a41 [file] [log] [blame]
Christian Hewittdc498022023-03-23 14:31:36 +00001.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for BananaPi M2S (A311D & S922X)
4=======================================
5
6BananaPi BPI-M2S ships is a Single Board Computer manufactured by Sinovoip that ships in
7two variants with Amlogic S922X or A311D SoC and the following common specification:
8
9- 16GB eMMC
10- HDMI 2.1a video
11- 2x 10/100/1000 Base-T Ethernet (1x RTL8211F, 1x RTL811H)
12- 2x USB 2.0 ports
13- 2x Status LED's (green/blue)
14- 1x Power/Reset button
15- 1x micro SD card slot
16- 40-pin GPIO header
17- PWM fan header
18- UART header
19
20The S992X variant has:
21- 2GB LPDDR4 RAM
22
23The A311D variant has:
24
25- 4GB LPDDR4 RAM
26- NPU (5.0 TOPS)
27- MIPI DSI header
28- MIPI CSI header
29
30An optional RTL8822CS SDIO WiFi/BT mezzanine is available for both board variants.
31
32Schematics are available from the manufacturer: https://wiki.banana-pi.org/Banana_Pi_BPI-M2S
33
34U-Boot Compilation
35------------------
36
37.. code-block:: bash
38
39 $ export CROSS_COMPILE=aarch64-none-elf-
40 $ make bananapi-m2s_defconfig
41 $ make
42
43U-Boot Signing with Pre-Built FIP repo
44--------------------------------------
45
46.. code-block:: bash
47
48 $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
49 $ cd amlogic-boot-fip
50 $ mkdir my-output-dir
51 $ ./build-fip.sh bananapi-m2s /path/to/u-boot/u-boot.bin my-output-dir
52
53U-Boot Manual Signing
54---------------------
55
56Amlogic does not provide sources for the firmware and tools needed to create a bootloader
57image so it is necessary to obtain binaries from sources published by the board vendor:
58
59.. code-block:: bash
60
61 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
62 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
63 $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
64 $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
65 $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
66
67 $ DIR=bananapi-m2s
68 $ git clone --depth 1 https://github.com/Dangku/amlogic-u-boot.git -b khadas-g12b-v2015.01-m2s $DIR
69
70 $ cd $DIR
71 $ make bananapi_m2s_defconfig
72 $ make
73 $ export UBDIR=$PWD
74
75Go back to the mainline U-Boot source tree then:
76
77.. code-block:: bash
78
79 $ mkdir fip
80
81 $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
82 $ cp $UBDIR/build/scp_task/bl301.bin fip/
83 $ cp $UBDIR/build/board/bananapi/bananpi_m2s/firmware/acs.bin fip/
84 $ cp $UBDIR/fip/g12a/bl2.bin fip/
85 $ cp $UBDIR/fip/g12a/bl30.bin fip/
86 $ cp $UBDIR/fip/g12a/bl31.img fip/
87 $ cp $UBDIR/fip/g12a/ddr3_1d.fw fip/
88 $ cp $UBDIR/fip/g12a/ddr4_1d.fw fip/
89 $ cp $UBDIR/fip/g12a/ddr4_2d.fw fip/
90 $ cp $UBDIR/fip/g12a/diag_lpddr4.fw fip/
91 $ cp $UBDIR/fip/g12a/lpddr3_1d.fw fip/
92 $ cp $UBDIR/fip/g12a/lpddr4_1d.fw fip/
93 $ cp $UBDIR/fip/g12a/lpddr4_2d.fw fip/
94 $ cp $UBDIR/fip/g12a/piei.fw fip/
95 $ cp $UBDIR/fip/g12a/aml_ddr.fw fip/
96 $ cp u-boot.bin fip/bl33.bin
97
98 $ sh fip/blx_fix.sh \
99 fip/bl30.bin \
100 fip/zero_tmp \
101 fip/bl30_zero.bin \
102 fip/bl301.bin \
103 fip/bl301_zero.bin \
104 fip/bl30_new.bin \
105 bl30
106
107 $ sh fip/blx_fix.sh \
108 fip/bl2.bin \
109 fip/zero_tmp \
110 fip/bl2_zero.bin \
111 fip/acs.bin \
112 fip/bl21_zero.bin \
113 fip/bl2_new.bin \
114 bl2
115
116 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
117 --output fip/bl30_new.bin.g12a.enc \
118 --level v3
119 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
120 --output fip/bl30_new.bin.enc \
121 --level v3 --type bl30
122 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
123 --output fip/bl31.img.enc \
124 --level v3 --type bl31
125 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
126 --output fip/bl33.bin.enc \
127 --level v3 --type bl33 --compress lz4
128 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
129 --output fip/bl2.n.bin.sig
130 $ $UBDIR/fip/g12b/aml_encrypt_g12b --bootmk \
131 --output fip/u-boot.bin \
132 --bl2 fip/bl2.n.bin.sig \
133 --bl30 fip/bl30_new.bin.enc \
134 --bl31 fip/bl31.img.enc \
135 --bl33 fip/bl33.bin.enc \
136 --ddrfw1 fip/ddr4_1d.fw \
137 --ddrfw2 fip/ddr4_2d.fw \
138 --ddrfw3 fip/ddr3_1d.fw \
139 --ddrfw4 fip/piei.fw \
140 --ddrfw5 fip/lpddr4_1d.fw \
141 --ddrfw6 fip/lpddr4_2d.fw \
142 --ddrfw7 fip/diag_lpddr4.fw \
143 --ddrfw8 fip/aml_ddr.fw \
144 --ddrfw9 fip/lpddr3_1d.fw \
145 --level v3
146
147Then write the image to SD or eMMC with:
148
149.. code-block:: bash
150
151 $ DEV=/dev/boot_device
152 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
153 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440