Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 3 | U-Boot for Khadas VIM2 (S912) |
| 4 | ============================= |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 5 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 6 | Khadas VIM2 is a Single Board Computer manufactured by Shenzhen Wesion Technology Co. Ltd |
| 7 | with the following specifications: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 8 | |
| 9 | - Amlogic S912 ARM Cortex-A53 octo-core SoC @ 1.5GHz |
| 10 | - ARM Mali T860 GPU |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 11 | - 2GB/3GB DDR4 SDRAM |
| 12 | - 16GB/32GB/64GB eMMC |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 13 | - 10/100/1000 Ethernet |
| 14 | - HDMI 2.0 4K/60Hz display |
| 15 | - 40-pin GPIO header |
| 16 | - 2 x USB 2.0 Host, 1 x USB 2.0 Type-C OTG |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 17 | - 2MB SPI Flash |
| 18 | - microSD |
| 19 | - SDIO Wifi Module, Bluetooth |
| 20 | - Two channels IR receiver |
| 21 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 22 | U-Boot Compilation |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 23 | ------------------ |
| 24 | |
| 25 | .. code-block:: bash |
| 26 | |
| 27 | $ export CROSS_COMPILE=aarch64-none-elf- |
| 28 | $ make khadas-vim2_defconfig |
| 29 | $ make |
| 30 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 31 | U-Boot Signing with Pre-Built FIP repo |
| 32 | -------------------------------------- |
| 33 | |
| 34 | .. code-block:: bash |
| 35 | |
| 36 | $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1 |
| 37 | $ cd amlogic-boot-fip |
| 38 | $ mkdir my-output-dir |
| 39 | $ ./build-fip.sh khadas-vim2 /path/to/u-boot/u-boot.bin my-output-dir |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 40 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 41 | U-Boot Manual Signing |
| 42 | --------------------- |
Neil Armstrong | 2ea9868 | 2022-03-02 10:42:22 +0100 | [diff] [blame] | 43 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 44 | Amlogic does not provide sources for the firmware and tools needed to create a bootloader |
| 45 | image so it is necessary to obtain binaries from sources published by the board vendor: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 46 | |
| 47 | .. code-block:: bash |
| 48 | |
| 49 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 50 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 51 | $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 52 | $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 53 | $ 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 |
| 54 | $ git clone https://github.com/khadas/u-boot -b khadas-vim-v2015.01 vim-u-boot |
| 55 | $ cd vim-u-boot |
| 56 | $ make kvim2_defconfig |
| 57 | $ make |
| 58 | $ export FIPDIR=$PWD/fip |
| 59 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 60 | Go back to the mainline U-Boot source tree then: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 61 | |
| 62 | .. code-block:: bash |
| 63 | |
| 64 | $ mkdir fip |
| 65 | |
| 66 | $ cp $FIPDIR/gxl/bl2.bin fip/ |
| 67 | $ cp $FIPDIR/gxl/acs.bin fip/ |
| 68 | $ cp $FIPDIR/gxl/bl21.bin fip/ |
| 69 | $ cp $FIPDIR/gxl/bl30.bin fip/ |
| 70 | $ cp $FIPDIR/gxl/bl301.bin fip/ |
| 71 | $ cp $FIPDIR/gxl/bl31.img fip/ |
| 72 | $ cp u-boot.bin fip/bl33.bin |
| 73 | |
| 74 | $ $FIPDIR/blx_fix.sh \ |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 75 | fip/bl30.bin \ |
| 76 | fip/zero_tmp \ |
| 77 | fip/bl30_zero.bin \ |
| 78 | fip/bl301.bin \ |
| 79 | fip/bl301_zero.bin \ |
| 80 | fip/bl30_new.bin \ |
| 81 | bl30 |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 82 | |
| 83 | $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0 |
| 84 | |
| 85 | $ $FIPDIR/blx_fix.sh \ |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 86 | fip/bl2_acs.bin \ |
| 87 | fip/zero_tmp \ |
| 88 | fip/bl2_zero.bin \ |
| 89 | fip/bl21.bin \ |
| 90 | fip/bl21_zero.bin \ |
| 91 | fip/bl2_new.bin \ |
| 92 | bl2 |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 93 | |
| 94 | $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin |
| 95 | $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img |
| 96 | $ $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin |
| 97 | $ $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig |
| 98 | $ $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 99 | --output fip/u-boot.bin \ |
| 100 | --bl2 fip/bl2.n.bin.sig \ |
| 101 | --bl30 fip/bl30_new.bin.enc \ |
| 102 | --bl31 fip/bl31.img.enc \ |
| 103 | --bl33 fip/bl33.bin.enc |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 104 | |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 105 | Then write U-Boot to SD or eMMC with: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 106 | |
| 107 | .. code-block:: bash |
| 108 | |
| 109 | $ DEV=/dev/your_sd_device |
| 110 | $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 |
Christian Hewitt | 8634821 | 2023-03-20 11:45:45 +0000 | [diff] [blame] | 111 | $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440 |