1a13110a9SKlaus GogerIntroduction
2a13110a9SKlaus Goger============
3a13110a9SKlaus Goger
4a13110a9SKlaus GogerThe RK3399-Q7 (Puma) is a system-on-module featuring the Rockchip
5a13110a9SKlaus GogerRK3399 in a Qseven-compatible form-factor.
6a13110a9SKlaus Goger
7a13110a9SKlaus GogerRK3399-Q7 features:
8a13110a9SKlaus Goger	* CPU: ARMv8 64bit Big-Little architecture,
9a13110a9SKlaus Goger		* Big: dual-core Cortex-A72
10a13110a9SKlaus Goger		* Little: quad-core Cortex-A53
11a13110a9SKlaus Goger		* IRAM: 200KB
12a13110a9SKlaus Goger	* DRAM: 4GB-128MB dual-channel
13a13110a9SKlaus Goger	* eMMC: onboard eMMC
14a13110a9SKlaus Goger	* SD/MMC
15a13110a9SKlaus Goger	* GbE (onboard Micrel KSZ9031) Gigabit ethernet PHY
16a13110a9SKlaus Goger	* USB:
17a13110a9SKlaus Goger		* USB3.0 dual role port
18a13110a9SKlaus Goger		* 2x USB3.0 host, 1x USB2.0 host via onboard USB3.0 hub
19a13110a9SKlaus Goger	* Display: HDMI/eDP/MIPI
20a13110a9SKlaus Goger	* Camera: 2x CSI (one on the edge connector, one on the Q7 specified CSI ZIF)
21a13110a9SKlaus Goger	* NOR Flash: onboard SPI NOR
22a13110a9SKlaus Goger	* Companion Controller: onboard additional Cortex-M0 microcontroller
23a13110a9SKlaus Goger		* RTC
24a13110a9SKlaus Goger		* fan controller
25a13110a9SKlaus Goger		* CAN
26a13110a9SKlaus Goger
27a13110a9SKlaus GogerHere is the step-by-step to boot to U-Boot on rk3399.
28a13110a9SKlaus Goger
29a13110a9SKlaus GogerGet the Source and build ATF/Cortex-M0 binaries
30a13110a9SKlaus Goger===============================================
31a13110a9SKlaus Goger
32a13110a9SKlaus Goger  > git clone git://git.theobroma-systems.com/arm-trusted-firmware.git
33a13110a9SKlaus Goger  > git clone git://git.theobroma-systems.com/rk3399-cortex-m0.git
34a13110a9SKlaus Goger
35a13110a9SKlaus GogerCompile the ATF
36a13110a9SKlaus Goger===============
37a13110a9SKlaus Goger
38a13110a9SKlaus Goger  > cd arm-trusted-firmware
39a13110a9SKlaus Goger  > make CROSS_COMPILE=aarch64-linux-gnu- PLAT=rk3399 bl31
404ce8b4d6SKlaus Goger  > cp build/rk3399/release/bl31.bin ../u-boot/bl31-rk3399.bin
41a13110a9SKlaus Goger
42a13110a9SKlaus GogerCompile the M0 firmware
43a13110a9SKlaus Goger=======================
44a13110a9SKlaus Goger
45a13110a9SKlaus Goger  > cd ../rk3399-cortex-m0
46a13110a9SKlaus Goger  > make CROSS_COMPILE=arm-cortex_m0-eabi-
47a13110a9SKlaus Goger  > cp rk3399m0.bin ../u-boot
48a13110a9SKlaus Goger
49a13110a9SKlaus GogerCompile the U-Boot
50a13110a9SKlaus Goger==================
51a13110a9SKlaus Goger
52a13110a9SKlaus Goger  > cd ../u-boot
53a13110a9SKlaus Goger  > make CROSS_COMPILE=aarch64-linux-gnu- puma-rk3399_defconfig all
54a13110a9SKlaus Goger
55a13110a9SKlaus GogerPackage the image
56a13110a9SKlaus Goger=================
57a13110a9SKlaus Goger
58*c9140340SKlaus GogerCreating a SPL image for SD-Card/eMMC
59*c9140340SKlaus Goger  > tools/mkimage -n rk3399 -T rksd -d spl/u-boot-spl.bin spl_mmc.img
60*c9140340SKlaus GogerCreating a SPL image for SPI-NOR
61*c9140340SKlaus Goger  > tools/mkimage -n rk3399 -T rkspi -d spl/u-boot-spl.bin spl_nor.img
62*c9140340SKlaus GogerCreate the FIT image containing U-Boot proper, ATF, M0 Firmware, devicetree
63f8e3b083SPhilipp Tomsich  > make CROSS_COMPILE=aarch64-linux-gnu- u-boot.itb
64a13110a9SKlaus Goger
65a13110a9SKlaus GogerFlash the image
66a13110a9SKlaus Goger===============
67a13110a9SKlaus Goger
68*c9140340SKlaus GogerCopy the SPL to offset 32k for SD/eMMC, offset 0 for NOR-Flash and the FIT
69*c9140340SKlaus Gogerimage to offset 256k card.
70a13110a9SKlaus Goger
71*c9140340SKlaus GogerSD-Card
72*c9140340SKlaus Goger-------
73*c9140340SKlaus Goger
74*c9140340SKlaus Goger  > dd if=spl_mmc.img of=/dev/sdb seek=64
75f8e3b083SPhilipp Tomsich  > dd if=u-boot.itb of=/dev/sdb seek=512
76a13110a9SKlaus Goger
77*c9140340SKlaus GogereMMC
78*c9140340SKlaus Goger----
79*c9140340SKlaus Goger
80*c9140340SKlaus Gogerrkdeveloptool allows to flash the on-board eMMC via the USB OTG interface with
81*c9140340SKlaus Gogerhelp of the Rockchip loader binary.
82*c9140340SKlaus Goger
83*c9140340SKlaus Goger  > git clone https://github.com/rockchip-linux/rkdeveloptool
84*c9140340SKlaus Goger  > cd rkdeveloptool
85*c9140340SKlaus Goger  > autoreconf -i && ./configure && make
86*c9140340SKlaus Goger  > git clone https://github.com/rockchip-linux/rkbin.git
87*c9140340SKlaus Goger  > ./rkdeveloptool db rkbin/rk33/rk3399_loader_v1.08.106.bin
88*c9140340SKlaus Goger  > ./rkdeveloptool wl 64 ../spl_mmc.img
89*c9140340SKlaus Goger  > ./rkdeveloptool wl 512 ../u-boot.itb
90*c9140340SKlaus Goger
91*c9140340SKlaus GogerNOR-Flash
92*c9140340SKlaus Goger---------
93*c9140340SKlaus Goger
94*c9140340SKlaus GogerWriting the SPI NOR Flash requires a running U-Boot. For the sake of simplicity
95*c9140340SKlaus Gogerwe assume you have a SD-Card with a partition containing the required files
96*c9140340SKlaus Gogerready.
97*c9140340SKlaus Goger
98*c9140340SKlaus Goger  > load mmc 1:1 ${kernel_addr_r} spl_nor.img
99*c9140340SKlaus Goger  > sf probe
100*c9140340SKlaus Goger  > sf erase 0 +$filesize
101*c9140340SKlaus Goger  > sf write $kernel_addr_r 0 ${filesize}
102*c9140340SKlaus Goger  > load mmc 1:1 ${kernel_addr_r} u-boot.itb
103*c9140340SKlaus Goger  > sf erase 0x40000 +$filesize
104*c9140340SKlaus Goger  > sf write $kernel_addr_r 0x40000 ${filesize}
105*c9140340SKlaus Goger
106*c9140340SKlaus Goger
107*c9140340SKlaus GogerReboot the system and you should see a U-Boot console on UART0 (115200n8).
108