boot-flow.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. .. SPDX-License-Identifier: GPL-2.0+
  2. Amlogic SoC Boot Flow
  3. =====================
  4. Amlogic SoCs follow a pre-defined boot sequence stored in SoC ROM code. The possible boot
  5. sequences of the different SoC families are:
  6. GX* & AXG Family
  7. ----------------
  8. +----------+-------------------+---------+---------+---------+---------+
  9. | | 1 | 2 | 3 | 4 | 5 |
  10. +==========+===================+=========+=========+=========+=========+
  11. | S905 | POC=0: SPI NOR | eMMC | NAND | SD | USB |
  12. | S905D | | | | | |
  13. | S905L | | | | | |
  14. | S905W | | | | | |
  15. | S905X | | | | | |
  16. | S905Y | | | | | |
  17. | S912 | | | | | |
  18. +----------+-------------------+---------+---------+---------+---------+
  19. | S805X | POC=0: SPI NOR | eMMC | NAND | USB | - |
  20. | A113D | | | | | |
  21. | A113X | | | | | |
  22. +----------+-------------------+---------+---------+---------+---------+
  23. POC pin: `NAND_CLE`
  24. Some boards provide a button to force USB boot by disabling the eMMC clock signal and
  25. allowing the eMMC step to be bypassed. Others have removable eMMC modules; removing an
  26. eMMC module and SD card will allow boot from USB.
  27. An exception is the Libre Computer AML-S805X-XX (LaFrite) board which has no SD card
  28. slot and boots from SPI. Booting a LaFrite board from USB requires either:
  29. - Erasing the first sectors of SPI NOR flash
  30. - Inserting an HDMI boot plug forcing boot over USB
  31. The VIM1 and initial VIM2 boards provide a test point on the eMMC signals to block the
  32. storage from answering, allowing boot to continue with the next boot step.
  33. USB boot uses the first USB interface. On some boards this port is only available on a
  34. USB-A type connector and requires a special Type-A to Type-A cable to communicate with
  35. the BootROM.
  36. G12* & SM1 Family
  37. -----------------
  38. +-------+-------+-------+------------+------------+------------+-----------+
  39. | POC0 | POC1 | POC2 | 1 | 2 | 3 | 4 |
  40. +=======+=======+=======+============+============+============+===========+
  41. | 0 | 0 | 0 | USB | SPI-NOR | NAND/eMMC | SD |
  42. +-------+-------+-------+------------+------------+-------------+----------+
  43. | 0 | 0 | 1 | USB | NAND/eMMC | SD | - |
  44. +-------+-------+-------+------------+------------+------------+-----------+
  45. | 0 | 1 | 0 | SPI-NOR | NAND/eMMC | SD | USB |
  46. +-------+-------+-------+------------+------------+------------+-----------+
  47. | 0 | 1 | 1 | SPI-NAND | NAND/eMMC | USB | - |
  48. +-------+-------+-------+------------+------------+------------+-----------+
  49. | 1 | 0 | 0 | USB | SPI-NOR | NAND/eMMC | SD |
  50. +-------+-------+-------+------------+------------+------------+-----------+
  51. | 1 | 0 | 1 | USB | NAND/eMMC | SD | - |
  52. +-------+-------+-------+------------+------------+------------+-----------+
  53. | 1 | 1 | 0 | SPI-NOR | NAND/eMMC | SD | USB |
  54. +-------+-------+-------+------------+------------+------------+-----------+
  55. | 1 | 1 | 1 | NAND/eMMC | SD | USB | - |
  56. +-------+-------+-------+------------+------------+------------+-----------+
  57. The last option (1/1/1) is the normal default seen on production devices:
  58. * POC0 pin: `BOOT_4` (0 and all other 1 means SPI NAND boot first)
  59. * POC1 pin: `BOOT_5` (0 and all other 1 means USB Device boot first
  60. * POC2 pin: `BOOT_6` (0 and all other 1 means SPI NOR boot first)
  61. Most boards provide a button to force USB BOOT which lowers `BOOT_5` to 0. Some boards
  62. provide a test point on eMMC or SPI NOR clock signals to block storage from answering
  63. and allowing boot to continue from the next boot step.
  64. The Khadas VIM3/3L boards embed a microcontroller which sets POC signals according to
  65. its configuration or a specific key press sequence to either boot from SPI NOR or eMMC
  66. then SD card, or boot as a USB device.
  67. The Odroid N2/N2+ has a hardware switch to select between SPI NOR or eMMC boot. The
  68. Odroid HC4 has a button to disable SPI-NOR allowing boot from SD card.
  69. Boot Modes
  70. ----------
  71. * SD
  72. The BootROM fetches the first SD card sectors in one sequence then checks the content of
  73. the data. It expects to find the FIP binary in sector 1, 512 bytes offset from the start.
  74. * eMMC
  75. The BootROM fetches the first sectors of the main partition in one sequence then checks
  76. the content of the data. On GXL and newer boards it expects to find the FIP binary in
  77. sector 1, 512 bytes offset from the start. If not found it checks the boot0 partition,
  78. then the boot1 partition. On GXBB it expects to find the FIP binary at an offset that
  79. conflicts with MBR partition tables, but this has been worked around (thus avoiding the
  80. need for a partition scheme that relocates the MBR). For a more detailed explanation
  81. please see: https://github.com/LibreELEC/amlogic-boot-fip/pull/8
  82. * SPI-NOR
  83. The BootROM fetches the first SPI NOR sectors in one sequence then checks the content of
  84. the data. It expects to find the FIP binary in sector 1, 512 bytes offset from the start.
  85. * NAND & SPI-NAND
  86. These modes are rarely used in open platforms and no details are available.
  87. * USB
  88. The BootROM supports a custom USB protocol and sets the USB Gadget interface to use the
  89. USB ID 1b8e:c003. The Amlogic `update` utility uses this protocol. It is also supported
  90. in the Amlogic vendor U-Boot sources.
  91. The `pyamlboot` utility https://github.com/superna9999/pyamlboot is open-source and also
  92. implements the USB protocol. It can load U-Boot into memory to start the SoC without the
  93. storage being attached, or to recover the device from a failed/incorrect image flash.
  94. HDMI Recovery Dongle
  95. --------------------
  96. The BootROM also reads 8 bytes at address I2C 0x52 offset 0xf8 (248) on the HDMI DDC bus
  97. during startup. The content `boot@USB` forces USB boot. The content `boot@SDC` forces SD
  98. card boot. The content `boot@SPI` forces SPI-NOT boot. If an SD card or USB device does
  99. not enumerate the BootROM continues with the normal boot sequence.
  100. HDMI boot dongles can be created by connecting a 256bytes EEPROM set to answer on address
  101. 0x52, with `boot@USB` or `boot@SDC` or `boot@SPI` programmed at offset 0xf8 (248).
  102. If the SoC is booted with USB Device forced at first step, it will retain the forced boot
  103. order on warm reboot. Only cold reboot (removing power) will reset the boot order.