1*4882a593Smuzhiyun--------------------------------------------- 2*4882a593SmuzhiyunUBL image Boot Image generation using mkimage 3*4882a593Smuzhiyun--------------------------------------------- 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunThis document describes how to set up an U-Boot image that can be directly 6*4882a593Smuzhiyunbooted by a DaVinci processor via NAND boot mode, using an UBL header, 7*4882a593Smuzhiyunbut without need for UBL. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunFor more details see section 11.2 "ARM ROM Boot Modes" of 10*4882a593Smuzhiyunhttp://focus.ti.com/lit/ug/sprufg5a/sprufg5a.pdf 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunCommand syntax: 13*4882a593Smuzhiyun-------------- 14*4882a593Smuzhiyun./tools/mkimage -l <u-boot_file> 15*4882a593Smuzhiyun to list the UBL image file details 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun./tools/mkimage -T ublimage \ 18*4882a593Smuzhiyun -n <board specific configuration file> \ 19*4882a593Smuzhiyun -d <u-boot binary> <output image file> 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunFor example, for the davinci dm365evm board: 22*4882a593Smuzhiyun./tools/mkimage -n ./board/davinci/dm365evm/ublimage.cfg \ 23*4882a593Smuzhiyun -T ublimage \ 24*4882a593Smuzhiyun -d u-boot-nand.bin u-boot.ubl 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunYou can generate the image directly when you compile u-boot with: 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun$ make u-boot.ubl 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunThe output image can be flashed into the NAND. 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunPlease check the DaVinci documentation for further details. 33*4882a593Smuzhiyun 34*4882a593SmuzhiyunBoard specific configuration file specifications: 35*4882a593Smuzhiyun------------------------------------------------- 36*4882a593Smuzhiyun1. This file must present in the $(BOARDDIR) and the name should be 37*4882a593Smuzhiyun ublimage.cfg (since this is used in Makefile). 38*4882a593Smuzhiyun2. This file can have empty lines and lines starting with "#" as first 39*4882a593Smuzhiyun character to put comments. 40*4882a593Smuzhiyun3. This file can have configuration command lines as mentioned below, 41*4882a593Smuzhiyun any other information in this file is treated as invalid. 42*4882a593Smuzhiyun 43*4882a593SmuzhiyunConfiguration command line syntax: 44*4882a593Smuzhiyun--------------------------------- 45*4882a593Smuzhiyun1. Each command line must have two strings, first one command or address 46*4882a593Smuzhiyun and second one data string 47*4882a593Smuzhiyun2. Following are the valid command strings and associated data strings:- 48*4882a593Smuzhiyun Command string data string 49*4882a593Smuzhiyun -------------- ----------- 50*4882a593Smuzhiyun MODE UBL special mode, on of: 51*4882a593Smuzhiyun safe 52*4882a593Smuzhiyun Example: 53*4882a593Smuzhiyun MODE safe 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun ENTRY Entry point address for the user 56*4882a593Smuzhiyun bootloader (absolute address) = TEXT_BASE 57*4882a593Smuzhiyun nand_spl loader. 58*4882a593Smuzhiyun Example: 59*4882a593Smuzhiyun ENTRY 0x00000020 60*4882a593Smuzhiyun 61*4882a593Smuzhiyun PAGES Number of pages (size of user bootloader 62*4882a593Smuzhiyun in number of pages) 63*4882a593Smuzhiyun Example: 64*4882a593Smuzhiyun PAGES 27 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun START_BLOCK Block number where user bootloader is present 67*4882a593Smuzhiyun Example: 68*4882a593Smuzhiyun START_BLOCK 5 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun START_PAGE Page number where user bootloader is present 71*4882a593Smuzhiyun (for RBL always 0) 72*4882a593Smuzhiyun Example: 73*4882a593Smuzhiyun START_PAGE 0 74*4882a593Smuzhiyun 75*4882a593Smuzhiyun------------------------------------------------ 76*4882a593Smuzhiyun 77*4882a593SmuzhiyunStructure of the u-boot.ubl binary: 78*4882a593Smuzhiyun 79*4882a593Smuzhiyuncompile steps: 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun1) nand_spl code compile, with pad_to = (TEXT_BASE + 82*4882a593Smuzhiyun (CONFIG_SYS_NROF_PAGES_NAND_SPL * pagesize)) 83*4882a593Smuzhiyun Example: cam_enc_4xx pad_to = 0x20 + (6 * 0x800) = 0x3020 = 12320 84*4882a593Smuzhiyun -> u-boot-spl-16k.bin 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun !! TEXT_BASE = 0x20, as the RBL starts at 0x20 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun2) compile u-boot.bin ("normal" u-boot) 89*4882a593Smuzhiyun -> u-boot.bin 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun3) create u-boot-nand.bin = u-boot-spl-16k.bin + u-boot.bin 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun4) create u-boot.ubl, size = 1 page size NAND 94*4882a593Smuzhiyun create UBL header and paste it before u-boot.bin 95*4882a593Smuzhiyun 96*4882a593SmuzhiyunThis steps are done automagically if you do a "make all" 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun-> You get an u-boot.ubl binary, which you can flash 99*4882a593Smuzhiyun into your NAND. 100*4882a593Smuzhiyun 101*4882a593SmuzhiyunStructure of this binary (Example for the cam_enc_4xx board with a NAND 102*4882a593Smuzhiyunpage size = 0x800): 103*4882a593Smuzhiyun 104*4882a593Smuzhiyunoffset : 0x00000 | 0x800 | 0x3800 105*4882a593Smuzhiyuncontent: UBL | nand_spl | u-boot code 106*4882a593Smuzhiyun Header | code | 107*4882a593Smuzhiyun 108*4882a593SmuzhiyunThe NAND layout looks for example like this: 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun(Example for the cam_enc_4xx board with a NAND page size = 0x800, block 111*4882a593Smuzhiyunsize = 0x20000 and CONFIG_SYS_NROF_UBL_HEADER 5): 112*4882a593Smuzhiyun 113*4882a593Smuzhiyunoffset : 0x80000 | 0xa0000 | 0xa3000 114*4882a593Smuzhiyuncontent: UBL | nand_spl | u-boot code 115*4882a593Smuzhiyun Header | code | 116*4882a593Smuzhiyun ^ ^ 117*4882a593Smuzhiyun ^ 0xa0000 = CONFIG_SYS_NROF_UBL_HEADER * 0x20000 118*4882a593Smuzhiyun ^ 119*4882a593Smuzhiyun 0x80000 = Block 4 * 0x20000 120*4882a593Smuzhiyun 121*4882a593SmuzhiyunIf the cpu starts in NAND boot mode, it checks the UBL descriptor 122*4882a593Smuzhiyunstarting with block 1 (page 0). When a valid UBL signature is found, 123*4882a593Smuzhiyunthe corresponding block number (from 1 to 24) is written to the last 32 124*4882a593Smuzhiyunbits of ARM internal memory (0x7ffc-0x8000). This feature is provided 125*4882a593Smuzhiyunas a basic debug mechanism. If not found, it continues with block 2 126*4882a593Smuzhiyun... last possible block is 24 127*4882a593Smuzhiyun 128*4882a593SmuzhiyunIf a valid UBL descriptor is found, the UBL descriptor is read and 129*4882a593Smuzhiyunprocessed. The descriptor gives the information required for loading 130*4882a593Smuzhiyunand control transfer to the nand_spl code. The nand_spl code is then 131*4882a593Smuzhiyunread and processed. 132*4882a593Smuzhiyun 133*4882a593SmuzhiyunOnce the user-specified start-up conditions are set, the RBL copies the 134*4882a593Smuzhiyunnand_spl into ARM internal RAM, starting at address 0x0000: 0020. 135*4882a593Smuzhiyun ^^^^ 136*4882a593Smuzhiyun 137*4882a593SmuzhiyunThe nand_spl code itself now does necessary intializations, and at least, 138*4882a593Smuzhiyuncopies the u-boot code from NAND into RAM, and jumps to it ... 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun------------------------------------------------ 141*4882a593SmuzhiyunAuthor: Heiko Schocher <hs@denx.de> 142