blob: 041297c512cba999c15305865a628cfb4eb30290 [file] [log] [blame]
Neil Armstrong85c4a522022-07-06 11:36:49 +02001.. SPDX-License-Identifier: GPL-2.0+
2
3Amlogic SoC Boot Flow
4=====================
5
Christian Hewitt68abb312023-03-20 11:45:38 +00006Amlogic SoCs follow a pre-defined boot sequence stored in SoC ROM code. The possible boot
7sequences of the different SoC families are:
Neil Armstrong85c4a522022-07-06 11:36:49 +02008
Christian Hewitt68abb312023-03-20 11:45:38 +00009GX* & AXG Family
Neil Armstrong85c4a522022-07-06 11:36:49 +020010----------------
11
Christian Hewitt68abb312023-03-20 11:45:38 +000012+----------+-------------------+---------+---------+---------+---------+
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 Armstrong85c4a522022-07-06 11:36:49 +020027
28POC pin: `NAND_CLE`
29
Christian Hewitt68abb312023-03-20 11:45:38 +000030Some boards provide a button to force USB boot by disabling the eMMC clock signal and
31allowing the eMMC step to be bypassed. Others have removable eMMC modules; removing an
32eMMC module and SD card will allow boot from USB.
Neil Armstrong85c4a522022-07-06 11:36:49 +020033
Christian Hewitt68abb312023-03-20 11:45:38 +000034An exception is the Libre Computer AML-S805X-XX (LaFrite) board which has no SD card
35slot and boots from SPI. Booting a LaFrite board from USB requires either:
Neil Armstrong85c4a522022-07-06 11:36:49 +020036
Christian Hewitt68abb312023-03-20 11:45:38 +000037 - Erasing the first sectors of SPI NOR flash
38 - Inserting an HDMI boot plug forcing boot over USB
Neil Armstrong85c4a522022-07-06 11:36:49 +020039
Christian Hewitt68abb312023-03-20 11:45:38 +000040The VIM1 and initial VIM2 boards provide a test point on the eMMC signals to block the
41storage from answering, allowing boot to continue with the next boot step.
Neil Armstrong85c4a522022-07-06 11:36:49 +020042
Christian Hewitt68abb312023-03-20 11:45:38 +000043USB boot uses the first USB interface. On some boards this port is only available on a
44USB-A type connector and requires a special Type-A to Type-A cable to communicate with
45the BootROM.
Neil Armstrong85c4a522022-07-06 11:36:49 +020046
Christian Hewitt68abb312023-03-20 11:45:38 +000047G12* & SM1 Family
Neil Armstrong85c4a522022-07-06 11:36:49 +020048-----------------
49
Christian Hewitt68abb312023-03-20 11:45:38 +000050+-------+-------+-------+------------+------------+------------+-----------+
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 Armstrong85c4a522022-07-06 11:36:49 +020069
Christian Hewitt68abb312023-03-20 11:45:38 +000070The last option (1/1/1) is the normal default seen on production devices:
Neil Armstrong85c4a522022-07-06 11:36:49 +020071
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
76Most boards provide a button to force USB BOOT which lowers `BOOT_5` to 0. Some boards
Christian Hewitt68abb312023-03-20 11:45:38 +000077provide a test point on eMMC or SPI NOR clock signals to block storage from answering
78and allowing boot to continue from the next boot step.
Neil Armstrong85c4a522022-07-06 11:36:49 +020079
Christian Hewitt68abb312023-03-20 11:45:38 +000080The Khadas VIM3/3L boards embed a microcontroller which sets POC signals according to
81its configuration or a specific key press sequence to either boot from SPI NOR or eMMC
82then SD card, or boot as a USB device.
Neil Armstrong85c4a522022-07-06 11:36:49 +020083
Christian Hewitt68abb312023-03-20 11:45:38 +000084The Odroid N2/N2+ has a hardware switch to select between SPI NOR or eMMC boot. The
85Odroid HC4 has a button to disable SPI-NOR allowing boot from SD card.
Neil Armstrong85c4a522022-07-06 11:36:49 +020086
87Boot Modes
88----------
89
Christian Hewitt68abb312023-03-20 11:45:38 +000090 * SD
Neil Armstrong85c4a522022-07-06 11:36:49 +020091
Christian Hewitt68abb312023-03-20 11:45:38 +000092The BootROM fetches the first SD card sectors in one sequence then checks the content of
93the data. It expects to find the FIP binary in sector 1, 512 bytes offset from the start.
Neil Armstrong85c4a522022-07-06 11:36:49 +020094
95 * eMMC
96
Christian Hewitt68abb312023-03-20 11:45:38 +000097The BootROM fetches the first sectors of the main partition in one sequence then checks
98the content of the data. On GXL and newer boards it expects to find the FIP binary in
99sector 1, 512 bytes offset from the start. If not found it checks the boot0 partition,
100then the boot1 partition. On GXBB it expects to find the FIP binary at an offset that
101conflicts with MBR partition tables, but this has been worked around (thus avoiding the
102need for a partition scheme that relocates the MBR). For a more detailed explanation
103please see: https://github.com/LibreELEC/amlogic-boot-fip/pull/8
Neil Armstrong85c4a522022-07-06 11:36:49 +0200104
Christian Hewitt68abb312023-03-20 11:45:38 +0000105 * SPI-NOR
Neil Armstrong85c4a522022-07-06 11:36:49 +0200106
Christian Hewitt68abb312023-03-20 11:45:38 +0000107The BootROM fetches the first SPI NOR sectors in one sequence then checks the content of
108the data. It expects to find the FIP binary in sector 1, 512 bytes offset from the start.
Neil Armstrong85c4a522022-07-06 11:36:49 +0200109
Christian Hewitt68abb312023-03-20 11:45:38 +0000110 * NAND & SPI-NAND
Neil Armstrong85c4a522022-07-06 11:36:49 +0200111
112These modes are rarely used in open platforms and no details are available.
113
Christian Hewitt68abb312023-03-20 11:45:38 +0000114 * USB
Neil Armstrong85c4a522022-07-06 11:36:49 +0200115
Christian Hewitt68abb312023-03-20 11:45:38 +0000116The BootROM supports a custom USB protocol and sets the USB Gadget interface to use the
117USB ID 1b8e:c003. The Amlogic `update` utility uses this protocol. It is also supported
118in the Amlogic vendor U-Boot sources.
Neil Armstrong85c4a522022-07-06 11:36:49 +0200119
Christian Hewitt68abb312023-03-20 11:45:38 +0000120The `pyamlboot` utility https://github.com/superna9999/pyamlboot is open-source and also
121implements the USB protocol. It can load U-Boot into memory to start the SoC without the
122storage being attached, or to recover the device from a failed/incorrect image flash.
Neil Armstrong85c4a522022-07-06 11:36:49 +0200123
Christian Hewitt68abb312023-03-20 11:45:38 +0000124HDMI Recovery Dongle
125--------------------
Neil Armstrong85c4a522022-07-06 11:36:49 +0200126
Christian Hewitt68abb312023-03-20 11:45:38 +0000127The BootROM also reads 8 bytes at address I2C 0x52 offset 0xf8 (248) on the HDMI DDC bus
128during startup. The content `boot@USB` forces USB boot. The content `boot@SDC` forces SD
129card boot. The content `boot@SPI` forces SPI-NOT boot. If an SD card or USB device does
130not enumerate the BootROM continues with the normal boot sequence.
Neil Armstrong85c4a522022-07-06 11:36:49 +0200131
Christian Hewitt68abb312023-03-20 11:45:38 +0000132HDMI boot dongles can be created by connecting a 256bytes EEPROM set to answer on address
1330x52, with `boot@USB` or `boot@SDC` or `boot@SPI` programmed at offset 0xf8 (248).
Neil Armstrong85c4a522022-07-06 11:36:49 +0200134
Christian Hewitt68abb312023-03-20 11:45:38 +0000135If the SoC is booted with USB Device forced at first step, it will retain the forced boot
136order on warm reboot. Only cold reboot (removing power) will reset the boot order.