README.uniphier 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. U-Boot for UniPhier SoC family
  2. ==============================
  3. Recommended toolchains
  4. ----------------------
  5. The UniPhier platform is well tested with Linaro toolchains.
  6. You can download pre-built toolchains from:
  7. http://www.linaro.org/downloads/
  8. Compile the source
  9. ------------------
  10. The source can be configured and built with the following commands:
  11. $ make <defconfig>
  12. $ make CROSS_COMPILE=<toolchain-prefix> DEVICE_TREE=<device-tree>
  13. The recommended <toolchain-prefix> is `arm-linux-gnueabihf-` for 32bit SoCs,
  14. `aarch64-linux-gnu-` for 64bit SoCs, but you may wish to change it to use your
  15. favorite compiler.
  16. The following tables show <defconfig> and <device-tree> for each board.
  17. 32bit SoC boards:
  18. Board | <defconfig> | <device-tree>
  19. ---------------|-----------------------------|------------------------------
  20. LD4 reference | uniphier_ld4_sld8_defconfig | uniphier-ld4-ref (default)
  21. sld8 reference | uniphier_ld4_sld8_defconfig | uniphier-sld8-def
  22. Pro4 reference | uniphier_v7_defconfig | uniphier-pro4-ref
  23. Pro4 Ace | uniphier_v7_defconfig | uniphier-pro4-ace
  24. Pro4 Sanji | uniphier_v7_defconfig | uniphier-pro4-sanji
  25. Pro5 4KBOX | uniphier_v7_defconfig | uniphier-pro5-4kbox
  26. PXs2 Gentil | uniphier_v7_defconfig | uniphier-pxs2-gentil
  27. PXs2 Vodka | uniphier_v7_defconfig | uniphier-pxs2-vodka (default)
  28. LD6b reference | uniphier_v7_defconfig | uniphier-ld6b-ref
  29. 64bit SoC boards:
  30. Board | <defconfig> | <device-tree>
  31. ---------------|-----------------------|----------------------------
  32. LD11 reference | uniphier_v8_defconfig | uniphier-ld11-ref
  33. LD11 Global | uniphier_v8_defconfig | uniphier-ld11-global
  34. LD20 reference | uniphier_v8_defconfig | uniphier-ld20-ref (default)
  35. LD20 Global | uniphier_v8_defconfig | uniphier-ld20-global
  36. PXs3 reference | uniphier_v8_defconfig | uniphier-pxs3-ref
  37. For example, to compile the source for PXs2 Vodka board, run the following:
  38. $ make uniphier_v7_defconfig
  39. $ make CROSS_COMPILE=arm-linux-gnueabihf- DEVICE_TREE=uniphier-pxs2-vodka
  40. The device tree marked as (default) can be omitted. `uniphier-pxs2-vodka` is
  41. the default device tree for the configuration `uniphier_v7_defconfig`, so the
  42. following gives the same result.
  43. $ make uniphier_v7_defconfig
  44. $ make CROSS_COMPILE=arm-linux-gnueabihf-
  45. Booting 32bit SoC boards
  46. ------------------------
  47. The build command will generate the following:
  48. - u-boot.bin
  49. - spl/u-boot.bin
  50. U-Boot can boot UniPhier 32bit SoC boards by itself. Flash the generated images
  51. to the storage device (NAND or eMMC) on your board.
  52. - spl/u-boot-spl.bin at the offset address 0x00000000
  53. - u-boot.bin at the offset address 0x00020000
  54. The `u-boot-with-spl.bin` is the concatenation of the two (with appropriate
  55. padding), so you can also do:
  56. - u-boot-with-spl.bin at the offset address 0x00000000
  57. If a TFTP server is available, the images can be easily updated.
  58. Just copy the u-boot-spl.bin and u-boot.bin to the TFTP public directory,
  59. and run the following command at the U-Boot command line:
  60. To update the images in NAND:
  61. => run nandupdate
  62. To update the images in eMMC:
  63. => run emmcupdate
  64. Booting 64bit SoC boards
  65. ------------------------
  66. The build command will generate the following:
  67. - u-boot.bin
  68. However, U-Boot is not the first stage loader for UniPhier 64bit SoC boards.
  69. U-Boot serves as a non-secure boot loader loaded by [ARM Trusted Firmware],
  70. so you need to provide the `u-boot.bin` to the build command of ARM Trusted
  71. Firmware.
  72. [ARM Trusted Firmware]: https://github.com/ARM-software/arm-trusted-firmware
  73. Verified Boot
  74. -------------
  75. U-Boot supports an image verification method called "Verified Boot".
  76. This is a brief tutorial to utilize this feature for the UniPhier platform.
  77. You will find details documents in the doc/uImage.FIT directory.
  78. Here, we take LD20 reference board for example, but it should work for any
  79. other boards including 32 bit SoCs.
  80. 1. Generate key to sign with
  81. $ mkdir keys
  82. $ openssl genpkey -algorithm RSA -out keys/dev.key \
  83. -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:65537
  84. $ openssl req -batch -new -x509 -key keys/dev.key -out keys/dev.crt
  85. Two files "dev.key" and "dev.crt" will be created. The base name is arbitrary,
  86. but need to match to the "key-name-hint" property described below.
  87. 2. Describe FIT source
  88. You need to write an FIT (Flattened Image Tree) source file to describe the
  89. structure of the image container.
  90. The following is an example for a simple usecase:
  91. ---------------------------------------->8----------------------------------------
  92. /dts-v1/;
  93. / {
  94. description = "Kernel, DTB and Ramdisk for UniPhier LD20 Reference Board";
  95. #address-cells = <1>;
  96. images {
  97. kernel {
  98. description = "linux";
  99. data = /incbin/("PATH/TO/YOUR/LINUX/DIR/arch/arm64/boot/Image.gz");
  100. type = "kernel";
  101. arch = "arm64";
  102. os = "linux";
  103. compression = "gzip";
  104. load = <0x82080000>;
  105. entry = <0x82080000>;
  106. hash-1 {
  107. algo = "sha256";
  108. };
  109. };
  110. fdt-1 {
  111. description = "fdt";
  112. data = /incbin/("PATH/TO/YOUR/LINUX/DIR/arch/arm64/boot/dts/socionext/uniphier-ld20-ref.dtb");
  113. type = "flat_dt";
  114. arch = "arm64";
  115. compression = "none";
  116. hash-1 {
  117. algo = "sha256";
  118. };
  119. };
  120. ramdisk {
  121. description = "ramdisk";
  122. data = /incbin/("PATH/TO/YOUR/ROOTFS/DIR/rootfs.cpio");
  123. type = "ramdisk";
  124. arch = "arm64";
  125. os = "linux";
  126. compression = "none";
  127. hash-1 {
  128. algo = "sha256";
  129. };
  130. };
  131. };
  132. configurations {
  133. default = "config-1";
  134. config-1 {
  135. description = "Configuration0";
  136. kernel = "kernel";
  137. fdt = "fdt-1";
  138. ramdisk = "ramdisk";
  139. signature-1 {
  140. algo = "sha256,rsa2048";
  141. key-name-hint = "dev";
  142. sign-images = "kernel", "fdt", "ramdisk";
  143. };
  144. };
  145. };
  146. };
  147. ---------------------------------------->8----------------------------------------
  148. You need to change the three '/incbin/' lines, depending on the location of
  149. your kernel image, device tree blob, and init ramdisk. The "load" and "entry"
  150. properties also need to be adjusted if you want to change the physical placement
  151. of the kernel.
  152. The "key-name-hint" must specify the key name you have created in the step 1.
  153. The FIT file name is arbitrary. Let's say you saved it into "fit.its".
  154. 3. Compile U-Boot with FIT and signature enabled
  155. To use the Verified Boot, you need to enable the following two options:
  156. CONFIG_FIT
  157. CONFIG_FIT_SIGNATURE
  158. They are disabled by default for UniPhier defconfig files. So, you need to
  159. tweak the configuration from "make menuconfig" or friends.
  160. $ make uniphier_v8_defconfig
  161. $ make menuconfig
  162. [ enable CONFIG_FIT and CONFIG_FIT_SIGNATURE ]
  163. $ make CROSS_COMPILE=aarch64-linux-gnu-
  164. 4. Build the image tree blob
  165. After building U-Boot, you will see tools/mkimage. With this tool, you can
  166. create an image tree blob as follows:
  167. $ tools/mkimage -f fit.its -k keys -K dts/dt.dtb -r -F fitImage
  168. The -k option must specify the key directory you have created in step 1.
  169. A file "fitImage" will be created. This includes kernel, DTB, Init-ramdisk,
  170. hash data for each of the three, and signature data.
  171. The public key needed for the run-time verification is stored in "dts/dt.dtb".
  172. 5. Compile U-Boot again
  173. Since the "dt.dtb" has been updated in step 4, you need to re-compile the
  174. U-Boot.
  175. $ make CROSS_COMPILE=aarch64-linux-gnu-
  176. The re-compiled "u-boot.bin" is appended with DTB that contains the public key.
  177. 6. Flash the image
  178. Flash the "fitImage" to a storage device (NAND, eMMC, or whatever) on your
  179. board.
  180. Please note the "u-boot.bin" must be signed, and verified by someone when it is
  181. loaded. For ARMv8 SoCs, the "someone" is generally ARM Trusted Firmware BL2.
  182. ARM Trusted Firmware supports an image authentication mechanism called Trusted
  183. Board Boot (TBB). The verification process must be chained from the moment of
  184. the system reset. If the Chain of Trust has a breakage somewhere, the verified
  185. boot process is entirely pointless.
  186. 7. Boot verified kernel
  187. Load the fitImage to memory and run the following from the U-Boot command line.
  188. > bootm <addr>
  189. Here, <addr> is the base address of the fitImage.
  190. If it is successful, you will see messages like follows:
  191. ---------------------------------------->8----------------------------------------
  192. ## Loading kernel from FIT Image at 84100000 ...
  193. Using 'config-1' configuration
  194. Verifying Hash Integrity ... sha256,rsa2048:dev+ OK
  195. Trying 'kernel' kernel subimage
  196. Description: linux
  197. Created: 2017-10-20 14:32:29 UTC
  198. Type: Kernel Image
  199. Compression: gzip compressed
  200. Data Start: 0x841000c8
  201. Data Size: 6957818 Bytes = 6.6 MiB
  202. Architecture: AArch64
  203. OS: Linux
  204. Load Address: 0x82080000
  205. Entry Point: 0x82080000
  206. Hash algo: sha256
  207. Hash value: 82a37b7f11ae55f4e07aa25bf77e4067cb9dc1014d52d6cd4d588f92eee3aaad
  208. Verifying Hash Integrity ... sha256+ OK
  209. ## Loading ramdisk from FIT Image at 84100000 ...
  210. Using 'config-1' configuration
  211. Trying 'ramdisk' ramdisk subimage
  212. Description: ramdisk
  213. Created: 2017-10-20 14:32:29 UTC
  214. Type: RAMDisk Image
  215. Compression: uncompressed
  216. Data Start: 0x847a5cc0
  217. Data Size: 5264365 Bytes = 5 MiB
  218. Architecture: AArch64
  219. OS: Linux
  220. Load Address: unavailable
  221. Entry Point: unavailable
  222. Hash algo: sha256
  223. Hash value: 44980a2874154a2e31ed59222c9f8ea968867637f35c81e4107a984de7014deb
  224. Verifying Hash Integrity ... sha256+ OK
  225. ## Loading fdt from FIT Image at 84100000 ...
  226. Using 'config-1' configuration
  227. Trying 'fdt-1' fdt subimage
  228. Description: fdt
  229. Created: 2017-10-20 14:32:29 UTC
  230. Type: Flat Device Tree
  231. Compression: uncompressed
  232. Data Start: 0x847a2cb0
  233. Data Size: 12111 Bytes = 11.8 KiB
  234. Architecture: AArch64
  235. Hash algo: sha256
  236. Hash value: c517099db537f6d325e6be46b25c871a41331ad5af0283883fd29d40bfc14e1d
  237. Verifying Hash Integrity ... sha256+ OK
  238. Booting using the fdt blob at 0x847a2cb0
  239. Uncompressing Kernel Image ... OK
  240. reserving fdt memory region: addr=80000000 size=2000000
  241. Loading Device Tree to 000000009fffa000, end 000000009fffff4e ... OK
  242. Starting kernel ...
  243. ---------------------------------------->8----------------------------------------
  244. Please pay attention to the lines that start with "Verifying Hash Integrity".
  245. "Verifying Hash Integrity ... sha256,rsa2048:dev+ OK" means the signature check
  246. passed.
  247. "Verifying Hash Integrity ... sha256+ OK" (3 times) means the hash check passed
  248. for kernel, DTB, and Init ramdisk.
  249. If they are not displayed, the Verified Boot is not working.
  250. Deployment for Distro Boot
  251. --------------------------
  252. UniPhier SoC family boot the kernel in a generic manner as described in
  253. doc/README.distro .
  254. To boot the kernel, you need to deploy necesssary components to a file
  255. system on one of your block devices (eMMC, NAND, USB drive, etc.).
  256. The components depend on the kernel image format.
  257. [1] Bare images
  258. - kernel
  259. - init ramdisk
  260. - device tree blob
  261. - boot configuration file (extlinux.conf)
  262. Here is an exmple of the configuration file.
  263. -------------------->8--------------------
  264. menu title UniPhier Boot Options.
  265. timeout 50
  266. default UniPhier
  267. label UniPhier
  268. kernel ../Image
  269. initrd ../rootfs.cpio.gz
  270. fdtdir ..
  271. -------------------->8--------------------
  272. Then, write 'Image', 'rootfs.cpio.gz', 'uniphier-ld20-ref.dtb' (DTB depends on
  273. your board), and 'extlinux/extlinux.conf' to the file system.
  274. [2] FIT
  275. - FIT blob
  276. - boot configuration file (extlinux.conf)
  277. -------------------->8--------------------
  278. menu title UniPhier Boot Options.
  279. timeout 50
  280. default UniPhier
  281. label UniPhier
  282. kernel ../fitImage
  283. -------------------->8--------------------
  284. Since the init ramdisk and DTB are contained in the FIT blob,
  285. you do not need to describe them in the configuration file.
  286. Write 'fitImage' and 'extlinux/extlinux.conf' to the file system.
  287. UniPhier specific commands
  288. --------------------------
  289. - pinmon (enabled by CONFIG_CMD_PINMON)
  290. shows the boot mode pins that has been latched at the power-on reset
  291. - ddrphy (enabled by CONFIG_CMD_DDRPHY_DUMP)
  292. shows the DDR PHY parameters set by the PHY training
  293. - ddrmphy (enabled by CONFIG_CMD_DDRMPHY_DUMP)
  294. shows the DDR Multi PHY parameters set by the PHY training
  295. Supported devices
  296. -----------------
  297. - UART (on-chip)
  298. - NAND
  299. - SD/eMMC
  300. - USB 2.0 (EHCI)
  301. - USB 3.0 (xHCI)
  302. - GPIO
  303. - LAN (on-board SMSC9118)
  304. - I2C
  305. - EEPROM (connected to the on-board I2C bus)
  306. - Support card (SRAM, NOR flash, some peripherals)
  307. Micro Support Card
  308. ------------------
  309. The recommended bit switch settings are as follows:
  310. SW2 OFF(1)/ON(0) Description
  311. ------------------------------------------
  312. bit 1 <---- BKSZ[0]
  313. bit 2 ----> BKSZ[1]
  314. bit 3 <---- SoC Bus Width 16/32
  315. bit 4 <---- SERIAL_SEL[0]
  316. bit 5 ----> SERIAL_SEL[1]
  317. bit 6 ----> BOOTSWAP_EN
  318. bit 7 <---- CS1/CS5
  319. bit 8 <---- SOC_SERIAL_DISABLE
  320. SW8 OFF(1)/ON(0) Description
  321. ------------------------------------------
  322. bit 1 <---- CS1_SPLIT
  323. bit 2 <---- CASE9_ON
  324. bit 3 <---- CASE10_ON
  325. bit 4 Don't Care Reserve
  326. bit 5 Don't Care Reserve
  327. bit 6 Don't Care Reserve
  328. bit 7 ----> BURST_EN
  329. bit 8 ----> FLASHBUS32_16
  330. The BKSZ[1:0] specifies the address range of memory slot and peripherals
  331. as follows:
  332. BKSZ Description RAM slot Peripherals
  333. --------------------------------------------------------------------
  334. 0b00 15MB RAM / 1MB Peri 00000000-00efffff 00f00000-00ffffff
  335. 0b01 31MB RAM / 1MB Peri 00000000-01efffff 01f00000-01ffffff
  336. 0b10 64MB RAM / 1MB Peri 00000000-03efffff 03f00000-03ffffff
  337. 0b11 127MB RAM / 1MB Peri 00000000-07efffff 07f00000-07ffffff
  338. Set BSKZ[1:0] to 0b01 for U-Boot.
  339. This mode is the most handy because EA[24] is always supported by the save pin
  340. mode of the system bus. On the other hand, EA[25] is not supported for some
  341. newer SoCs. Even if it is, EA[25] is not connected on most of the boards.
  342. --
  343. Masahiro Yamada <yamada.masahiro@socionext.com>
  344. Oct. 2017