1*302987b6SNeil ArmstrongU-Boot for Khadas VIM2
2*302987b6SNeil Armstrong=======================
3*302987b6SNeil Armstrong
4*302987b6SNeil ArmstrongKhadas VIM2 is an Open Source DIY Box manufactured by Shenzhen Wesion
5*302987b6SNeil ArmstrongTechnology Co., Ltd with the following specifications:
6*302987b6SNeil Armstrong
7*302987b6SNeil Armstrong - Amlogic S912 ARM Cortex-A53 octo-core SoC @ 1.5GHz
8*302987b6SNeil Armstrong - ARM Mali T860 GPU
9*302987b6SNeil Armstrong - 2/3GB DDR4 SDRAM
10*302987b6SNeil Armstrong - 10/100/1000 Ethernet
11*302987b6SNeil Armstrong - HDMI 2.0 4K/60Hz display
12*302987b6SNeil Armstrong - 40-pin GPIO header
13*302987b6SNeil Armstrong - 2 x USB 2.0 Host, 1 x USB 2.0 Type-C OTG
14*302987b6SNeil Armstrong - 16GB/32GB/64GB eMMC
15*302987b6SNeil Armstrong - 2MB SPI Flash
16*302987b6SNeil Armstrong - microSD
17*302987b6SNeil Armstrong - SDIO Wifi Module, Bluetooth
18*302987b6SNeil Armstrong - Two channels IR receiver
19*302987b6SNeil Armstrong
20*302987b6SNeil ArmstrongCurrently the u-boot port supports the following devices:
21*302987b6SNeil Armstrong - serial
22*302987b6SNeil Armstrong - eMMC, microSD
23*302987b6SNeil Armstrong - Ethernet
24*302987b6SNeil Armstrong - I2C
25*302987b6SNeil Armstrong - Regulators
26*302987b6SNeil Armstrong - Reset controller
27*302987b6SNeil Armstrong - Clock controller
28*302987b6SNeil Armstrong - USB Host
29*302987b6SNeil Armstrong - ADC
30*302987b6SNeil Armstrong
31*302987b6SNeil ArmstrongU-Boot compilation
32*302987b6SNeil Armstrong==================
33*302987b6SNeil Armstrong
34*302987b6SNeil Armstrong > export ARCH=arm
35*302987b6SNeil Armstrong > export CROSS_COMPILE=aarch64-none-elf-
36*302987b6SNeil Armstrong > make khadas-vim2_defconfig
37*302987b6SNeil Armstrong > make
38*302987b6SNeil Armstrong
39*302987b6SNeil ArmstrongImage creation
40*302987b6SNeil Armstrong==============
41*302987b6SNeil Armstrong
42*302987b6SNeil ArmstrongAmlogic doesn't provide sources for the firmware and for tools needed
43*302987b6SNeil Armstrongto create the bootloader image, so it is necessary to obtain them from
44*302987b6SNeil Armstrongthe git tree published by the board vendor:
45*302987b6SNeil Armstrong
46*302987b6SNeil Armstrong > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
47*302987b6SNeil Armstrong > wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
48*302987b6SNeil Armstrong > tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
49*302987b6SNeil Armstrong > tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
50*302987b6SNeil Armstrong > 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
51*302987b6SNeil Armstrong > git clone https://github.com/khadas/u-boot -b Vim vim-u-boot
52*302987b6SNeil Armstrong > cd vim-u-boot
53*302987b6SNeil Armstrong > make kvim_defconfig
54*302987b6SNeil Armstrong > make
55*302987b6SNeil Armstrong > export FIPDIR=$PWD/fip
56*302987b6SNeil Armstrong
57*302987b6SNeil ArmstrongGo back to mainline U-Boot source tree then :
58*302987b6SNeil Armstrong > mkdir fip
59*302987b6SNeil Armstrong
60*302987b6SNeil Armstrong > cp $FIPDIR/gxl/bl2.bin fip/
61*302987b6SNeil Armstrong > cp $FIPDIR/gxl/acs.bin fip/
62*302987b6SNeil Armstrong > cp $FIPDIR/gxl/bl21.bin fip/
63*302987b6SNeil Armstrong > cp $FIPDIR/gxl/bl30.bin fip/
64*302987b6SNeil Armstrong > cp $FIPDIR/gxl/bl301.bin fip/
65*302987b6SNeil Armstrong > cp $FIPDIR/gxl/bl31.img fip/
66*302987b6SNeil Armstrong > cp u-boot.bin fip/bl33.bin
67*302987b6SNeil Armstrong
68*302987b6SNeil Armstrong > $FIPDIR/blx_fix.sh \
69*302987b6SNeil Armstrong	fip/bl30.bin \
70*302987b6SNeil Armstrong	fip/zero_tmp \
71*302987b6SNeil Armstrong	fip/bl30_zero.bin \
72*302987b6SNeil Armstrong	fip/bl301.bin \
73*302987b6SNeil Armstrong	fip/bl301_zero.bin \
74*302987b6SNeil Armstrong	fip/bl30_new.bin \
75*302987b6SNeil Armstrong	bl30
76*302987b6SNeil Armstrong
77*302987b6SNeil Armstrong > python $FIPDIR/acs_tool.pyc fip/bl2.bin fip/bl2_acs.bin fip/acs.bin 0
78*302987b6SNeil Armstrong
79*302987b6SNeil Armstrong > $FIPDIR/blx_fix.sh \
80*302987b6SNeil Armstrong	fip/bl2_acs.bin \
81*302987b6SNeil Armstrong	fip/zero_tmp \
82*302987b6SNeil Armstrong	fip/bl2_zero.bin \
83*302987b6SNeil Armstrong	fip/bl21.bin \
84*302987b6SNeil Armstrong	fip/bl21_zero.bin \
85*302987b6SNeil Armstrong	fip/bl2_new.bin \
86*302987b6SNeil Armstrong	bl2
87*302987b6SNeil Armstrong
88*302987b6SNeil Armstrong > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl30_new.bin
89*302987b6SNeil Armstrong > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl31.img
90*302987b6SNeil Armstrong > $FIPDIR/gxl/aml_encrypt_gxl --bl3enc --input fip/bl33.bin
91*302987b6SNeil Armstrong > $FIPDIR/gxl/aml_encrypt_gxl --bl2sig --input fip/bl2_new.bin --output fip/bl2.n.bin.sig
92*302987b6SNeil Armstrong > $FIPDIR/gxl/aml_encrypt_gxl --bootmk \
93*302987b6SNeil Armstrong		--output fip/u-boot.bin \
94*302987b6SNeil Armstrong		--bl2 fip/bl2.n.bin.sig \
95*302987b6SNeil Armstrong		--bl30 fip/bl30_new.bin.enc \
96*302987b6SNeil Armstrong		--bl31 fip/bl31.img.enc \
97*302987b6SNeil Armstrong		--bl33 fip/bl33.bin.enc
98*302987b6SNeil Armstrong
99*302987b6SNeil Armstrongand then write the image to SD with:
100*302987b6SNeil Armstrong
101*302987b6SNeil Armstrong > DEV=/dev/your_sd_device
102*302987b6SNeil Armstrong > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
103*302987b6SNeil Armstrong > dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444
104