blob: 53a0a41c8897f6b1d6943b8faf7088b60dc67b9a [file] [log] [blame]
Neil Armstrong84e5e8e2020-06-11 10:53:49 +02001.. SPDX-License-Identifier: GPL-2.0+
2
Christian Hewitt15bece42023-03-20 11:45:50 +00003U-Boot for NanoPi-K2 (S905)
4===========================
Neil Armstrong84e5e8e2020-06-11 10:53:49 +02005
Christian Hewitt15bece42023-03-20 11:45:50 +00006NanoPi-K2 is a single board computer manufactured by FriendlyElec with the following
7specifications:
Neil Armstrong84e5e8e2020-06-11 10:53:49 +02008
9 - Amlogic S905 ARM Cortex-A53 quad-core SoC @ 1.5GHz
10 - ARM Mali 450 GPU
11 - 2GB DDR3 SDRAM
12 - Gigabit Ethernet
13 - HDMI 2.0 4K/60Hz display
14 - 40-pin GPIO header
15 - 4 x USB 2.0 Host, 1 x USB OTG
16 - eMMC, microSD
17 - Infrared receiver
18
19Schematics are available on the manufacturer website.
20
Christian Hewitt15bece42023-03-20 11:45:50 +000021U-Boot Compilation
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020022------------------
23
24.. code-block:: bash
25
26 $ export CROSS_COMPILE=aarch64-none-elf-
27 $ make nanopi-k2_defconfig
28 $ make
29
Christian Hewitt15bece42023-03-20 11:45:50 +000030U-Boot Signing with Pre-Built FIP repo
31--------------------------------------
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020032
Christian Hewitt15bece42023-03-20 11:45:50 +000033.. 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 nanopi-k2 /path/to/u-boot/u-boot.bin my-output-dir
39
40U-Boot Manual Signing
41---------------------
Neil Armstrong2ea98682022-03-02 10:42:22 +010042
Christian Hewitt15bece42023-03-20 11:45:50 +000043Amlogic does not provide sources for the firmware and tools needed to create a bootloader
44image so it is necessary to obtain binaries from sources published by the board vendor:
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020045
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
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020053 $ git clone https://github.com/friendlyarm/u-boot.git -b nanopi-k2-v2015.01 amlogic-u-boot
54 $ cd amlogic-u-boot
55 $ sed -i 's/aarch64-linux-gnu-/aarch64-none-elf-/' Makefile
56 $ sed -i 's/arm-linux-/arm-none-eabi-/' arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile
57 $ make nanopi-k2_defconfig
58 $ make
59 $ export FIPDIR=$PWD/fip
60
Christian Hewitt15bece42023-03-20 11:45:50 +000061Go back to the mainline U-Boot source tree then:
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020062
63.. code-block:: bash
64
65 $ mkdir fip
66
67 $ cp $FIPDIR/gxb/bl2.bin fip/
68 $ cp $FIPDIR/gxb/acs.bin fip/
69 $ cp $FIPDIR/gxb/bl21.bin fip/
70 $ cp $FIPDIR/gxb/bl30.bin fip/
71 $ cp $FIPDIR/gxb/bl301.bin fip/
72 $ cp $FIPDIR/gxb/bl31.img fip/
73 $ cp u-boot.bin fip/bl33.bin
Christian Hewitt15bece42023-03-20 11:45:50 +000074 $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/bl1.bin.hardkernel fip/bl1.bin.hardkernel
75 $ chmod +x fip/bl1.bin.hardkernel
76 $ wget https://github.com/LibreELEC/amlogic-boot-fip/raw/master/nanopi-k2/aml_chksum fip/aml_chksum
77 $ chmod +x fip/aml_chksum
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020078
79 $ $FIPDIR/blx_fix.sh \
Christian Hewitt15bece42023-03-20 11:45:50 +000080 fip/bl30.bin \
81 fip/zero_tmp \
82 fip/bl30_zero.bin \
83 fip/bl301.bin \
84 fip/bl301_zero.bin \
85 fip/bl30_new.bin \
86 bl30
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020087
Christian Hewitt15bece42023-03-20 11:45:50 +000088 $ $FIPDIR/fip_create --bl30 fip/bl30_new.bin \
89 --bl31 fip/bl31.img \
90 --bl33 fip/bl33.bin \
91 fip/fip.bin
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020092
Christian Hewitt15bece42023-03-20 11:45:50 +000093 $ sed -i 's/\x73\x02\x08\x91/\x1F\x20\x03\xD5/' fip/bl2.bin
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020094 $ python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
95
96 $ $FIPDIR/blx_fix.sh \
Christian Hewitt15bece42023-03-20 11:45:50 +000097 fip/bl2_acs.bin \
98 fip/zero_tmp \
99 fip/bl2_zero.bin \
100 fip/bl21.bin \
101 fip/bl21_zero.bin \
102 fip/bl2_new.bin \
103 bl2
Neil Armstrong84e5e8e2020-06-11 10:53:49 +0200104
105 $ cat fip/bl2_new.bin fip/fip.bin > fip/boot_new.bin
106
107 $ $FIPDIR/gxb/aml_encrypt_gxb --bootsig \
Christian Hewitt15bece42023-03-20 11:45:50 +0000108 --input fip/boot_new.bin
109 --output fip/u-boot.bin
Neil Armstrong84e5e8e2020-06-11 10:53:49 +0200110
Christian Hewitt15bece42023-03-20 11:45:50 +0000111Then write U-Boot to SD or eMMC with:
Neil Armstrong84e5e8e2020-06-11 10:53:49 +0200112
113.. code-block:: bash
114
Christian Hewitt15bece42023-03-20 11:45:50 +0000115 $ DEV=/dev/boot_device
116 $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 conv=fsync
117 $ dd if=fip/u-boot.bin of=fip/u-boot.bin.gxbb bs=512 seek=9 skip=8 count=87 conv=fsync,notrunc
118 $ dd if=/dev/zero of=fip/u-boot.bin.gxbb bs=512 seek=8 count=1 conv=fsync,notrunc
119 $ dd if=bl1.bin.hardkernel of=fip/u-boot.bin.gxbb bs=512 seek=2 skip=2 count=1 conv=fsync,notrunc
120 $ ./aml_chksum fip/u-boot.bin.gxbb
121 $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
122 $ dd if=fip/u-boot.gxbb of=$DEV conv=fsync,notrunc bs=1 count=440