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