README.davinci.nand_spl 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. With this approach, we don't need the UBL any more on DaVinci boards.
  2. A "make boardname" will compile a u-boot.ubl, with UBL Header, which is
  3. needed for the RBL to find the "UBL", which actually is a UBL-compatible
  4. header, nand spl code and u-boot code.
  5. As the RBL uses another read function as the "standard" u-boot,
  6. we need a command, which switches between this two read/write
  7. functions, so we can write the UBL header and the spl
  8. code in a format, which the RBL can read. This is realize
  9. (at the moment in board specific code) in the u-boot command
  10. nandrbl
  11. nandrbl without arguments returns actual mode (rbl or uboot).
  12. with nandrbl mode (mode = "rbl" or "uboot") you can switch
  13. between the two NAND read/write modes.
  14. To set up mkimage you need a config file for mkimage, example:
  15. board/ait/cam_enc_4xx/ublimage.cfg
  16. For information about the configuration please see:
  17. doc/README.ublimage
  18. Example for the cam_enc_4xx board:
  19. On the cam_enc_4xx board we have a NAND flash with blocksize = 0x20000 and
  20. pagesize = 0x800, so the u-boot.ubl image (which you get with:
  21. "make cam_enc_4xx") looks like this:
  22. 00000000 00 ed ac a1 20 00 00 00 06 00 00 00 05 00 00 00 |.... ...........|
  23. 00000010 00 00 00 00 20 00 00 00 ff ff ff ff ff ff ff ff |.... ...........|
  24. 00000020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
  25. *
  26. 00000800 14 00 00 ea 14 f0 9f e5 10 f0 9f e5 0c f0 9f e5 |................|
  27. 00000810 08 f0 9f e5 04 f0 9f e5 00 f0 9f e5 04 f0 1f e5 |................|
  28. 00000820 00 01 00 00 78 56 34 12 78 56 34 12 78 56 34 12 |....xV4.xV4.xV4.|
  29. [...]
  30. *
  31. 00001fe0 00 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff |................|
  32. 00001ff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
  33. *
  34. 00003800 14 00 00 ea 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 |................|
  35. 00003810 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 14 f0 9f e5 |................|
  36. 00003820 80 01 08 81 e0 01 08 81 40 02 08 81 a0 02 08 81 |........@.......|
  37. In the first "page" of the image, we have the UBL Header, needed for
  38. the RBL to find the spl code.
  39. The spl code starts in the second "page" of the image, with a size
  40. defined by:
  41. #define CONFIG_SYS_NROF_PAGES_NAND_SPL 6
  42. After the spl code, there comes the "real" u-boot code
  43. @ (6 + 1) * pagesize = 0x3800
  44. ------------------------------------------------------------------------
  45. Setting up spl code:
  46. /*
  47. * RBL searches from Block n (n = 1..24)
  48. * so we can define, how many UBL Headers
  49. * we write before the real spl code
  50. */
  51. #define CONFIG_SYS_NROF_UBL_HEADER 5
  52. #define CONFIG_SYS_NROF_PAGES_NAND_SPL 6
  53. #define CONFIG_SYS_NAND_U_BOOT_OFFS ((CONFIG_SYS_NROF_UBL_HEADER * \
  54. CONFIG_SYS_NAND_BLOCK_SIZE) + \
  55. (CONFIG_SYS_NROF_PAGES_NAND_SPL) * \
  56. CONFIG_SYS_NAND_PAGE_SIZE)
  57. ------------------------------------------------------------------------
  58. Burning into NAND:
  59. step 1:
  60. The RBL searches from Block n ( n = 1..24) on page 0 for valid UBL
  61. Headers, so you have to burn the UBL header page from the u-boot.ubl
  62. image to the blocks, you want to have the UBL header.
  63. !! Don;t forget to switch to rbl nand read/write functions with
  64. "nandrbl rbl"
  65. step 2:
  66. You need to setup in the ublimage.cfg, where the RBL can find the spl
  67. code, and how big it is.
  68. !! RBL always starts reading from page 0 !!
  69. For the AIT board, we have:
  70. PAGES 6
  71. START_BLOCK 5
  72. So we need to copy the spl code to block 5 page 0
  73. !! Don;t forget to switch to rbl nand read/write functions with
  74. "nandrbl rbl"
  75. step 3:
  76. You need to copy the u-boot image to the block/page
  77. where the spl code reads it (CONFIG_SYS_NAND_U_BOOT_OFFS)
  78. !! Don;t forget to switch to rbl nand read/write functions with
  79. "nandrbl uboot", which is default.
  80. On the cam_enc_4xx board it is:
  81. #define CONFIG_SYS_NAND_U_BOOT_OFFS (0xc0000)
  82. -> this results in following NAND usage on the cam_enc_4xx board:
  83. addr
  84. 20000 possible UBL Header
  85. 40000 possible UBL Header
  86. 60000 possible UBL Header
  87. 80000 possilbe UBL Header
  88. a0000 spl code
  89. c0000 u-boot code
  90. The above steps are executeed through the following environment vars:
  91. (using 80000 as address for the UBL header)
  92. pagesz=800
  93. uboot=/tftpboot/cam_enc_4xx/u-boot.ubl
  94. load=tftp 80000000 ${uboot}
  95. writeheader nandrbl rbl;nand erase 80000 ${pagesz};nand write 80000000 80000 ${pagesz};nandrbl uboot
  96. writenand_spl nandrbl rbl;nand erase a0000 3000;nand write 80000800 a0000 3000;nandrbl uboot
  97. writeuboot nandrbl uboot;nand erase c0000 5d000;nand write 80003800 c0000 5d000
  98. update=run load writeheader writenand_spl writeuboot
  99. If you do a "run load update" u-boot, spl + ubl header
  100. are magically updated ;-)
  101. Note:
  102. - There seem to be a bug in the RBL code (at least on my HW),
  103. In the UBL block, I can set the page to values != 0, so it
  104. is possible to burn step 1 and step 2 in one step into the
  105. flash, but the RBL ignores the page settings, so I have to
  106. burn the UBL Header to a page 0 and the spl code to
  107. a page 0 ... :-(
  108. - If we make the nand read/write functions in the RBL equal to
  109. the functions in u-boot (as I have no RBL code, it is only
  110. possible in u-boot), we could burn the complete image in
  111. one step ... that would be nice ...