1.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for ODROID-N2/N2+ (S922X)
4================================
5
6ODROID-N2 and ODROID-N2+ are a Single Board Computers manufactured by Hardkernel with the
7following specifications:
8
9 - Amlogic S922X ARM Cortex-A53 dual-core + Cortex-A73 quad-core SoC
10 - 4GB DDR4 SDRAM
11 - Gigabit Ethernet
12 - HDMI 2.1 4K/60Hz display
13 - 40-pin GPIO header
14 - 4 x USB 3.0 Host, 1 x USB OTG
15 - eMMC, microSD
16 - Infrared receiver
17
18ODROID-N2+ uses Rev-C silicon allowing higher CPU opp-points. U-Boot contains logic to
19read the model detail from SARADC and select the correct device-tree file if FDTDIR is
20used instead of an FDT reference to a specfic device-tree.
21
22Schematics are available on the manufacturer website: https://wiki.odroid.com
23
24U-Boot Compilation
25------------------
26
27.. code-block:: bash
28
29    $ export CROSS_COMPILE=aarch64-none-elf-
30    $ make odroid-n2_defconfig
31    $ make
32
33U-Boot Signing with Pre-Built FIP repo
34--------------------------------------
35
36.. code-block:: bash
37
38    $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
39    $ cd amlogic-boot-fip
40    $ mkdir my-output-dir
41    $ ./build-fip.sh odroid-n2 /path/to/u-boot/u-boot.bin my-output-dir
42
43U-Boot Manual Signing
44---------------------
45
46Amlogic does not provide sources for the firmware and tools needed to create a bootloader
47image so it is necessary to obtain binaries from sources published by the board vendor:
48
49.. code-block:: bash
50
51    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
52    $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
53    $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
54    $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
55    $ 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
56
57    $ DIR=odroid-n2
58    $ git clone --depth 1 https://github.com/hardkernel/u-boot.git -b odroidn2-v2015.01 $DIR
59
60    $ cd odroid-n2
61    $ make odroidn2_defconfig
62    $ make
63    $ export UBOOTDIR=$PWD
64
65Go back to the mainline U-Boot source tree then:
66
67.. code-block:: bash
68
69    $ mkdir fip
70
71    $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
72    $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
73    $ cp $UBOOTDIR/build/board/hardkernel/odroidn2/firmware/acs.bin fip/
74    $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
75    $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/
76    $ cp $UBOOTDIR/fip/g12b/bl31.img fip/
77    $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
78    $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
79    $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
80    $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
81    $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
82    $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
83    $ cp $UBOOTDIR/fip/g12b/piei.fw fip/
84    $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
85    $ cp u-boot.bin fip/bl33.bin
86
87    $ sh fip/blx_fix.sh \
88         fip/bl30.bin \
89         fip/zero_tmp \
90         fip/bl30_zero.bin \
91         fip/bl301.bin \
92         fip/bl301_zero.bin \
93         fip/bl30_new.bin \
94         bl30
95
96    $ sh fip/blx_fix.sh \
97         fip/bl2.bin \
98         fip/zero_tmp \
99         fip/bl2_zero.bin \
100         fip/acs.bin \
101         fip/bl21_zero.bin \
102         fip/bl2_new.bin \
103         bl2
104
105    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
106                                          --output fip/bl30_new.bin.g12a.enc \
107                                          --level v3
108    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
109                                          --output fip/bl30_new.bin.enc \
110                                          --level v3 --type bl30
111    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
112                                          --output fip/bl31.img.enc \
113                                          --level v3 --type bl31
114    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
115                                          --output fip/bl33.bin.enc \
116                                          --level v3 --type bl33 --compress lz4
117    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
118                                          --output fip/bl2.n.bin.sig
119    $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
120                                          --output fip/u-boot.bin \
121                                          --bl2 fip/bl2.n.bin.sig \
122                                          --bl30 fip/bl30_new.bin.enc \
123                                          --bl31 fip/bl31.img.enc \
124                                          --bl33 fip/bl33.bin.enc \
125                                          --ddrfw1 fip/ddr4_1d.fw \
126                                          --ddrfw2 fip/ddr4_2d.fw \
127                                          --ddrfw3 fip/ddr3_1d.fw \
128                                          --ddrfw4 fip/piei.fw \
129                                          --ddrfw5 fip/lpddr4_1d.fw \
130                                          --ddrfw6 fip/lpddr4_2d.fw \
131                                          --ddrfw7 fip/diag_lpddr4.fw \
132                                          --ddrfw8 fip/aml_ddr.fw \
133                                          --level v3
134
135Then write U-Boot to SD or eMMC with:
136
137.. code-block:: bash
138
139    $ DEV=/dev/boot_device
140    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
141    $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440
142