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