README 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. Introduction:
  2. -------------
  3. The AM65x family of SoCs is the first device family from K3 Multicore
  4. SoC architecture, targeted for broad market and industrial control with
  5. aim to meet the complex processing needs of modern embedded products.
  6. The device is built over three domains, each containing specific processing
  7. cores, voltage domains and peripherals:
  8. 1. Wake-up (WKUP) domain:
  9. - Device Management and Security Controller (DMSC)
  10. 2. Microcontroller (MCU) domain:
  11. - Dual Core ARM Cortex-R5F processor
  12. 3. MAIN domain:
  13. - Quad core 64-bit ARM Cortex-A53
  14. More info can be found in TRM: http://www.ti.com/lit/pdf/spruid7
  15. Boot Flow:
  16. ----------
  17. On AM65x family devices, ROM supports boot only via MCU(R5). This means that
  18. bootloader has to run on R5 core. In order to meet this constraint, and for
  19. the following reasons the boot flow is designed as mentioned:
  20. 1. Need to move away from R5 asap, so that we want to start *any*
  21. firmware on the r5 cores like.... autosar can be loaded to receive CAN
  22. response and other safety operations to be started. This operation is
  23. very time critical and is applicable for all automotive use cases.
  24. 2. U-Boot on A53 should start other remotecores for various
  25. applications. This should happen before running Linux.
  26. 3. In production boot flow, we might not like to use full u-boot,
  27. instead use Flacon boot flow to reduce boot time.
  28. +------------------------------------------------------------------------+
  29. | DMSC | R5 | A53 |
  30. +------------------------------------------------------------------------+
  31. | +--------+ | | |
  32. | | Reset | | | |
  33. | +--------+ | | |
  34. | : | | |
  35. | +--------+ | +-----------+ | |
  36. | | *ROM* |----------|-->| Reset rls | | |
  37. | +--------+ | +-----------+ | |
  38. | | | | : | |
  39. | | ROM | | : | |
  40. | |services| | : | |
  41. | | | | +-------------+ | |
  42. | | | | | *R5 ROM* | | |
  43. | | | | +-------------+ | |
  44. | | |<---------|---|Load and auth| | |
  45. | | | | | tiboot3.bin | | |
  46. | | | | +-------------+ | |
  47. | | | | : | |
  48. | | | | : | |
  49. | | | | : | |
  50. | | | | +-------------+ | |
  51. | | | | | *R5 SPL* | | |
  52. | | | | +-------------+ | |
  53. | | | | | Load | | |
  54. | | | | | sysfw.itb | | |
  55. | | Start | | +-------------+ | |
  56. | | System |<---------|---| Start | | |
  57. | |Firmware| | | SYSFW | | |
  58. | +--------+ | +-------------+ | |
  59. | : | | | | |
  60. | +---------+ | | Load | | |
  61. | | *SYSFW* | | | system | | |
  62. | +---------+ | | Config data | | |
  63. | | |<--------|---| | | |
  64. | | | | +-------------+ | |
  65. | | | | | | | |
  66. | | | | | DDR | | |
  67. | | | | | config | | |
  68. | | | | +-------------+ | |
  69. | | | | | | | |
  70. | | |<--------|---| Start A53 | | |
  71. | | | | | and Reset | | |
  72. | | | | +-------------+ | |
  73. | | | | | +-----------+ |
  74. | | |---------|-----------------------|---->| Reset rls | |
  75. | | | | | +-----------+ |
  76. | | DMSC | | | : |
  77. | |Services | | | +-----------+ |
  78. | | |<--------|-----------------------|---->|*ATF/OPTEE*| |
  79. | | | | | +-----------+ |
  80. | | | | | : |
  81. | | | | | +-----------+ |
  82. | | |<--------|-----------------------|---->| *A53 SPL* | |
  83. | | | | | +-----------+ |
  84. | | | | | | Load | |
  85. | | | | | | u-boot.img| |
  86. | | | | | +-----------+ |
  87. | | | | | : |
  88. | | | | | +-----------+ |
  89. | | |<--------|-----------------------|---->| *U-Boot* | |
  90. | | | | | +-----------+ |
  91. | | | | | | prompt | |
  92. | | | | | +-----------+ |
  93. | +---------+ | | |
  94. | | | |
  95. +------------------------------------------------------------------------+
  96. - Here DMSC acts as master and provides all the critical services. R5/A53
  97. requests DMSC to get these services done as shown in the above diagram.
  98. Sources:
  99. --------
  100. 1. SYSFW:
  101. Tree: git://git.ti.com/k3-image-gen/k3-image-gen.git
  102. Branch: master
  103. 2. ATF:
  104. Tree: https://github.com/ARM-software/arm-trusted-firmware.git
  105. Branch: master
  106. 3. OPTEE:
  107. Tree: https://github.com/OP-TEE/optee_os.git
  108. Branch: master
  109. 4. U-Boot:
  110. Tree: http://git.denx.de/u-boot.git
  111. Branch: master
  112. Build procedure:
  113. ----------------
  114. 1. SYSFW:
  115. $ make CROSS_COMPILE=arm-linux-gnueabihf-
  116. 2. ATF:
  117. $ make CROSS_COMPILE=aarch64-linux-gnu- ARCH=aarch64 PLAT=k3 TARGET_BOARD=generic SPD=opteed
  118. 3. OPTEE:
  119. $ make PLATFORM=k3-am65x CFG_ARM64_core=y
  120. 4. U-Boot:
  121. 4.1. R5:
  122. $ make CROSS_COMPILE=arm-linux-gnueabihf- am65x_evm_r5_defconfig O=/tmp/r5
  123. $ make CROSS_COMPILE=arm-linux-gnueabihf- O=/tmp/r5
  124. 4.2. A53:
  125. $ make CROSS_COMPILE=aarch64-linux-gnu- am65x_evm_a53_defconfig O=/tmp/a53
  126. $ make CROSS_COMPILE=aarch64-linux-gnu- ATF=<path to ATF dir>/build/k3/generic/release/bl31.bin TEE=<path to OPTEE OS dir>/out/arm-plat-k3/core/tee-pager_v2.bin O=/tmp/a53
  127. Target Images
  128. --------------
  129. Copy the below images to an SD card and boot:
  130. - sysfw.itb from step 1
  131. - tiboot3.bin from step 4.1
  132. - tispl.bin, u-boot.img from 4.2
  133. Image formats:
  134. --------------
  135. - tiboot3.bin:
  136. +-----------------------+
  137. | X.509 |
  138. | Certificate |
  139. | +-------------------+ |
  140. | | | |
  141. | | R5 | |
  142. | | u-boot-spl.bin | |
  143. | | | |
  144. | +-------------------+ |
  145. | | | |
  146. | | FIT header | |
  147. | | +---------------+ | |
  148. | | | | | |
  149. | | | DTB 1...N | | |
  150. | | +---------------+ | |
  151. | +-------------------+ |
  152. +-----------------------+
  153. - tispl.bin
  154. +-----------------------+
  155. | |
  156. | FIT HEADER |
  157. | +-------------------+ |
  158. | | | |
  159. | | A53 ATF | |
  160. | +-------------------+ |
  161. | | | |
  162. | | A53 OPTEE | |
  163. | +-------------------+ |
  164. | | | |
  165. | | A53 SPL | |
  166. | +-------------------+ |
  167. | | | |
  168. | | SPL DTB 1...N | |
  169. | +-------------------+ |
  170. +-----------------------+
  171. - sysfw.itb
  172. +-----------------------+
  173. | |
  174. | FIT HEADER |
  175. | +-------------------+ |
  176. | | | |
  177. | | sysfw.bin | |
  178. | +-------------------+ |
  179. | | | |
  180. | | board config | |
  181. | +-------------------+ |
  182. | | | |
  183. | | PM config | |
  184. | +-------------------+ |
  185. | | | |
  186. | | RM config | |
  187. | +-------------------+ |
  188. | | | |
  189. | | Secure config | |
  190. | +-------------------+ |
  191. +-----------------------+
  192. eMMC:
  193. -----
  194. ROM supports booting from eMMC from boot0 partition offset 0x0
  195. Flashing images to eMMC:
  196. The following commands can be used to download tiboot3.bin, tispl.bin,
  197. u-boot.img, and sysfw.itb from an SD card and write them to the eMMC boot0
  198. partition at respective addresses.
  199. => mmc dev 0 1
  200. => fatload mmc 1 ${loadaddr} tiboot3.bin
  201. => mmc write ${loadaddr} 0x0 0x400
  202. => fatload mmc 1 ${loadaddr} tispl.bin
  203. => mmc write ${loadaddr} 0x400 0x1000
  204. => fatload mmc 1 ${loadaddr} u-boot.img
  205. => mmc write ${loadaddr} 0x1400 0x2000
  206. => fatload mmc 1 ${loadaddr} sysfw.itb
  207. => mmc write ${loadaddr} 0x3600 0x800
  208. To give the ROM access to the boot partition, the following commands must be
  209. used for the first time:
  210. => mmc partconf 0 1 1 1
  211. => mmc bootbus 0 1 0 0
  212. To create a software partition for the rootfs, the following command can be
  213. used:
  214. => gpt write mmc 0 ${partitions}
  215. eMMC layout:
  216. boot0 partition (8 MB) user partition
  217. 0x0+----------------------------------+ 0x0+-------------------------+
  218. | tiboot3.bin (512 KB) | | |
  219. 0x400+----------------------------------+ | |
  220. | tispl.bin (2 MB) | | |
  221. 0x1400+----------------------------------+ | rootfs |
  222. | u-boot.img (4 MB) | | |
  223. 0x3400+----------------------------------+ | |
  224. | environment (128 KB) | | |
  225. 0x3500+----------------------------------+ | |
  226. | backup environment (128 KB) | | |
  227. 0x3600+----------------------------------+ | |
  228. | sysfw (1 MB) | | |
  229. 0x3E00+----------------------------------+ +-------------------------+
  230. Kernel image and DT are expected to be present in the /boot folder of rootfs.
  231. To boot kernel from eMMC, use the following commands:
  232. => setenv mmcdev 0
  233. => setenv bootpart 0
  234. => boot
  235. OSPI:
  236. -----
  237. ROM supports booting from OSPI from offset 0x0.
  238. Flashing images to OSPI:
  239. Below commands can be used to download tiboot3.bin, tispl.bin, u-boot.img,
  240. and sysfw.itb over tftp and then flash those to OSPI at their respective
  241. addresses.
  242. => sf probe
  243. => tftp ${loadaddr} tiboot3.bin
  244. => sf update $loadaddr 0x0 $filesize
  245. => tftp ${loadaddr} tispl.bin
  246. => sf update $loadaddr 0x80000 $filesize
  247. => tftp ${loadaddr} u-boot.img
  248. => sf update $loadaddr 0x280000 $filesize
  249. => tftp ${loadaddr} sysfw.itb
  250. => sf update $loadaddr 0x6C0000 $filesize
  251. Flash layout for OSPI:
  252. 0x0 +----------------------------+
  253. | ospi.tiboot3(512K) |
  254. | |
  255. 0x80000 +----------------------------+
  256. | ospi.tispl(2M) |
  257. | |
  258. 0x280000 +----------------------------+
  259. | ospi.u-boot(4M) |
  260. | |
  261. 0x680000 +----------------------------+
  262. | ospi.env(128K) |
  263. | |
  264. 0x6A0000 +----------------------------+
  265. | ospi.env.backup (128K) |
  266. | |
  267. 0x6C0000 +----------------------------+
  268. | ospi.sysfw(1M) |
  269. | |
  270. 0x7C0000 +----------------------------+
  271. | padding (256k) |
  272. 0x800000 +----------------------------+
  273. | ospi.rootfs(UBIFS) |
  274. | |
  275. +----------------------------+
  276. Kernel Image and DT are expected to be present in the /boot folder of UBIFS
  277. ospi.rootfs just like in SD card case. U-Boot looks for UBI volume named
  278. "rootfs" for rootfs.
  279. To boot kernel from OSPI, at the U-Boot prompt:
  280. => setenv boot ubi
  281. => boot
  282. UART:
  283. -----
  284. ROM supports booting from MCU_UART0 via X-Modem protocol. The entire UART-based
  285. boot process up to U-Boot (proper) prompt goes through different stages and uses
  286. different UART peripherals as follows:
  287. WHO | Loading WHAT | HW Module | Protocol
  288. ----------+---------------+-------------+------------
  289. Boot ROM | tiboot3.bin | MCU_UART0 | X-Modem(*)
  290. R5 SPL | sysfw.itb | MCU_UART0 | Y-Modem(*)
  291. R5 SPL | tispl.bin | MAIN_UART0 | Y-Modem
  292. A53 SPL | u-boot.img | MAIN_UART0 | Y-Modem
  293. (*) Note that in addition to X/Y-Modem related protocol timeouts the DMSC
  294. watchdog timeout of 3min (typ.) needs to be observed until System Firmware
  295. is fully loaded (from sysfw.itb) and started.
  296. Example bash script sequence for running on a Linux host PC feeding all boot
  297. artifacts needed to the device:
  298. MCU_DEV=/dev/ttyUSB1
  299. MAIN_DEV=/dev/ttyUSB0
  300. stty -F $MCU_DEV 115200 cs8 -cstopb -parenb
  301. stty -F $MAIN_DEV 115200 cs8 -cstopb -parenb
  302. sb --xmodem tiboot3.bin > $MCU_DEV < $MCU_DEV
  303. sb --ymodem sysfw.itb > $MCU_DEV < $MCU_DEV
  304. sb --ymodem tispl.bin > $MAIN_DEV < $MAIN_DEV
  305. sleep 1
  306. sb --xmodem u-boot.img > $MAIN_DEV < $MAIN_DEV