1.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for Amlogic U200 (S905X2)
4================================
5
6U200 is a reference board manufactured by Amlogic with the following specification:
7
8 - Amlogic S905D2 ARM Cortex-A53 quad-core SoC
9 - 2GB DDR4 SDRAM
10 - 10/100 Ethernet (Internal PHY)
11 - 1x USB 3.0 Host
12 - eMMC
13 - SDcard
14 - Infrared receiver
15 - SDIO WiFi Module
16 - MIPI DSI Connector
17 - Audio HAT Connector
18 - PCI-E M.2 Connector
19
20Schematics are available from Amlogic on demand.
21
22U-Boot Compilation
23------------------
24
25.. code-block:: bash
26
27    $ export CROSS_COMPILE=aarch64-none-elf-
28    $ make u200_defconfig
29    $ make
30
31U-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 u200 /path/to/u-boot/u-boot.bin my-output-dir
40
41U-Boot Manual Signing
42---------------------
43
44Amlogic does not provide sources for the firmware and tools needed to create a bootloader
45image so it is necessary to obtain binaries from sources published by the board vendor:
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/BayLibre/u-boot.git -b buildroot-openlinux-20180418 amlogic-u-boot
55    $ cd amlogic-u-boot
56    $ make g12a_u200_v1_defconfig
57    $ make
58    $ export UBOOTDIR=$PWD
59
60Download the latest Amlogic buildroot package and extract it:
61
62.. code-block:: bash
63
64    $ wget http://openlinux2.amlogic.com:8000/ARM/filesystem/Linux_BSP/buildroot_openlinux_kernel_4.9_fbdev_20180706.tar.gz
65    $ tar xfz buildroot_openlinux_kernel_4.9_fbdev_20180706.tar.gz buildroot_openlinux_kernel_4.9_fbdev_20180706/bootloader
66    $ export BRDIR=$PWD/buildroot_openlinux_kernel_4.9_fbdev_20180706
67    $ export FIPDIR=$BRDIR/bootloader/uboot-repo/fip
68
69Go back to the mainline U-Boot source tree then:
70
71.. code-block:: bash
72
73    $ mkdir fip
74
75    $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
76    $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
77    $ cp $UBOOTDIR/build/board/amlogic/g12a_u200_v1/firmware/acs.bin fip/
78    $ cp $BRDIR/bootloader/uboot-repo/bl2/bin/g12a/bl2.bin fip/
79    $ cp $BRDIR/bootloader/uboot-repo/bl30/bin/g12a/bl30.bin fip/
80    $ cp $BRDIR/bootloader/uboot-repo/bl31_1.3/bin/g12a/bl31.img fip/
81    $ cp $FIPDIR/g12a/ddr3_1d.fw fip/
82    $ cp $FIPDIR/g12a/ddr4_1d.fw fip/
83    $ cp $FIPDIR/g12a/ddr4_2d.fw fip/
84    $ cp $FIPDIR/g12a/diag_lpddr4.fw fip/
85    $ cp $FIPDIR/g12a/lpddr4_1d.fw fip/
86    $ cp $FIPDIR/g12a/lpddr4_2d.fw fip/
87    $ cp $FIPDIR/g12a/piei.fw fip/
88    $ cp u-boot.bin fip/bl33.bin
89
90    $ sh fip/blx_fix.sh \
91         fip/bl30.bin \
92         fip/zero_tmp \
93         fip/bl30_zero.bin \
94         fip/bl301.bin \
95         fip/bl301_zero.bin \
96         fip/bl30_new.bin \
97         bl30
98
99    $ sh fip/blx_fix.sh \
100         fip/bl2.bin \
101         fip/zero_tmp \
102         fip/bl2_zero.bin \
103         fip/acs.bin \
104         fip/bl21_zero.bin \
105         fip/bl2_new.bin \
106         bl2
107
108    $ $FIPDIR/g12a/aml_encrypt_g12a --bl30sig --input fip/bl30_new.bin \
109                                              --output fip/bl30_new.bin.g12a.enc \
110                                              --level v3
111    $ $FIPDIR/g12a/aml_encrypt_g12a --bl3sig --input fip/bl30_new.bin.g12a.enc \
112                                             --output fip/bl30_new.bin.enc \
113                                             --level v3 --type bl30
114    $ $FIPDIR/g12a/aml_encrypt_g12a --bl3sig --input fip/bl31.img \
115                                             --output fip/bl31.img.enc \
116                                             --level v3 --type bl31
117    $ $FIPDIR/g12a/aml_encrypt_g12a --bl3sig --input fip/bl33.bin --compress lz4 \
118                                             --output fip/bl33.bin.enc \
119                                             --level v3 --type bl33
120    $ $FIPDIR/g12a/aml_encrypt_g12a --bl2sig --input fip/bl2_new.bin \
121                                             --output fip/bl2.n.bin.sig
122    $ $FIPDIR/g12a/aml_encrypt_g12a --bootmk \
123                                    --output fip/u-boot.bin \
124                                    --bl2 fip/bl2.n.bin.sig \
125                                    --bl30 fip/bl30_new.bin.enc \
126                                    --bl31 fip/bl31.img.enc \
127                                    --bl33 fip/bl33.bin.enc \
128                                    --ddrfw1 fip/ddr4_1d.fw \
129                                    --ddrfw2 fip/ddr4_2d.fw \
130                                    --ddrfw3 fip/ddr3_1d.fw \
131                                    --ddrfw4 fip/piei.fw \
132                                    --ddrfw5 fip/lpddr4_1d.fw \
133                                    --ddrfw6 fip/lpddr4_2d.fw \
134                                    --ddrfw7 fip/diag_lpddr4.fw \
135                                    --level v3
136
137Then write U-Boot to SD or eMMC with:
138
139.. code-block:: bash
140
141    $ DEV=/dev/boot_device
142    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
143    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
144