khadas-vim3.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. U-Boot for Khadas VIM3 (A311D)
  3. ==============================
  4. Khadas VIM3 is a Single Board Computer manufactured by Shenzhen Wesion Technology Co. Ltd
  5. 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 on-board MCU can mux the PCIe/USB3.0 shared differential lines using a FUSB340TMX USB
  19. 3.1 SuperSpeed Data Switch between a USB3.0 Type-A connector and an M.2 Key M slot. The
  20. PHY driving these differential lines is shared between the USB3.0 controller and the PCIe
  21. Controller, thus only a single controller can use it.
  22. To setup for PCIe run the following commands from U-Boot then power-cycle the board:
  23. .. code-block:: none
  24. i2c dev i2c@5000
  25. i2c mw 0x18 0x33 1
  26. To revert to USB3.0 run the following commands from U-Boot then power-cycle the board:
  27. .. code-block:: none
  28. i2c dev i2c@5000
  29. i2c mw 0x18 0x33 0
  30. U-Boot Compilation
  31. ------------------
  32. .. code-block:: bash
  33. $ export CROSS_COMPILE=aarch64-none-elf-
  34. $ make khadas-vim3_defconfig
  35. $ make
  36. U-Boot Signing with Pre-Built FIP repo
  37. --------------------------------------
  38. .. code-block:: bash
  39. $ git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1
  40. $ cd amlogic-boot-fip
  41. $ mkdir my-output-dir
  42. $ ./build-fip.sh khadas-vim3 /path/to/u-boot/u-boot.bin my-output-dir
  43. U-Boot Manual Signing
  44. ---------------------
  45. Amlogic does not provide sources for the firmware and tools needed to create a bootloader
  46. image so it is necessary to obtain binaries from sources published by the board vendor:
  47. .. code-block:: bash
  48. $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  49. $ wget https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  50. $ tar xvfJ gcc-linaro-aarch64-none-elf-4.8-2013.11_linux.tar.xz
  51. $ tar xvfJ gcc-linaro-arm-none-eabi-4.8-2013.11_linux.tar.xz
  52. $ 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
  53. $ DIR=vim3-u-boot
  54. $ git clone --depth 1 https://github.com/khadas/u-boot.git -b khadas-vims-v2015.01 $DIR
  55. $ cd vim3-u-boot
  56. $ make kvim3_defconfig
  57. $ make CROSS_COMPILE=aarch64-none-elf-
  58. $ export UBOOTDIR=$PWD
  59. Go back to the mainline U-Boot source tree then:
  60. .. code-block:: bash
  61. $ mkdir fip
  62. $ wget https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/blx_fix_g12a.sh -O fip/blx_fix.sh
  63. $ cp $UBOOTDIR/build/scp_task/bl301.bin fip/
  64. $ cp $UBOOTDIR/build/board/khadas/kvim3/firmware/acs.bin fip/
  65. $ cp $UBOOTDIR/fip/g12b/bl2.bin fip/
  66. $ cp $UBOOTDIR/fip/g12b/bl30.bin fip/
  67. $ cp $UBOOTDIR/fip/g12b/bl31.img fip/
  68. $ cp $UBOOTDIR/fip/g12b/ddr3_1d.fw fip/
  69. $ cp $UBOOTDIR/fip/g12b/ddr4_1d.fw fip/
  70. $ cp $UBOOTDIR/fip/g12b/ddr4_2d.fw fip/
  71. $ cp $UBOOTDIR/fip/g12b/diag_lpddr4.fw fip/
  72. $ cp $UBOOTDIR/fip/g12b/lpddr3_1d.fw fip/
  73. $ cp $UBOOTDIR/fip/g12b/lpddr4_1d.fw fip/
  74. $ cp $UBOOTDIR/fip/g12b/lpddr4_2d.fw fip/
  75. $ cp $UBOOTDIR/fip/g12b/piei.fw fip/
  76. $ cp $UBOOTDIR/fip/g12b/aml_ddr.fw fip/
  77. $ cp u-boot.bin fip/bl33.bin
  78. $ bash fip/blx_fix.sh \
  79. fip/bl30.bin \
  80. fip/zero_tmp \
  81. fip/bl30_zero.bin \
  82. fip/bl301.bin \
  83. fip/bl301_zero.bin \
  84. fip/bl30_new.bin \
  85. bl30
  86. $ bash fip/blx_fix.sh \
  87. fip/bl2.bin \
  88. fip/zero_tmp \
  89. fip/bl2_zero.bin \
  90. fip/acs.bin \
  91. fip/bl21_zero.bin \
  92. fip/bl2_new.bin \
  93. bl2
  94. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl30sig --input fip/bl30_new.bin \
  95. --output fip/bl30_new.bin.g12a.enc \
  96. --level v3
  97. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl30_new.bin.g12a.enc \
  98. --output fip/bl30_new.bin.enc \
  99. --level v3 --type bl30
  100. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl31.img \
  101. --output fip/bl31.img.enc \
  102. --level v3 --type bl31
  103. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl3sig --input fip/bl33.bin --compress lz4 \
  104. --output fip/bl33.bin.enc \
  105. --level v3 --type bl33 --compress lz4
  106. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bl2sig --input fip/bl2_new.bin \
  107. --output fip/bl2.n.bin.sig
  108. $ $UBOOTDIR/fip/g12b/aml_encrypt_g12b --bootmk \
  109. --output fip/u-boot.bin \
  110. --bl2 fip/bl2.n.bin.sig \
  111. --bl30 fip/bl30_new.bin.enc \
  112. --bl31 fip/bl31.img.enc \
  113. --bl33 fip/bl33.bin.enc \
  114. --ddrfw1 fip/ddr4_1d.fw \
  115. --ddrfw2 fip/ddr4_2d.fw \
  116. --ddrfw3 fip/ddr3_1d.fw \
  117. --ddrfw4 fip/piei.fw \
  118. --ddrfw5 fip/lpddr4_1d.fw \
  119. --ddrfw6 fip/lpddr4_2d.fw \
  120. --ddrfw7 fip/diag_lpddr4.fw \
  121. --ddrfw8 fip/aml_ddr.fw \
  122. --ddrfw9 fip/lpddr3_1d.fw \
  123. --level v3
  124. Then write U-Boot to SD or eMMC with:
  125. .. code-block:: bash
  126. $ DEV=/dev/boot_device
  127. $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=512 skip=1 seek=1
  128. $ dd if=fip/u-boot.bin.sd.bin of=$DEV conv=fsync,notrunc bs=1 count=440