1.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for Amlogic S400 (A113X)
4===============================
5
6S400 is a reference board manufactured by Amlogic with the following specifications:
7
8 - Amlogic A113X ARM Cortex-A53 quad-core SoC @ 1.2GHz
9 - 1GB DDR4 SDRAM
10 - 10/100 Ethernet
11 - 2x USB 2.0 Host
12 - eMMC
13 - Infrared receiver
14 - SDIO WiFi Module
15 - MIPI DSI Connector
16 - Audio HAT Connector
17 - PCI-E M.2 Connectors
18
19Schematics are available from Amlogic on demand.
20
21U-Boot Compilation
22------------------
23
24.. code-block:: bash
25
26    $ export CROSS_COMPILE=aarch64-none-elf-
27    $ make s400_defconfig
28    $ make
29
30U-Boot Signing with Pre-Built FIP repo
31--------------------------------------
32
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 s400 /path/to/u-boot/u-boot.bin my-output-dir
39
40U-Boot Manual Signing
41---------------------
42
43Amlogic does not provide sources for the firmware and tools needed to create a bootloader
44image but sources have been shared by Linux development contractor, Baylibre:
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
53    $ git clone https://github.com/BayLibre/u-boot.git -b n-amlogic-openlinux-20170606 amlogic-u-boot
54    $ cd amlogic-u-boot
55    $ make axg_s400_v1_defconfig
56    $ make
57    $ export FIPDIR=$PWD/fip
58
59Go back to mainline U-boot source tree then :
60
61.. code-block:: bash
62
63    $ mkdir fip
64
65    $ cp $FIPDIR/axg/bl2.bin fip/
66    $ cp $FIPDIR/axg/acs.bin fip/
67    $ cp $FIPDIR/axg/bl21.bin fip/
68    $ cp $FIPDIR/axg/bl30.bin fip/
69    $ cp $FIPDIR/axg/bl301.bin fip/
70    $ cp $FIPDIR/axg/bl31.img fip/
71    $ cp u-boot.bin fip/bl33.bin
72
73    $ $FIPDIR/blx_fix.sh \
74              fip/bl30.bin \
75              fip/zero_tmp \
76              fip/bl30_zero.bin \
77              fip/bl301.bin \
78              fip/bl301_zero.bin \
79              fip/bl30_new.bin \
80              bl30
81
82    $ $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
83
84    $ $FIPDIR/blx_fix.sh \
85              fip/bl2_acs.bin \
86              fip/zero_tmp \
87              fip/bl2_zero.bin \
88              fip/bl21.bin \
89              fip/bl21_zero.bin \
90              fip/bl2_new.bin \
91              bl2
92
93    $ $FIPDIR/axg/aml_encrypt_axg --bl3sig --input fip/bl30_new.bin \
94                                           --output fip/bl30_new.bin.enc \
95                                           --level v3 --type bl30
96    $ $FIPDIR/axg/aml_encrypt_axg --bl3sig --input fip/bl31.img \
97                                           --output fip/bl31.img.enc \
98                                           --level v3 --type bl31
99    $ $FIPDIR/axg/aml_encrypt_axg --bl3sig --input fip/bl33.bin --compress lz4 \
100                                           --output fip/bl33.bin.enc \
101                                           --level v3 --type bl33
102    $ $FIPDIR/axg/aml_encrypt_axg --bl2sig --input fip/bl2_new.bin \
103                                           --output fip/bl2.n.bin.sig
104    $ $FIPDIR/axg/aml_encrypt_axg --bootmk \
105                                  --output fip/u-boot.bin \
106                                  --bl2 fip/bl2.n.bin.sig \
107                                  --bl30 fip/bl30_new.bin.enc \
108                                  --bl31 fip/bl31.img.enc \
109                                  --bl33 fip/bl33.bin.enc --level v3
110
111Then write U-Boot to SD or eMMC with:
112
113.. code-block:: bash
114
115    $ DEV=/dev/boot_device
116    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
117    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
118