xref: /openbmc/u-boot/doc/README.rockchip (revision adfb2bfe50bba29e59fd04a81f0a9bbebdd203ce)
1*adfb2bfeSSimon Glass#
2*adfb2bfeSSimon Glass# Copyright (C) 2015 Google. Inc
3*adfb2bfeSSimon Glass# Written by Simon Glass <sjg@chromium.org>
4*adfb2bfeSSimon Glass#
5*adfb2bfeSSimon Glass# SPDX-License-Identifier:	GPL-2.0+
6*adfb2bfeSSimon Glass#
7*adfb2bfeSSimon Glass
8*adfb2bfeSSimon GlassU-Boot on Rockchip
9*adfb2bfeSSimon Glass==================
10*adfb2bfeSSimon Glass
11*adfb2bfeSSimon GlassThere are several repositories available with versions of U-Boot that support
12*adfb2bfeSSimon Glassmany Rockchip devices [1] [2].
13*adfb2bfeSSimon Glass
14*adfb2bfeSSimon GlassThe current mainline support is experimental only and is not useful for
15*adfb2bfeSSimon Glassanything. It should provide a base on which to build.
16*adfb2bfeSSimon Glass
17*adfb2bfeSSimon GlassSo far only support for the RK3288 is provided.
18*adfb2bfeSSimon Glass
19*adfb2bfeSSimon Glass
20*adfb2bfeSSimon GlassPrerequisites
21*adfb2bfeSSimon Glass=============
22*adfb2bfeSSimon Glass
23*adfb2bfeSSimon GlassYou will need:
24*adfb2bfeSSimon Glass
25*adfb2bfeSSimon Glass   - Firefly RK3288 baord
26*adfb2bfeSSimon Glass   - Power connection to 5V using the supplied micro-USB power cable
27*adfb2bfeSSimon Glass   - Separate USB serial cable attached to your computer and the Firefly
28*adfb2bfeSSimon Glass        (connect to the micro-USB connector below the logo)
29*adfb2bfeSSimon Glass   - rkflashtool [3]
30*adfb2bfeSSimon Glass   - openssl (sudo apt-get install openssl)
31*adfb2bfeSSimon Glass   - Serial UART connection [4]
32*adfb2bfeSSimon Glass   - Suitable ARM cross compiler, e.g.:
33*adfb2bfeSSimon Glass        sudo apt-get install gcc-4.7-arm-linux-gnueabi
34*adfb2bfeSSimon Glass
35*adfb2bfeSSimon Glass
36*adfb2bfeSSimon GlassBuilding
37*adfb2bfeSSimon Glass========
38*adfb2bfeSSimon Glass
39*adfb2bfeSSimon GlassAt present three RK3288 boards are supported:
40*adfb2bfeSSimon Glass
41*adfb2bfeSSimon Glass   - Firefly RK3288 - use firefly-rk3288 configuration
42*adfb2bfeSSimon Glass   - Radxa Rock Pro - also uses firefly-rk3288 configuration
43*adfb2bfeSSimon Glass   - Haier Chromebook - use chromebook_jerry configuration
44*adfb2bfeSSimon Glass
45*adfb2bfeSSimon GlassFor example:
46*adfb2bfeSSimon Glass
47*adfb2bfeSSimon Glass   CROSS_COMPILE=arm-linux-gnueabi- make O=firefly firefly-rk3288_defconfig all
48*adfb2bfeSSimon Glass
49*adfb2bfeSSimon Glass(or you can use another cross compiler if you prefer)
50*adfb2bfeSSimon Glass
51*adfb2bfeSSimon GlassNote that the Radxa Rock Pro uses the Firefly configuration for now as
52*adfb2bfeSSimon Glassdevice tree files are not yet available for the Rock Pro. Clearly the two
53*adfb2bfeSSimon Glasshave hardware differences, so this approach will break down as more drivers
54*adfb2bfeSSimon Glassare added.
55*adfb2bfeSSimon Glass
56*adfb2bfeSSimon Glass
57*adfb2bfeSSimon GlassWriting to the board with USB
58*adfb2bfeSSimon Glass=============================
59*adfb2bfeSSimon Glass
60*adfb2bfeSSimon GlassFor USB to work you must get your board into ROM boot mode, either by erasing
61*adfb2bfeSSimon Glassyour MMC or (perhaps) holding the recovery button when you boot the board.
62*adfb2bfeSSimon GlassTo erase your MMC, you can boot into Linux and type (as root)
63*adfb2bfeSSimon Glass
64*adfb2bfeSSimon Glass   dd if=/dev/zero of=/dev/mmcblk0 bs=1M
65*adfb2bfeSSimon Glass
66*adfb2bfeSSimon GlassConnect your board's OTG port to your computer.
67*adfb2bfeSSimon Glass
68*adfb2bfeSSimon GlassTo create a suitable image and write it to the board:
69*adfb2bfeSSimon Glass
70*adfb2bfeSSimon Glass   ./firefly-rk3288/tools/mkimage -T rkimage -d ./firefly-rk3288/spl/u-boot-spl-dtb.bin out
71*adfb2bfeSSimon Glass   cat out | openssl rc4 -K 7c4e0304550509072d2c7b38170d1711 | rkflashtool l
72*adfb2bfeSSimon Glass
73*adfb2bfeSSimon GlassIf all goes well you should something like:
74*adfb2bfeSSimon Glass
75*adfb2bfeSSimon Glass   U-Boot SPL 2015.07-rc1-00383-ge345740-dirty (Jun 03 2015 - 10:06:49)
76*adfb2bfeSSimon Glass   Card did not respond to voltage select!
77*adfb2bfeSSimon Glass   spl: mmc init failed with error: -17
78*adfb2bfeSSimon Glass   ### ERROR ### Please RESET the board ###
79*adfb2bfeSSimon Glass
80*adfb2bfeSSimon GlassYou will need to reset the board before each time you try. Yes, that's all
81*adfb2bfeSSimon Glassit does so far. If support for the Rockchip USB protocol or DFU were added
82*adfb2bfeSSimon Glassin SPL then we could in principle load U-Boot and boot to a prompt from USB
83*adfb2bfeSSimon Glassas several other platforms do. However it does not seem to be possible to
84*adfb2bfeSSimon Glassuse the existing boot ROM code from SPL.
85*adfb2bfeSSimon Glass
86*adfb2bfeSSimon Glass
87*adfb2bfeSSimon GlassBooting from an SD card
88*adfb2bfeSSimon Glass=======================
89*adfb2bfeSSimon Glass
90*adfb2bfeSSimon GlassTo write an image that boots from an SD card (assumed to be /dev/sdc):
91*adfb2bfeSSimon Glass
92*adfb2bfeSSimon Glass   ./firefly-rk3288/tools/mkimage -T rksd -d firefly-rk3288/spl/u-boot-spl-dtb.bin out
93*adfb2bfeSSimon Glass   sudo dd if=out of=/dev/sdc
94*adfb2bfeSSimon Glass   sudo dd if=firefly-rk3288/u-boot-dtb.img of=/dev/sdc seek=256
95*adfb2bfeSSimon Glass
96*adfb2bfeSSimon GlassThis puts the Rockchip header and SPL image first and then places the U-Boot
97*adfb2bfeSSimon Glassimage at block 256 (i.e. 128KB from the start of the SD card). This
98*adfb2bfeSSimon Glasscorresponds with this setting in U-Boot:
99*adfb2bfeSSimon Glass
100*adfb2bfeSSimon Glass   #define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR	256
101*adfb2bfeSSimon Glass
102*adfb2bfeSSimon GlassPut this SD (or micro-SD) card into your board and reset it. You should see
103*adfb2bfeSSimon Glasssomething like:
104*adfb2bfeSSimon Glass
105*adfb2bfeSSimon Glass   U-Boot SPL 2015.07-rc1-00383-ge345740-dirty (Jun 03 2015 - 11:04:40)
106*adfb2bfeSSimon Glass
107*adfb2bfeSSimon Glass
108*adfb2bfeSSimon Glass   U-Boot 2015.07-rc1-00383-ge345740-dirty (Jun 03 2015 - 11:04:40)
109*adfb2bfeSSimon Glass
110*adfb2bfeSSimon Glass   DRAM:  2 GiB
111*adfb2bfeSSimon Glass   MMC:
112*adfb2bfeSSimon Glass   Using default environment
113*adfb2bfeSSimon Glass
114*adfb2bfeSSimon Glass   In:    serial@ff690000
115*adfb2bfeSSimon Glass   Out:   serial@ff690000
116*adfb2bfeSSimon Glass   Err:   serial@ff690000
117*adfb2bfeSSimon Glass   =>
118*adfb2bfeSSimon Glass
119*adfb2bfeSSimon Glass
120*adfb2bfeSSimon GlassBooting from SPI
121*adfb2bfeSSimon Glass================
122*adfb2bfeSSimon Glass
123*adfb2bfeSSimon GlassTo write an image that boots from SPI flash (e.g. for the Haier Chromebook):
124*adfb2bfeSSimon Glass
125*adfb2bfeSSimon Glass   ./chromebook_jerry/tools/mkimage -T rkspi -d chromebook_jerry/spl/u-boot-spl-dtb.bin out
126*adfb2bfeSSimon Glass   dd if=spl.bin of=out.bin bs=128K conv=sync
127*adfb2bfeSSimon Glass   cat chromebook_jerry/u-boot-dtb.img out.bin
128*adfb2bfeSSimon Glass   dd if=out.bin of=out.bin.pad bs=4M conv=sync
129*adfb2bfeSSimon Glass
130*adfb2bfeSSimon GlassThis converts the SPL image to the required SPI format by adding the Rockchip
131*adfb2bfeSSimon Glassheader and skipping every 2KB block. Then the U-Boot image is written at
132*adfb2bfeSSimon Glassoffset 128KB and the whole image is padded to 4MB which is the SPI flash size.
133*adfb2bfeSSimon GlassThe position of U-Boot is controlled with this setting in U-Boot:
134*adfb2bfeSSimon Glass
135*adfb2bfeSSimon Glass   #define CONFIG_SYS_SPI_U_BOOT_OFFS	(128 << 10)
136*adfb2bfeSSimon Glass
137*adfb2bfeSSimon GlassIf you have a Dediprog em100pro connected then you can write the image with:
138*adfb2bfeSSimon Glass
139*adfb2bfeSSimon Glass      sudo em100 -s -c GD25LQ32 -d out.bin.pad -r
140*adfb2bfeSSimon Glass
141*adfb2bfeSSimon GlassWhen booting you should see something like:
142*adfb2bfeSSimon Glass
143*adfb2bfeSSimon Glass   U-Boot SPL 2015.07-rc2-00215-g9a58220-dirty (Jun 23 2015 - 12:11:32)
144*adfb2bfeSSimon Glass
145*adfb2bfeSSimon Glass
146*adfb2bfeSSimon Glass   U-Boot 2015.07-rc2-00215-g9a58220-dirty (Jun 23 2015 - 12:11:32 -0600)
147*adfb2bfeSSimon Glass
148*adfb2bfeSSimon Glass   Model: Google Jerry
149*adfb2bfeSSimon Glass   DRAM:  2 GiB
150*adfb2bfeSSimon Glass   MMC:
151*adfb2bfeSSimon Glass   Using default environment
152*adfb2bfeSSimon Glass
153*adfb2bfeSSimon Glass   In:    serial@ff690000
154*adfb2bfeSSimon Glass   Out:   serial@ff690000
155*adfb2bfeSSimon Glass   Err:   serial@ff690000
156*adfb2bfeSSimon Glass   =>
157*adfb2bfeSSimon Glass
158*adfb2bfeSSimon Glass
159*adfb2bfeSSimon GlassFuture work
160*adfb2bfeSSimon Glass===========
161*adfb2bfeSSimon Glass
162*adfb2bfeSSimon GlassImmediate priorities are:
163*adfb2bfeSSimon Glass
164*adfb2bfeSSimon Glass- MMC support (in U-Boot itself)
165*adfb2bfeSSimon Glass- GPIO (driver exists but is lightly tested)
166*adfb2bfeSSimon Glass- I2C (driver exists but is non-functional)
167*adfb2bfeSSimon Glass- USB host
168*adfb2bfeSSimon Glass- USB device
169*adfb2bfeSSimon Glass- PMIC and regulators (only ACT8846 is supported at present)
170*adfb2bfeSSimon Glass- LCD and HDMI
171*adfb2bfeSSimon Glass- Run CPU at full speed
172*adfb2bfeSSimon Glass- Ethernet
173*adfb2bfeSSimon Glass- NAND flash
174*adfb2bfeSSimon Glass- Support for other Rockchip parts
175*adfb2bfeSSimon Glass- Boot U-Boot proper over USB OTG (at present only SPL works)
176*adfb2bfeSSimon Glass
177*adfb2bfeSSimon Glass
178*adfb2bfeSSimon GlassDevelopment Notes
179*adfb2bfeSSimon Glass=================
180*adfb2bfeSSimon Glass
181*adfb2bfeSSimon GlassThere are plenty of patches in the links below to help with this work.
182*adfb2bfeSSimon Glass
183*adfb2bfeSSimon Glass[1] https://github.com/rkchrome/uboot.git
184*adfb2bfeSSimon Glass[2] https://github.com/linux-rockchip/u-boot-rockchip.git branch u-boot-rk3288
185*adfb2bfeSSimon Glass[3] https://github.com/linux-rockchip/rkflashtool.git
186*adfb2bfeSSimon Glass[4] http://wiki.t-firefly.com/index.php/Firefly-RK3288/Serial_debug/en
187*adfb2bfeSSimon Glass
188*adfb2bfeSSimon Glassrkimage
189*adfb2bfeSSimon Glass-------
190*adfb2bfeSSimon Glass
191*adfb2bfeSSimon Glassrkimage.c produces an SPL image suitable for sending directly to the boot ROM
192*adfb2bfeSSimon Glassover USB OTG. This is a very simple format - just the string RK32 (as 4 bytes)
193*adfb2bfeSSimon Glassfollowed by u-boot-spl-dtb.bin.
194*adfb2bfeSSimon Glass
195*adfb2bfeSSimon GlassThe boot ROM loads image to 0xff704000 which is in the internal SRAM. The SRAM
196*adfb2bfeSSimon Glassstarts at 0xff700000 and extends to 0xff718000 where we put the stack.
197*adfb2bfeSSimon Glass
198*adfb2bfeSSimon Glassrksd
199*adfb2bfeSSimon Glass----
200*adfb2bfeSSimon Glass
201*adfb2bfeSSimon Glassrksd.c produces an image consisting of 32KB of empty space, a header and
202*adfb2bfeSSimon Glassu-boot-spl-dtb.bin. The header is defined by 'struct header0_info' although
203*adfb2bfeSSimon Glassmost of the fields are unused by U-Boot. We just need to specify the
204*adfb2bfeSSimon Glasssignature, a flag and the block offset and size of the SPL image.
205*adfb2bfeSSimon Glass
206*adfb2bfeSSimon GlassThe header occupies a single block but we pad it out to 4 blocks. The header
207*adfb2bfeSSimon Glassis encoding using RC4 with the key 7c4e0304550509072d2c7b38170d1711. The SPL
208*adfb2bfeSSimon Glassimage can be encoded too but we don't do that.
209*adfb2bfeSSimon Glass
210*adfb2bfeSSimon GlassThe maximum size of u-boot-spl-dtb.bin which the boot ROM will read is 32KB,
211*adfb2bfeSSimon Glassor 0x40 blocks. This is a severe and annoying limitation. There may be a way
212*adfb2bfeSSimon Glassaround this limitation, since there is plenty of SRAM, but at present the
213*adfb2bfeSSimon Glassboard refuses to boot if this limit is exceeded.
214*adfb2bfeSSimon Glass
215*adfb2bfeSSimon GlassThe image produced is padded up to a block boundary (512 bytes). It should be
216*adfb2bfeSSimon Glasswritten to the start of an SD card using dd.
217*adfb2bfeSSimon Glass
218*adfb2bfeSSimon GlassSince this image is set to load U-Boot from the SD card at block offset,
219*adfb2bfeSSimon GlassCONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR, dd should be used to write
220*adfb2bfeSSimon Glassu-boot-dtb.img to the SD card at that offset. See above for instructions.
221*adfb2bfeSSimon Glass
222*adfb2bfeSSimon Glassrkspi
223*adfb2bfeSSimon Glass-----
224*adfb2bfeSSimon Glass
225*adfb2bfeSSimon Glassrkspi.c produces an image consisting of a header and u-boot-spl-dtb.bin. The
226*adfb2bfeSSimon Glassresulting image is then spread out so that only the first 2KB of each 4KB
227*adfb2bfeSSimon Glasssector is used. The header is the same as with rksd and the maximum size is
228*adfb2bfeSSimon Glassalso 32KB (before spreading). The image should be written to the start of
229*adfb2bfeSSimon GlassSPI flash.
230*adfb2bfeSSimon Glass
231*adfb2bfeSSimon GlassSee above for instructions on how to write a SPI image.
232*adfb2bfeSSimon Glass
233*adfb2bfeSSimon Glass
234*adfb2bfeSSimon GlassDevice tree and driver model
235*adfb2bfeSSimon Glass----------------------------
236*adfb2bfeSSimon Glass
237*adfb2bfeSSimon GlassWhere possible driver model is used to provide a structure to the
238*adfb2bfeSSimon Glassfunctionality. Device tree is used for configuration. However these have an
239*adfb2bfeSSimon Glassoverhead and in SPL with a 32KB size limit some shortcuts have been taken.
240*adfb2bfeSSimon GlassIn general all Rockchip drivers should use these features, with SPL-specific
241*adfb2bfeSSimon Glassmodifications where required.
242*adfb2bfeSSimon Glass
243*adfb2bfeSSimon Glass
244*adfb2bfeSSimon Glass--
245*adfb2bfeSSimon GlassSimon Glass <sjg@chromium.org>
246*adfb2bfeSSimon Glass24 June 2015
247