Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 1 | U-Boot for LibreTech CC |
| 2 | ======================= |
| 3 | |
| 4 | LibreTech CC is a single board computer manufactured by Libre Technology |
| 5 | with the following specifications: |
| 6 | |
Neil Armstrong | c95848c | 2018-06-27 17:19:02 +0200 | [diff] [blame] | 7 | - Amlogic S905X ARM Cortex-A53 quad-core SoC @ 1.5GHz |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 8 | - ARM Mali 450 GPU |
| 9 | - 2GB DDR3 SDRAM |
Neil Armstrong | c95848c | 2018-06-27 17:19:02 +0200 | [diff] [blame] | 10 | - 10/100 Ethernet |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 11 | - HDMI 2.0 4K/60Hz display |
| 12 | - 40-pin GPIO header |
Neil Armstrong | c95848c | 2018-06-27 17:19:02 +0200 | [diff] [blame] | 13 | - 4 x USB 2.0 Host |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 14 | - eMMC, microSD |
| 15 | - Infrared receiver |
| 16 | |
| 17 | Schematics are available on the manufacturer website. |
| 18 | |
| 19 | Currently the U-Boot port supports the following devices: |
| 20 | - serial |
| 21 | - eMMC, microSD |
| 22 | - Ethernet |
Neil Armstrong | c95848c | 2018-06-27 17:19:02 +0200 | [diff] [blame] | 23 | - I2C |
| 24 | - Regulators |
| 25 | - Reset controller |
| 26 | - Clock controller |
| 27 | - USB Host |
| 28 | - ADC |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 29 | |
| 30 | U-Boot compilation |
| 31 | ================== |
| 32 | |
| 33 | > export ARCH=arm |
| 34 | > export CROSS_COMPILE=aarch64-none-elf- |
| 35 | > make libretech-cc_defconfig |
| 36 | > make |
| 37 | |
| 38 | Image creation |
| 39 | ============== |
| 40 | |
Daniel Drake | 4ae9747 | 2019-08-06 16:10:42 +0800 | [diff] [blame^] | 41 | To boot the system, u-boot must be combined with several earlier stage |
| 42 | bootloaders: |
| 43 | |
| 44 | * bl2.bin: vendor-provided binary blob |
| 45 | * bl21.bin: built from vendor u-boot source |
| 46 | * bl30.bin: vendor-provided binary blob |
| 47 | * bl301.bin: built from vendor u-boot source |
| 48 | * bl31.bin: vendor-provided binary blob |
| 49 | * acs.bin: built from vendor u-boot source |
| 50 | |
| 51 | These binaries and the tools required below have been collected and prebuilt |
| 52 | for convenience at <https://github.com/BayLibre/u-boot/releases/> |
| 53 | |
| 54 | Download and extract the libretech-cc release from there, and set FIPDIR to |
| 55 | point to the `fip` subdirectory. |
| 56 | |
| 57 | > export FIPDIR=/path/to/extracted/fip |
| 58 | |
| 59 | Alternatively, you can obtain the original vendor u-boot tree which |
| 60 | contains the required blobs and sources, and build yourself. |
| 61 | Note that old compilers are required for this to build. The compilers here |
| 62 | are suggested by Amlogic, and they are 32-bit x86 binaries. |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 63 | |
| 64 | > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 65 | > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 66 | > tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz |
| 67 | > tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz |
| 68 | > 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 |
| 69 | > git clone https://github.com/BayLibre/u-boot.git -b libretech-cc amlogic-u-boot |
| 70 | > cd amlogic-u-boot |
| 71 | > make libretech_cc_defconfig |
| 72 | > make |
| 73 | > export FIPDIR=$PWD/fip |
| 74 | |
Daniel Drake | 4ae9747 | 2019-08-06 16:10:42 +0800 | [diff] [blame^] | 75 | Once you have the binaries available (either through the prebuilt download, |
| 76 | or having built the vendor u-boot yourself), you can then proceed to glue |
| 77 | everything together. Go back to mainline U-Boot source tree then : |
| 78 | |
Neil Armstrong | 96e7b5a | 2017-11-27 10:16:19 +0100 | [diff] [blame] | 79 | > mkdir fip |
| 80 | |
| 81 | > cp $FIPDIR/gxl/bl2.bin fip/ |
| 82 | > cp $FIPDIR/gxl/acs.bin fip/ |
| 83 | > cp $FIPDIR/gxl/bl21.bin fip/ |
| 84 | > cp $FIPDIR/gxl/bl30.bin fip/ |
| 85 | > cp $FIPDIR/gxl/bl301.bin fip/ |
| 86 | > cp $FIPDIR/gxl/bl31.img fip/ |
| 87 | > cp u-boot.bin fip/bl33.bin |
| 88 | |
| 89 | > $FIPDIR/blx_fix.sh \ |
| 90 | fip/bl30.bin \ |
| 91 | fip/zero_tmp \ |
| 92 | fip/bl30_zero.bin \ |
| 93 | fip/bl301.bin \ |
| 94 | fip/bl301_zero.bin \ |
| 95 | fip/bl30_new.bin \ |
| 96 | bl30 |
| 97 | |
| 98 | > $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0 |
| 99 | |
| 100 | > $FIPDIR/blx_fix.sh \ |
| 101 | fip/bl2_acs.bin \ |
| 102 | fip/zero_tmp \ |
| 103 | fip/bl2_zero.bin \ |
| 104 | fip/bl21.bin \ |
| 105 | fip/bl21_zero.bin \ |
| 106 | fip/bl2_new.bin \ |
| 107 | bl2 |
| 108 | |
| 109 | > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin |
| 110 | > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img |
| 111 | > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin |
| 112 | > $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig |
| 113 | > $FIPDIR/gxl/aml_encrypt_gxl --bootmk \ |
| 114 | --output fip/u-boot.bin \ |
| 115 | --bl2 fip/bl2.n.bin.sig \ |
| 116 | --bl30 fip/bl30_new.bin.enc \ |
| 117 | --bl31 fip/bl31.img.enc \ |
| 118 | --bl33 fip/bl33.bin.enc |
| 119 | |
| 120 | and then write the image to SD with: |
| 121 | |
| 122 | > DEV=/dev/your_sd_device |
| 123 | > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1 |
| 124 | > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444 |
Daniel Drake | 4ae9747 | 2019-08-06 16:10:42 +0800 | [diff] [blame^] | 125 | |
| 126 | Note that Amlogic provides aml_encrypt_gxl as a 32-bit x86 binary with no |
| 127 | source code. Should you prefer to avoid that, there are open source reverse |
| 128 | engineered versions available: |
| 129 | |
| 130 | 1. gxlimg <https://github.com/repk/gxlimg>, which comes with a handy |
| 131 | Makefile that automates the whole process. |
| 132 | 2. meson-tools <https://github.com/afaerber/meson-tools> |
| 133 | |
| 134 | However, these community-developed alternatives are not endorsed by or |
| 135 | supported by Amlogic. |