blob: 009ea0ba947497797edf1908edab7ab5686e72dd [file] [log] [blame]
Christian Hewitte47d45b2023-03-20 11:46:07 +00001.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for BananaPi BPI-M5 (S905X3)
4===================================
5
6BananaPi BPI-M5 is a Single Board Computer manufactured by Sinovoip with the following
7specification:
8
9 - Amlogic S905X3 Arm Cortex-A55 quad-core SoC
10 - 4GB DDR4 SDRAM
11 - 16GB eMMC
12 - Gigabit Ethernet
13 - HDMI 2.1 display
14 - 40-pin GPIO header
15 - 4x USB 3.0 Host
16 - 1x USB-C (power)
17 - microSD
18 - UART serial
19 - Infrared receiver
20
21Schematics are available from the manufacturer: https://wiki.banana-pi.org/Banana_Pi_BPI-M5
22
23U-Boot Compilation
24------------------
25
26.. code-block:: bash
27
28 $ export CROSS_COMPILE=aarch64-none-elf-
29 $ make bananapi-m5_defconfig
30 $ make
31
32U-Boot Signing with Pre-Built FIP repo
33--------------------------------------
34
35.. code-block:: bash
36
37 $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
38 $ cd amlogic-boot-fip
39 $ mkdir my-output-dir
40 $ ./build-fip.sh bananapi-m5 /path/to/u-boot/u-boot.bin my-output-dir
41
42U-Boot Manual Signing
43---------------------
44
45Amlogic does not provide sources for the firmware and tools needed to create a bootloader
46image so it is necessary to obtain binaries from sources published by the board vendor:
47
48.. code-block:: bash
49
50 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
51 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
52 $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
53 $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
54 $ 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
55
56 $ DIR=bananapi-m5
57 $ git clone --depth 1 https://github.com/Dangku/amlogic-u-boot.git -b odroidg12-v2015.01-c4-m5 $DIR
58
59 $ cd $DIR
60 $ make bananapi_m5_defconfig
61 $ make
62 $ export UBOOTDIR=$PWD
63
64Go back to the mainline U-Boot source tree then:
65
66.. code-block:: bash
67
68 $ mkdir fip
69
70 $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
71 $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
72 $ cp $UBOOTDIR/build/board/bananapi/bananpi_m5/firmware/acs.bin fip/
73 $ cp $UBOOTDIR/fip/g12a/bl2.bin fip/
74 $ cp $UBOOTDIR/fip/g12a/bl30.bin fip/
75 $ cp $UBOOTDIR/fip/g12a/bl31.img fip/
76 $ cp $UBOOTDIR/fip/g12a/ddr3_1d.fw fip/
77 $ cp $UBOOTDIR/fip/g12a/ddr4_1d.fw fip/
78 $ cp $UBOOTDIR/fip/g12a/ddr4_2d.fw fip/
79 $ cp $UBOOTDIR/fip/g12a/diag_lpddr4.fw fip/
80 $ cp $UBOOTDIR/fip/g12a/lpddr3_1d.fw fip/
81 $ cp $UBOOTDIR/fip/g12a/lpddr4_1d.fw fip/
82 $ cp $UBOOTDIR/fip/g12a/lpddr4_2d.fw fip/
83 $ cp $UBOOTDIR/fip/g12a/piei.fw fip/
84 $ cp $UBOOTDIR/fip/g12a/aml_ddr.fw fip/
85 $ cp u-boot.bin fip/bl33.bin
86
87 $ sh fip/blx_fix.sh \
88 fip/bl30.bin \
89 fip/zero_tmp \
90 fip/bl30_zero.bin \
91 fip/bl301.bin \
92 fip/bl301_zero.bin \
93 fip/bl30_new.bin \
94 bl30
95
96 $ sh fip/blx_fix.sh \
97 fip/bl2.bin \
98 fip/zero_tmp \
99 fip/bl2_zero.bin \
100 fip/acs.bin \
101 fip/bl21_zero.bin \
102 fip/bl2_new.bin \
103 bl2
104
105 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl30sig --input fip/bl30_new.bin \
106 --output fip/bl30_new.bin.g12a.enc \
107 --level v3
108 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl30_new.bin.g12a.enc \
109 --output fip/bl30_new.bin.enc \
110 --level v3 --type bl30
111 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl31.img \
112 --output fip/bl31.img.enc \
113 --level v3 --type bl31
114 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl3sig --input fip/bl33.bin --compress lz4 \
115 --output fip/bl33.bin.enc \
116 --level v3 --type bl33 --compress lz4
117 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bl2sig --input fip/bl2_new.bin \
118 --output fip/bl2.n.bin.sig
119 $ $UBOOTDIR/fip/g12a/aml_encrypt_g12a --bootmk \
120 --output fip/u-boot.bin \
121 --bl2 fip/bl2.n.bin.sig \
122 --bl30 fip/bl30_new.bin.enc \
123 --bl31 fip/bl31.img.enc \
124 --bl33 fip/bl33.bin.enc \
125 --ddrfw1 fip/ddr4_1d.fw \
126 --ddrfw2 fip/ddr4_2d.fw \
127 --ddrfw3 fip/ddr3_1d.fw \
128 --ddrfw4 fip/piei.fw \
129 --ddrfw5 fip/lpddr4_1d.fw \
130 --ddrfw6 fip/lpddr4_2d.fw \
131 --ddrfw7 fip/diag_lpddr4.fw \
132 --ddrfw8 fip/aml_ddr.fw \
133 --ddrfw9 fip/lpddr3_1d.fw \
134 --level v3
135
136Then write the image to SD or eMMC with:
137
138.. code-block:: bash
139
140 $ DEV=/dev/boot_device
141 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
142 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440