blob: d6a9642ad62c3f19934547712fe46d104d0dcbc5 [file] [log] [blame]
Neil Armstrong84e5e8e2020-06-11 10:53:49 +02001.. SPDX-License-Identifier: GPL-2.0+
2
3U-Boot for Khadas VIM3
4======================
5
6Khadas VIM3 is a single board computer manufactured by Shenzhen Wesion
7Technology Co., Ltd. with the following specifications:
8
9 - Amlogic A311D Arm Cortex-A53 dual-core + Cortex-A73 quad-core SoC
10 - 4GB LPDDR4 SDRAM
11 - Gigabit Ethernet
12 - HDMI 2.1 display
13 - 40-pin GPIO header
14 - 1 x USB 3.0 Host, 1 x USB 2.0 Host
15 - eMMC, microSD
16 - M.2
17 - Infrared receiver
18
19Schematics are available on the manufacturer website.
20
Neil Armstrong29f59e82020-09-21 09:34:15 +020021PCIe Setup
22----------
23The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential
24lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
25an USB3.0 Type A connector and a M.2 Key M slot.
26The PHY driving these differential lines is shared between
27the USB3.0 controller and the PCIe Controller, thus only
28a single controller can use it.
29
30To setup for PCIe, run the following commands from U-Boot:
31
32.. code-block:: none
33
34 i2c dev i2c@5000
35 i2c mw 0x18 0x33 1
36
37Then power-cycle the board.
38
39To set back to USB3.0, run the following commands from U-Boot:
40
41.. code-block:: none
42
43 i2c dev i2c@5000
44 i2c mw 0x18 0x33 0
45
46Then power-cycle the board.
47
Neil Armstrong84e5e8e2020-06-11 10:53:49 +020048U-Boot compilation
49------------------
50
51.. code-block:: bash
52
53 $ export CROSS_COMPILE=aarch64-none-elf-
54 $ make khadas-vim3_defconfig
55 $ make
56
57Image creation
58--------------
59
60Amlogic doesn't provide sources for the firmware and for tools needed
61to create the bootloader image, so it is necessary to obtain them from
62the git tree published by the board vendor:
63
64.. code-block:: bash
65
66 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
67 $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
68 $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
69 $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
70 $ 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
71
72 $ DIR=vim3-u-boot
73 $ git clone --depth 1 \
74 https://github.com/khadas/u-boot.git -b khadas-vims-v2015.01 \
75 $DIR
76
77 $ cd vim3-u-boot
78 $ make kvim3_defconfig
79 $ make
80 $ export UBOOTDIR=$PWD
81
82 Go back to mainline U-Boot source tree then :
83
84.. code-block:: bash
85
86 $ mkdir fip
87
88 $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
89 $ cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/
90 $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
91 $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/
92 $ cp $UBOOTDIR/fip/g12b/bl31.img fip/
93 $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
94 $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
95 $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
96 $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
97 $ cp $UBOOTDIR/fip/g12b/lpddr3_1d.fw fip/
98 $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
99 $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
100 $ cp $UBOOTDIR/fip/g12b/piei.fw fip/
101 $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
102 $ cp u-boot.bin fip/bl33.bin
103
104 $ sh fip/blx_fix.sh \
105 fip/bl30.bin \
106 fip/zero_tmp \
107 fip/bl30_zero.bin \
108 fip/bl301.bin \
109 fip/bl301_zero.bin \
110 fip/bl30_new.bin \
111 bl30
112
113 $ sh fip/blx_fix.sh \
114 fip/bl2.bin \
115 fip/zero_tmp \
116 fip/bl2_zero.bin \
117 fip/acs.bin \
118 fip/bl21_zero.bin \
119 fip/bl2_new.bin \
120 bl2
121
122 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
123 --output fip/bl30_new.bin.g12a.enc \
124 --level v3
125 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
126 --output fip/bl30_new.bin.enc \
127 --level v3 --type bl30
128 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
129 --output fip/bl31.img.enc \
130 --level v3 --type bl31
131 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
132 --output fip/bl33.bin.enc \
133 --level v3 --type bl33 --compress lz4
134 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
135 --output fip/bl2.n.bin.sig
136 $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
137 --output fip/u-boot.bin \
138 --bl2 fip/bl2.n.bin.sig \
139 --bl30 fip/bl30_new.bin.enc \
140 --bl31 fip/bl31.img.enc \
141 --bl33 fip/bl33.bin.enc \
142 --ddrfw1 fip/ddr4_1d.fw \
143 --ddrfw2 fip/ddr4_2d.fw \
144 --ddrfw3 fip/ddr3_1d.fw \
145 --ddrfw4 fip/piei.fw \
146 --ddrfw5 fip/lpddr4_1d.fw \
147 --ddrfw6 fip/lpddr4_2d.fw \
148 --ddrfw7 fip/diag_lpddr4.fw \
149 --ddrfw8 fip/aml_ddr.fw \
150 --ddrfw9 fip/lpddr3_1d.fw \
151 --level v3
152
153and then write the image to SD with:
154
155.. code-block:: bash
156
157 $ DEV=/dev/your_sd_device
158 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
159 $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444