1*d54e03b6SJerome BrunetU-Boot for NanoPi-K2
2*d54e03b6SJerome Brunet====================
3*d54e03b6SJerome Brunet
4*d54e03b6SJerome BrunetNanoPi-K2 is a single board computer manufactured by FriendlyElec
5*d54e03b6SJerome Brunetwith the following specifications:
6*d54e03b6SJerome Brunet
7*d54e03b6SJerome Brunet - Amlogic S905 ARM Cortex-A53 quad-core SoC @ 1.5GHz
8*d54e03b6SJerome Brunet - ARM Mali 450 GPU
9*d54e03b6SJerome Brunet - 2GB DDR3 SDRAM
10*d54e03b6SJerome Brunet - Gigabit Ethernet
11*d54e03b6SJerome Brunet - HDMI 2.0 4K/60Hz display
12*d54e03b6SJerome Brunet - 40-pin GPIO header
13*d54e03b6SJerome Brunet - 4 x USB 2.0 Host, 1 x USB OTG
14*d54e03b6SJerome Brunet - eMMC, microSD
15*d54e03b6SJerome Brunet - Infrared receiver
16*d54e03b6SJerome Brunet
17*d54e03b6SJerome BrunetSchematics are available on the manufacturer website.
18*d54e03b6SJerome Brunet
19*d54e03b6SJerome BrunetCurrently the u-boot port supports the following devices:
20*d54e03b6SJerome Brunet - serial
21*d54e03b6SJerome Brunet - eMMC, microSD
22*d54e03b6SJerome Brunet - Ethernet
23*d54e03b6SJerome Brunet
24*d54e03b6SJerome Brunetu-boot compilation
25*d54e03b6SJerome Brunet==================
26*d54e03b6SJerome Brunet
27*d54e03b6SJerome Brunet > export ARCH=arm
28*d54e03b6SJerome Brunet > export CROSS_COMPILE=aarch64-none-elf-
29*d54e03b6SJerome Brunet > make nanopi-k2_defconfig
30*d54e03b6SJerome Brunet > make
31*d54e03b6SJerome Brunet
32*d54e03b6SJerome BrunetImage creation
33*d54e03b6SJerome Brunet==============
34*d54e03b6SJerome Brunet
35*d54e03b6SJerome BrunetAmlogic doesn't provide sources for the firmware and for tools needed
36*d54e03b6SJerome Brunetto create the bootloader image, so it is necessary to obtain them from
37*d54e03b6SJerome Brunetthe git tree published by the board vendor:
38*d54e03b6SJerome Brunet
39*d54e03b6SJerome Brunet > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
40*d54e03b6SJerome Brunet > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
41*d54e03b6SJerome Brunet > tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
42*d54e03b6SJerome Brunet > tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
43*d54e03b6SJerome Brunet > 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
44*d54e03b6SJerome Brunet > git clone https://github.com/BayLibre/u-boot.git -b libretech-cc amlogic-u-boot
45*d54e03b6SJerome Brunet > git clone https://github.com/friendlyarm/u-boot.git -b nanopi-k2-v2015.01 amlogic-u-boot
46*d54e03b6SJerome Brunet > cd amlogic-u-boot
47*d54e03b6SJerome Brunet > sed -i 's/aarch64-linux-gnu-/aarch64-none-elf-/' Makefile
48*d54e03b6SJerome Brunet > sed -i 's/arm-linux-/arm-none-eabi-/' arch/arm/cpu/armv8/gxb/firmware/scp_task/Makefile
49*d54e03b6SJerome Brunet > make nanopi-k2_defconfig
50*d54e03b6SJerome Brunet > make
51*d54e03b6SJerome Brunet > export FIPDIR=$PWD/fip
52*d54e03b6SJerome Brunet
53*d54e03b6SJerome BrunetGo back to mainline U-Boot source tree then :
54*d54e03b6SJerome Brunet > mkdir fip
55*d54e03b6SJerome Brunet
56*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/bl2.bin fip/
57*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/acs.bin fip/
58*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/bl21.bin fip/
59*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/bl30.bin fip/
60*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/bl301.bin fip/
61*d54e03b6SJerome Brunet > cp $FIPDIR/gxb/bl31.img fip/
62*d54e03b6SJerome Brunet > cp u-boot.bin fip/bl33.bin
63*d54e03b6SJerome Brunet
64*d54e03b6SJerome Brunet > $FIPDIR/blx_fix.sh \
65*d54e03b6SJerome Brunet	fip/bl30.bin \
66*d54e03b6SJerome Brunet	fip/zero_tmp \
67*d54e03b6SJerome Brunet	fip/bl30_zero.bin \
68*d54e03b6SJerome Brunet	fip/bl301.bin \
69*d54e03b6SJerome Brunet	fip/bl301_zero.bin \
70*d54e03b6SJerome Brunet	fip/bl30_new.bin \
71*d54e03b6SJerome Brunet	bl30
72*d54e03b6SJerome Brunet
73*d54e03b6SJerome Brunet > $FIPDIR/fip_create \
74*d54e03b6SJerome Brunet	 --bl30 fip/bl30_new.bin \
75*d54e03b6SJerome Brunet	 --bl31 fip/bl31.img \
76*d54e03b6SJerome Brunet	 --bl33 fip/bl33.bin \
77*d54e03b6SJerome Brunet	 fip/fip.bin
78*d54e03b6SJerome Brunet
79*d54e03b6SJerome Brunet > python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
80*d54e03b6SJerome Brunet
81*d54e03b6SJerome Brunet > $FIPDIR/blx_fix.sh \
82*d54e03b6SJerome Brunet	fip/bl2_acs.bin \
83*d54e03b6SJerome Brunet	fip/zero_tmp \
84*d54e03b6SJerome Brunet	fip/bl2_zero.bin \
85*d54e03b6SJerome Brunet	fip/bl21.bin \
86*d54e03b6SJerome Brunet	fip/bl21_zero.bin \
87*d54e03b6SJerome Brunet	fip/bl2_new.bin \
88*d54e03b6SJerome Brunet	bl2
89*d54e03b6SJerome Brunet
90*d54e03b6SJerome Brunet > cat fip/bl2_new.bin fip/fip.bin > fip/boot_new.bin
91*d54e03b6SJerome Brunet
92*d54e03b6SJerome Brunet > $FIPDIR/gxb/aml_encrypt_gxb --bootsig \
93*d54e03b6SJerome Brunet		--input fip/boot_new.bin
94*d54e03b6SJerome Brunet		--output fip/u-boot.bin
95*d54e03b6SJerome Brunet
96*d54e03b6SJerome Brunetand then write the image to SD with:
97*d54e03b6SJerome Brunet
98*d54e03b6SJerome Brunet > DEV=/dev/your_sd_device
99*d54e03b6SJerome Brunet > dd if=fip/u-boot.bin of=$DEV conv=fsync,notrunc bs=512 seek=1
100