Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
| 3 | U-Boot for Khadas VIM3 |
| 4 | ====================== |
| 5 | |
| 6 | Khadas VIM3 is a single board computer manufactured by Shenzhen Wesion |
| 7 | Technology Co., Ltd. with the following specifications: |
| 8 | |
| 9 | - Amlogic A311D Arm Cortex-A53 dual-core + Cortex-A73 quad-core SoC |
| 10 | - 4GB LPDDR4 SDRAM |
| 11 | - Gigabit Ethernet |
| 12 | - HDMI 2.1 display |
| 13 | - 40-pin GPIO header |
| 14 | - 1 x USB 3.0 Host, 1 x USB 2.0 Host |
| 15 | - eMMC, microSD |
| 16 | - M.2 |
| 17 | - Infrared receiver |
| 18 | |
| 19 | Schematics are available on the manufacturer website. |
| 20 | |
| 21 | U-Boot compilation |
| 22 | ------------------ |
| 23 | |
| 24 | .. code-block:: bash |
| 25 | |
| 26 | $ export CROSS_COMPILE=aarch64-none-elf- |
| 27 | $ make khadas-vim3_defconfig |
| 28 | $ make |
| 29 | |
| 30 | Image creation |
| 31 | -------------- |
| 32 | |
| 33 | Amlogic doesn't provide sources for the firmware and for tools needed |
| 34 | to create the bootloader image, so it is necessary to obtain them from |
| 35 | the git tree published by the board vendor: |
| 36 | |
| 37 | .. code-block:: bash |
| 38 | |
| 39 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 40 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 41 | $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 42 | $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 43 | $ 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 |
| 44 | |
| 45 | $ DIR=vim3-u-boot |
| 46 | $ git clone --depth 1 \ |
| 47 | https://github.com/khadas/u-boot.git -b khadas-vims-v2015.01 \ |
| 48 | $DIR |
| 49 | |
| 50 | $ cd vim3-u-boot |
| 51 | $ make kvim3_defconfig |
| 52 | $ make |
| 53 | $ export UBOOTDIR=$PWD |
| 54 | |
| 55 | Go back to mainline U-Boot source tree then : |
| 56 | |
| 57 | .. code-block:: bash |
| 58 | |
| 59 | $ mkdir fip |
| 60 | |
| 61 | $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/ |
| 62 | $ cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/ |
| 63 | $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/ |
| 64 | $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/ |
| 65 | $ cp $UBOOTDIR/fip/g12b/bl31.img fip/ |
| 66 | $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/ |
| 67 | $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/ |
| 68 | $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/ |
| 69 | $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/ |
| 70 | $ cp $UBOOTDIR/fip/g12b/lpddr3_1d.fw fip/ |
| 71 | $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/ |
| 72 | $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/ |
| 73 | $ cp $UBOOTDIR/fip/g12b/piei.fw fip/ |
| 74 | $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/ |
| 75 | $ cp u-boot.bin fip/bl33.bin |
| 76 | |
| 77 | $ sh fip/blx_fix.sh \ |
| 78 | fip/bl30.bin \ |
| 79 | fip/zero_tmp \ |
| 80 | fip/bl30_zero.bin \ |
| 81 | fip/bl301.bin \ |
| 82 | fip/bl301_zero.bin \ |
| 83 | fip/bl30_new.bin \ |
| 84 | bl30 |
| 85 | |
| 86 | $ sh fip/blx_fix.sh \ |
| 87 | fip/bl2.bin \ |
| 88 | fip/zero_tmp \ |
| 89 | fip/bl2_zero.bin \ |
| 90 | fip/acs.bin \ |
| 91 | fip/bl21_zero.bin \ |
| 92 | fip/bl2_new.bin \ |
| 93 | bl2 |
| 94 | |
| 95 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \ |
| 96 | --output fip/bl30_new.bin.g12a.enc \ |
| 97 | --level v3 |
| 98 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \ |
| 99 | --output fip/bl30_new.bin.enc \ |
| 100 | --level v3 --type bl30 |
| 101 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \ |
| 102 | --output fip/bl31.img.enc \ |
| 103 | --level v3 --type bl31 |
| 104 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \ |
| 105 | --output fip/bl33.bin.enc \ |
| 106 | --level v3 --type bl33 --compress lz4 |
| 107 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \ |
| 108 | --output fip/bl2.n.bin.sig |
| 109 | $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \ |
| 110 | --output fip/u-boot.bin \ |
| 111 | --bl2 fip/bl2.n.bin.sig \ |
| 112 | --bl30 fip/bl30_new.bin.enc \ |
| 113 | --bl31 fip/bl31.img.enc \ |
| 114 | --bl33 fip/bl33.bin.enc \ |
| 115 | --ddrfw1 fip/ddr4_1d.fw \ |
| 116 | --ddrfw2 fip/ddr4_2d.fw \ |
| 117 | --ddrfw3 fip/ddr3_1d.fw \ |
| 118 | --ddrfw4 fip/piei.fw \ |
| 119 | --ddrfw5 fip/lpddr4_1d.fw \ |
| 120 | --ddrfw6 fip/lpddr4_2d.fw \ |
| 121 | --ddrfw7 fip/diag_lpddr4.fw \ |
| 122 | --ddrfw8 fip/aml_ddr.fw \ |
| 123 | --ddrfw9 fip/lpddr3_1d.fw \ |
| 124 | --level v3 |
| 125 | |
| 126 | and then write the image to SD with: |
| 127 | |
| 128 | .. code-block:: bash |
| 129 | |
| 130 | $ DEV=/dev/your_sd_device |
| 131 | $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 |
| 132 | $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444 |