Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 3 | U-Boot for NanoPi-K2 (S905) |
| 4 | =========================== |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 5 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 6 | NanoPi-K2 is a single board computer manufactured by FriendlyElec with the following |
| 7 | specifications: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 8 | |
| 9 | - Amlogic S905 ARM Cortex-A53 quad-core SoC @ 1.5GHz |
| 10 | - ARM Mali 450 GPU |
| 11 | - 2GB DDR3 SDRAM |
| 12 | - Gigabit Ethernet |
| 13 | - HDMI 2.0 4K/60Hz display |
| 14 | - 40-pin GPIO header |
| 15 | - 4 x USB 2.0 Host, 1 x USB OTG |
| 16 | - eMMC, microSD |
| 17 | - Infrared receiver |
| 18 | |
| 19 | Schematics are available on the manufacturer website. |
| 20 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 21 | U-Boot Compilation |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 22 | ------------------ |
| 23 | |
| 24 | .. code-block:: bash |
| 25 | |
| 26 | $ export CROSS_COMPILE=aarch64-none-elf- |
| 27 | $ make nanopi-k2_defconfig |
| 28 | $ make |
| 29 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 30 | U-Boot Signing with Pre-Built FIP repo |
| 31 | -------------------------------------- |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 32 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 33 | .. code-block:: bash |
| 34 | |
| 35 | $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1 |
| 36 | $ cd amlogic-boot-fip |
| 37 | $ mkdir my-output-dir |
| 38 | $ ./build-fip.sh nanopi-k2 /path/to/u-boot/u-boot.bin my-output-dir |
| 39 | |
| 40 | U-Boot Manual Signing |
| 41 | --------------------- |
Neil Armstrong | 2ea9868 | 2022-03-02 10:42:22 +0100 | [diff] [blame] | 42 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 43 | Amlogic does not provide sources for the firmware and tools needed to create a bootloader |
| 44 | 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] | 45 | |
| 46 | .. code-block:: bash |
| 47 | |
| 48 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 49 | $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 50 | $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 51 | $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 52 | $ 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 |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 53 | $ git clone https://github.com/friendlyarm/u-boot.git -b nanopi-k2-v2015.01 amlogic-u-boot |
| 54 | $ cd amlogic-u-boot |
| 55 | $ sed -i 's/aarch64-linux-gnu-/aarch64-none-elf-/' Makefile |
| 56 | $ sed -i 's/arm-linux-/arm-none-eabi-/' arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile |
| 57 | $ make nanopi-k2_defconfig |
| 58 | $ make |
| 59 | $ export FIPDIR=$PWD/fip |
| 60 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 61 | Go back to the mainline U-Boot source tree then: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 62 | |
| 63 | .. code-block:: bash |
| 64 | |
| 65 | $ mkdir fip |
| 66 | |
| 67 | $ cp $FIPDIR/gxb/bl2.bin fip/ |
| 68 | $ cp $FIPDIR/gxb/acs.bin fip/ |
| 69 | $ cp $FIPDIR/gxb/bl21.bin fip/ |
| 70 | $ cp $FIPDIR/gxb/bl30.bin fip/ |
| 71 | $ cp $FIPDIR/gxb/bl301.bin fip/ |
| 72 | $ cp $FIPDIR/gxb/bl31.img fip/ |
| 73 | $ cp u-boot.bin fip/bl33.bin |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 74 | $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/bl1.bin.hardkernel fip/bl1.bin.hardkernel |
| 75 | $ chmod +x fip/bl1.bin.hardkernel |
| 76 | $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/aml_chksum fip/aml_chksum |
| 77 | $ chmod +x fip/aml_chksum |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 78 | |
| 79 | $ $FIPDIR/blx_fix.sh \ |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 80 | fip/bl30.bin \ |
| 81 | fip/zero_tmp \ |
| 82 | fip/bl30_zero.bin \ |
| 83 | fip/bl301.bin \ |
| 84 | fip/bl301_zero.bin \ |
| 85 | fip/bl30_new.bin \ |
| 86 | bl30 |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 87 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 88 | $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin \ |
| 89 | --bl31 fip/bl31.img \ |
| 90 | --bl33 fip/bl33.bin \ |
| 91 | fip/fip.bin |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 92 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 93 | $ sed -i 's/\x73\x02\x08\x91/\x1F\x20\x03\xD5/' fip/bl2.bin |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 94 | $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0 |
| 95 | |
| 96 | $ $FIPDIR/blx_fix.sh \ |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 97 | fip/bl2_acs.bin \ |
| 98 | fip/zero_tmp \ |
| 99 | fip/bl2_zero.bin \ |
| 100 | fip/bl21.bin \ |
| 101 | fip/bl21_zero.bin \ |
| 102 | fip/bl2_new.bin \ |
| 103 | bl2 |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 104 | |
| 105 | $ cat fip/bl2_new.bin fip/fip.bin > fip/boot_new.bin |
| 106 | |
| 107 | $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig \ |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 108 | --input fip/boot_new.bin |
| 109 | --output fip/u-boot.bin |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 110 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 111 | Then write U-Boot to SD or eMMC with: |
Neil Armstrong | 84e5e8e | 2020-06-11 10:53:49 +0200 | [diff] [blame] | 112 | |
| 113 | .. code-block:: bash |
| 114 | |
Christian Hewitt | 15bece4 | 2023-03-20 11:45:50 +0000 | [diff] [blame] | 115 | $ DEV=/dev/boot_device |
| 116 | $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 conv=fsync |
| 117 | $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 seek=9 skip=8 count=87 conv=fsync,notrunc |
| 118 | $ dd if=/dev/zero of=fip/u-boot.bin.gxbb bs=512 seek=8 count=1 conv=fsync,notrunc |
| 119 | $ dd if=bl1.bin.hardkernel of=fip/u-boot.bin.gxbb bs=512 seek=2 skip=2 count=1 conv=fsync,notrunc |
| 120 | $ ./aml_chksum fip/u-boot.bin.gxbb |
| 121 | $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 |
| 122 | $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=1 count=440 |