blob: 672cbee7d8e582f4b0635d86cde0ea4e7b953321 [file] [log] [blame]
Christian Hewittefe2c392023-03-20 11:46:06 +00001.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for BananaPi CM4 with CM4IO (A311D)
4==========================================
5
6BPI-CM4 is a system-on-module board manufactured by Sinovoip. It follows the Raspberry Pi
7CM4 interface specification but with a single HDMI port and a single DSI output:
8
9 - Amlogic A311D Arm Cortex-A53 dual-core + Cortex-A73 quad-core SoC
10 - 4GB DDR4 SDRAM
11 - 16GB eMMC
12 - NPU
13 - HDMI 2.1 display
14 - Gigabit Ethernet
15 - RTL8822CS WiFi (a/b/g/n/ac) + BT 5.0
16
17BPI-CM4IO is a carrier board for the BPI-CM4 module with the following specification:
18
19 - CM4 interface
20 - HDMI interface
21 - MIPI CSI interface
22 - MIPI DSI interface
23 - Ethernet interface
24 - PCIe interface
25 - SD (micro)
26 - SIM (micro)
27 - 26-pin GPIO
28 - UART serial
29 - 1x USB-C (power)
30 - 2x USB 2.0
31
32Schematics are available from the manufacturer: https://wiki.banana-pi.org/Banana_Pi_BPI-CM4
33
34U-Boot Compilation
35------------------
36
37.. code-block:: bash
38
39 $ export CROSS_COMPILE=aarch64-none-elf-
40 $ make bananapi-cm4io_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-cm4io /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-cm4io
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_cm4_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_cm4/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