khadas-vim3.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. U-Boot for Khadas VIM3
  3. ======================
  4. Khadas VIM3 is a single board computer manufactured by Shenzhen Wesion
  5. Technology Co., Ltd. with the following specifications:
  6. - Amlogic A311D Arm Cortex-A53 dual-core + Cortex-A73 quad-core SoC
  7. - 4GB LPDDR4 SDRAM
  8. - Gigabit Ethernet
  9. - HDMI 2.1 display
  10. - 40-pin GPIO header
  11. - 1 x USB 3.0 Host, 1 x USB 2.0 Host
  12. - eMMC, microSD
  13. - M.2
  14. - Infrared receiver
  15. Schematics are available on the manufacturer website.
  16. PCIe Setup
  17. ----------
  18. The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential
  19. lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between
  20. an USB3.0 Type A connector and a M.2 Key M slot.
  21. The PHY driving these differential lines is shared between
  22. the USB3.0 controller and the PCIe Controller, thus only
  23. a single controller can use it.
  24. To setup for PCIe, run the following commands from U-Boot:
  25. .. code-block:: none
  26. i2c dev i2c@5000
  27. i2c mw 0x18 0x33 1
  28. Then power-cycle the board.
  29. To set back to USB3.0, run the following commands from U-Boot:
  30. .. code-block:: none
  31. i2c dev i2c@5000
  32. i2c mw 0x18 0x33 0
  33. Then power-cycle the board.
  34. U-Boot compilation
  35. ------------------
  36. .. code-block:: bash
  37. $ export CROSS_COMPILE=aarch64-none-elf-
  38. $ make khadas-vim3_defconfig
  39. $ make
  40. Image creation
  41. --------------
  42. Amlogic doesn't provide sources for the firmware and for tools needed
  43. to create the bootloader image, so it is necessary to obtain them from
  44. the git tree published by the board vendor:
  45. .. code-block:: bash
  46. $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  47. $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  48. $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  49. $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  50. $ export PATH=$PWD/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin:$PWD/gcc-linaro-arm-none-eabi-4.8-2013.11_linux/bin:$PATH
  51. $ DIR=vim3-u-boot
  52. $ git clone --depth 1 \
  53. https://github.com/khadas/u-boot.git -b khadas-vims-v2015.01 \
  54. $DIR
  55. $ cd vim3-u-boot
  56. $ make kvim3_defconfig
  57. $ make
  58. $ export UBOOTDIR=$PWD
  59. Go back to mainline U-Boot source tree then :
  60. .. code-block:: bash
  61. $ mkdir fip
  62. $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
  63. $ cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/
  64. $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
  65. $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/
  66. $ cp $UBOOTDIR/fip/g12b/bl31.img fip/
  67. $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
  68. $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
  69. $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
  70. $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
  71. $ cp $UBOOTDIR/fip/g12b/lpddr3_1d.fw fip/
  72. $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
  73. $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
  74. $ cp $UBOOTDIR/fip/g12b/piei.fw fip/
  75. $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
  76. $ cp u-boot.bin fip/bl33.bin
  77. $ sh fip/blx_fix.sh \
  78. fip/bl30.bin \
  79. fip/zero_tmp \
  80. fip/bl30_zero.bin \
  81. fip/bl301.bin \
  82. fip/bl301_zero.bin \
  83. fip/bl30_new.bin \
  84. bl30
  85. $ sh fip/blx_fix.sh \
  86. fip/bl2.bin \
  87. fip/zero_tmp \
  88. fip/bl2_zero.bin \
  89. fip/acs.bin \
  90. fip/bl21_zero.bin \
  91. fip/bl2_new.bin \
  92. bl2
  93. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
  94. --output fip/bl30_new.bin.g12a.enc \
  95. --level v3
  96. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
  97. --output fip/bl30_new.bin.enc \
  98. --level v3 --type bl30
  99. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
  100. --output fip/bl31.img.enc \
  101. --level v3 --type bl31
  102. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
  103. --output fip/bl33.bin.enc \
  104. --level v3 --type bl33 --compress lz4
  105. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
  106. --output fip/bl2.n.bin.sig
  107. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
  108. --output fip/u-boot.bin \
  109. --bl2 fip/bl2.n.bin.sig \
  110. --bl30 fip/bl30_new.bin.enc \
  111. --bl31 fip/bl31.img.enc \
  112. --bl33 fip/bl33.bin.enc \
  113. --ddrfw1 fip/ddr4_1d.fw \
  114. --ddrfw2 fip/ddr4_2d.fw \
  115. --ddrfw3 fip/ddr3_1d.fw \
  116. --ddrfw4 fip/piei.fw \
  117. --ddrfw5 fip/lpddr4_1d.fw \
  118. --ddrfw6 fip/lpddr4_2d.fw \
  119. --ddrfw7 fip/diag_lpddr4.fw \
  120. --ddrfw8 fip/aml_ddr.fw \
  121. --ddrfw9 fip/lpddr3_1d.fw \
  122. --level v3
  123. and then write the image to SD with:
  124. .. code-block:: bash
  125. $ DEV=/dev/your_sd_device
  126. $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
  127. $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=444