xref: /OK3568_Linux_fs/u-boot/doc/README.davinci.nand_spl (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunWith this approach, we don't need the UBL any more on DaVinci boards.
2*4882a593SmuzhiyunA "make boardname" will compile a u-boot.ubl, with UBL Header, which is
3*4882a593Smuzhiyunneeded for the RBL to find the "UBL", which actually is a  UBL-compatible
4*4882a593Smuzhiyunheader, nand spl code and u-boot code.
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunAs the RBL uses another read function as the "standard" u-boot,
8*4882a593Smuzhiyunwe need a command, which switches between this two read/write
9*4882a593Smuzhiyunfunctions, so we can write the UBL header and the spl
10*4882a593Smuzhiyuncode in a format, which the RBL can read. This is realize
11*4882a593Smuzhiyun(at the moment in board specific code) in the u-boot command
12*4882a593Smuzhiyunnandrbl
13*4882a593Smuzhiyun
14*4882a593Smuzhiyunnandrbl without arguments returns actual mode (rbl or uboot).
15*4882a593Smuzhiyunwith nandrbl mode (mode = "rbl" or "uboot") you can switch
16*4882a593Smuzhiyunbetween the two NAND read/write modes.
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunTo set up mkimage you need a config file for mkimage, example:
20*4882a593Smuzhiyunboard/ait/cam_enc_4xx/ublimage.cfg
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunFor information about the configuration please see:
23*4882a593Smuzhiyundoc/README.ublimage
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunExample for the cam_enc_4xx board:
26*4882a593SmuzhiyunOn the cam_enc_4xx board we have a NAND flash with blocksize = 0x20000 and
27*4882a593Smuzhiyunpagesize = 0x800, so the u-boot.ubl image (which you get with:
28*4882a593Smuzhiyun"make cam_enc_4xx") looks like this:
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun00000000  00 ed ac a1 20 00 00 00  06 00 00 00 05 00 00 00  |.... ...........|
31*4882a593Smuzhiyun00000010  00 00 00 00 20 00 00 00  ff ff ff ff ff ff ff ff  |.... ...........|
32*4882a593Smuzhiyun00000020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
33*4882a593Smuzhiyun*
34*4882a593Smuzhiyun00000800  14 00 00 ea 14 f0 9f e5  10 f0 9f e5 0c f0 9f e5  |................|
35*4882a593Smuzhiyun00000810  08 f0 9f e5 04 f0 9f e5  00 f0 9f e5 04 f0 1f e5  |................|
36*4882a593Smuzhiyun00000820  00 01 00 00 78 56 34 12  78 56 34 12 78 56 34 12  |....xV4.xV4.xV4.|
37*4882a593Smuzhiyun[...]
38*4882a593Smuzhiyun*
39*4882a593Smuzhiyun00001fe0  00 00 00 00 00 00 00 00  ff ff ff ff ff ff ff ff  |................|
40*4882a593Smuzhiyun00001ff0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
41*4882a593Smuzhiyun*
42*4882a593Smuzhiyun00003800  14 00 00 ea 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
43*4882a593Smuzhiyun00003810  14 f0 9f e5 14 f0 9f e5  14 f0 9f e5 14 f0 9f e5  |................|
44*4882a593Smuzhiyun00003820  80 01 08 81 e0 01 08 81  40 02 08 81 a0 02 08 81  |........@.......|
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunIn the first "page" of the image, we have the UBL Header, needed for
47*4882a593Smuzhiyunthe RBL to find the spl code.
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunThe spl code starts in the second "page" of the image, with a size
50*4882a593Smuzhiyundefined by:
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun#define CONFIG_SYS_NROF_PAGES_NAND_SPL	6
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunAfter the spl code, there comes the "real" u-boot code
55*4882a593Smuzhiyun@ (6 + 1) * pagesize = 0x3800
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun------------------------------------------------------------------------
58*4882a593SmuzhiyunSetting up spl code:
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun/*
61*4882a593Smuzhiyun * RBL searches from Block n (n = 1..24)
62*4882a593Smuzhiyun * so we can define, how many UBL Headers
63*4882a593Smuzhiyun * we write before the real spl code
64*4882a593Smuzhiyun */
65*4882a593Smuzhiyun#define CONFIG_SYS_NROF_UBL_HEADER	5
66*4882a593Smuzhiyun#define CONFIG_SYS_NROF_PAGES_NAND_SPL	6
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun#define CONFIG_SYS_NAND_U_BOOT_OFFS	((CONFIG_SYS_NROF_UBL_HEADER * \
69*4882a593Smuzhiyun					CONFIG_SYS_NAND_BLOCK_SIZE) + \
70*4882a593Smuzhiyun					(CONFIG_SYS_NROF_PAGES_NAND_SPL) * \
71*4882a593Smuzhiyun					CONFIG_SYS_NAND_PAGE_SIZE)
72*4882a593Smuzhiyun------------------------------------------------------------------------
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunBurning into NAND:
75*4882a593Smuzhiyun
76*4882a593Smuzhiyunstep 1:
77*4882a593SmuzhiyunThe RBL searches from Block n ( n = 1..24) on page 0 for valid UBL
78*4882a593SmuzhiyunHeaders, so you have to burn the UBL header page from the u-boot.ubl
79*4882a593Smuzhiyunimage to the blocks, you want to have the UBL header.
80*4882a593Smuzhiyun!! Don;t forget to switch to rbl nand read/write functions with
81*4882a593Smuzhiyun   "nandrbl rbl"
82*4882a593Smuzhiyun
83*4882a593Smuzhiyunstep 2:
84*4882a593SmuzhiyunYou need to setup in the ublimage.cfg, where the RBL can find the spl
85*4882a593Smuzhiyuncode, and how big it is.
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun!! RBL always starts reading from page 0 !!
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunFor the AIT board, we have:
90*4882a593SmuzhiyunPAGES		6
91*4882a593SmuzhiyunSTART_BLOCK	5
92*4882a593Smuzhiyun
93*4882a593SmuzhiyunSo we need to copy the spl code to block 5 page 0
94*4882a593Smuzhiyun!! Don;t forget to switch to rbl nand read/write functions with
95*4882a593Smuzhiyun   "nandrbl rbl"
96*4882a593Smuzhiyun
97*4882a593Smuzhiyunstep 3:
98*4882a593SmuzhiyunYou need to copy the u-boot image to the block/page
99*4882a593Smuzhiyunwhere the spl code reads it (CONFIG_SYS_NAND_U_BOOT_OFFS)
100*4882a593Smuzhiyun!! Don;t forget to switch to rbl nand read/write functions with
101*4882a593Smuzhiyun   "nandrbl uboot", which is default.
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunOn the cam_enc_4xx board it is:
104*4882a593Smuzhiyun#define CONFIG_SYS_NAND_U_BOOT_OFFS	(0xc0000)
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun-> this results in following NAND usage on the cam_enc_4xx board:
107*4882a593Smuzhiyun
108*4882a593Smuzhiyunaddr
109*4882a593Smuzhiyun
110*4882a593Smuzhiyun20000		possible UBL Header
111*4882a593Smuzhiyun40000		possible UBL Header
112*4882a593Smuzhiyun60000		possible UBL Header
113*4882a593Smuzhiyun80000		possilbe UBL Header
114*4882a593Smuzhiyuna0000		spl code
115*4882a593Smuzhiyunc0000		u-boot code
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunThe above steps are executeed through the following environment vars:
118*4882a593Smuzhiyun(using 80000 as address for the UBL header)
119*4882a593Smuzhiyun
120*4882a593Smuzhiyunpagesz=800
121*4882a593Smuzhiyunuboot=/tftpboot/cam_enc_4xx/u-boot.ubl
122*4882a593Smuzhiyunload=tftp 80000000 ${uboot}
123*4882a593Smuzhiyunwriteheader nandrbl rbl;nand erase 80000 ${pagesz};nand write 80000000 80000 ${pagesz};nandrbl uboot
124*4882a593Smuzhiyunwritenand_spl nandrbl rbl;nand erase a0000 3000;nand write 80000800 a0000 3000;nandrbl uboot
125*4882a593Smuzhiyunwriteuboot nandrbl uboot;nand erase c0000 5d000;nand write 80003800 c0000 5d000
126*4882a593Smuzhiyunupdate=run load writeheader writenand_spl writeuboot
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunIf you do a "run load update" u-boot, spl + ubl header
129*4882a593Smuzhiyunare magically updated ;-)
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunNote:
132*4882a593Smuzhiyun- There seem to be a bug in the RBL code (at least on my HW),
133*4882a593Smuzhiyun  In the UBL block, I can set the page to values != 0, so it
134*4882a593Smuzhiyun  is possible to burn step 1 and step 2 in one step into the
135*4882a593Smuzhiyun  flash, but the RBL ignores the page settings, so I have to
136*4882a593Smuzhiyun  burn the UBL Header to a page 0 and the spl code to
137*4882a593Smuzhiyun  a page 0 ... :-(
138*4882a593Smuzhiyun- If we make the nand read/write functions in the RBL equal to
139*4882a593Smuzhiyun  the functions in u-boot (as I have no RBL code, it is only
140*4882a593Smuzhiyun  possible in u-boot), we could burn the complete image in
141*4882a593Smuzhiyun  one step ... that would be nice ...
142