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