1.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for Amlogic P201 (S905)
4==============================
5
6P201 is a reference board manufactured by Amlogic with the following specifications:
7
8 - Amlogic S905 ARM Cortex-A53 quad-core SoC @ 1.5GHz
9 - ARM Mali 450 GPU
10 - 2GB DDR3 SDRAM
11 - 10/100 Ethernet
12 - HDMI 2.0 4K/60Hz display
13 - 2x USB 2.0 Host
14 - eMMC, microSD
15 - Infrared receiver
16 - SDIO WiFi Module
17 - CVBS + Stereo Audio Jack
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 p201_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 p201 /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 gxb_p201_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/gxb/bl2.bin fip/
66    $ cp $FIPDIR/gxb/acs.bin fip/
67    $ cp $FIPDIR/gxb/bl21.bin fip/
68    $ cp $FIPDIR/gxb/bl30.bin fip/
69    $ cp $FIPDIR/gxb/bl301.bin fip/
70    $ cp $FIPDIR/gxb/bl31.img fip/
71    $ cp u-boot.bin fip/bl33.bin
72    $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/bl1.bin.hardkernel fip/bl1.bin.hardkernel
73    $ chmod +x fip/bl1.bin.hardkernel
74    $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/aml_chksum fip/aml_chksum
75    $ chmod +x fip/aml_chksum
76
77    $ $FIPDIR/blx_fix.sh \
78              fip/bl30.bin \
79              fip/zero_tmp \
80              fip/bl30_zero.bin \
81              fip/bl301.bin \
82              fip/bl301_zero.bin \
83              fip/bl30_new.bin \
84              bl30
85
86    $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
87
88    $ $FIPDIR/blx_fix.sh \
89              fip/bl2_acs.bin \
90              fip/zero_tmp \
91              fip/bl2_zero.bin \
92              fip/bl21.bin \
93              fip/bl21_zero.bin \
94              fip/bl2_new.bin \
95              bl2
96
97    $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin \
98                         --bl31 fip/bl31.img \
99                         --bl33 fip/bl33.bin \
100                         fip/fip.bin
101
102    $ cat fip/bl2_new.bin fip/fip.bin >fip/boot_new.bin
103
104    $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig \
105                                  --input fip/boot_new.bin \
106                                  --output fip/u-boot.bin
107
108Then write U-Boot to SD or eMMC with:
109
110.. code-block:: bash
111
112    $ DEV=/dev/boot_device
113    $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 conv=fsync
114    $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 seek=9 skip=8 count=87 conv=fsync,notrunc
115    $ dd if=/dev/zero of=fip/u-boot.bin.gxbb bs=512 seek=8 count=1 conv=fsync,notrunc
116    $ dd if=bl1.bin.hardkernel of=fip/u-boot.bin.gxbb bs=512 seek=2 skip=2 count=1 conv=fsync,notrunc
117    $ ./aml_chksum fip/u-boot.bin.gxbb
118    $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
119    $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=1 count=440
120