1.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for Amlogic W400 (S922X)
4===============================
5
6W400 is a reference board manufactured by Amlogic with the following specification:
7
8 - Amlogic S922X ARM Cortex-A53 dual-core + Cortex-A73 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 w400_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 jethub-j100 /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 g12b_w400_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/g12b_w400_v1/firmware/acs.bin fip/
78    $ cp $BRDIR/bootloader/uboot-repo/bl2/bin/g12b/bl2.bin fip/
79    $ cp $BRDIR/bootloader/uboot-repo/bl30/bin/g12b/bl30.bin fip/
80    $ cp $BRDIR/bootloader/uboot-repo/bl31_1.3/bin/g12b/bl31.img fip/
81    $ cp $FIPDIR/g12b/ddr3_1d.fw fip/
82    $ cp $FIPDIR/g12b/ddr4_1d.fw fip/
83    $ cp $FIPDIR/g12b/ddr4_2d.fw fip/
84    $ cp $FIPDIR/g12b/diag_lpddr4.fw fip/
85    $ cp $FIPDIR/g12b/lpddr4_1d.fw fip/
86    $ cp $FIPDIR/g12b/lpddr4_2d.fw fip/
87    $ cp $FIPDIR/g12b/piei.fw fip/
88    $ cp $FIPDIR/g12b/aml_ddr.fw fip/
89    $ cp u-boot.bin fip/bl33.bin
90
91    $ sh fip/blx_fix.sh \
92         fip/bl30.bin \
93         fip/zero_tmp \
94         fip/bl30_zero.bin \
95         fip/bl301.bin \
96         fip/bl301_zero.bin \
97         fip/bl30_new.bin \
98         bl30
99
100    $ sh fip/blx_fix.sh \
101         fip/bl2.bin \
102         fip/zero_tmp \
103         fip/bl2_zero.bin \
104         fip/acs.bin \
105         fip/bl21_zero.bin \
106         fip/bl2_new.bin \
107         bl2
108
109    $ $FIPDIR/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
110                                              --output fip/bl30_new.bin.g12a.enc \
111                                              --level v3
112    $ $FIPDIR/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
113                                             --output fip/bl30_new.bin.enc \
114                                             --level v3 --type bl30
115    $ $FIPDIR/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
116                                             --output fip/bl31.img.enc \
117                                             --level v3 --type bl31
118    $ $FIPDIR/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
119                                             --output fip/bl33.bin.enc \
120                                             --level v3 --type bl33
121    $ $FIPDIR/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
122                                             --output fip/bl2.n.bin.sig
123    $ $FIPDIR/g12b/aml_encrypt_g12b --bootmk \
124                                    --output fip/u-boot.bin \
125                                    --bl2 fip/bl2.n.bin.sig \
126                                    --bl30 fip/bl30_new.bin.enc \
127                                    --bl31 fip/bl31.img.enc \
128                                    --bl33 fip/bl33.bin.enc \
129                                    --ddrfw1 fip/ddr4_1d.fw \
130                                    --ddrfw2 fip/ddr4_2d.fw \
131                                    --ddrfw3 fip/ddr3_1d.fw \
132                                    --ddrfw4 fip/piei.fw \
133                                    --ddrfw5 fip/lpddr4_1d.fw \
134                                    --ddrfw6 fip/lpddr4_2d.fw \
135                                    --ddrfw7 fip/diag_lpddr4.fw \
136                                    --ddrfw8 fip/aml_ddr.fw \
137                                    --level v3
138
139Then write U-Boot to SD or eMMC with:
140
141.. code-block:: bash
142
143    $ DEV=/dev/boot_device
144    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
145    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
146