This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
products:sbc:edge2:hardware:edge2-boot-flow [2023/02/27 22:12] hyphop |
products:sbc:edge2:hardware:edge2-boot-flow [2023/05/17 07:14] hyphop [Reboot from SPI flash U-Boot via i2c command] |
||
---|---|---|---|
Line 3: | Line 3: | ||
====== Edge2 Boot flow ====== | ====== Edge2 Boot flow ====== | ||
- | Edge2 have advanced and flexible | + | [[:Edge2]] have advanced and flexible |
- | MCU => BROM => [[# | + | MCU => BROM => [[# |
Line 15: | Line 15: | ||
====== Hardware buttons ====== | ====== Hardware buttons ====== | ||
- | WIP: | + | |
- | + | ||
- | | + | |
* '' | * '' | ||
- | * '' | + | * '' |
More detail: [[./ | More detail: [[./ | ||
| | ||
- | ====== Bootmode ======= | ||
- | '' | + | ====== MCU features ====== |
- | ^ bootmode | + | See too: [[# |
+ | |||
+ | ===== Boot mode ====== | ||
+ | |||
+ | Common boot mode configuration '' | ||
+ | |||
+ | ^ boot mode ^ value ^ | ||
| spi | 0 | | | spi | 0 | | ||
| mmc | 1 | | | mmc | 1 | | ||
- | ====== OOWOW mode ======= | ||
- | '' | + | ```sh boot-mode read |
+ | i2cget -f -y 2 0x18 0x20 | ||
+ | ``` | ||
+ | |||
+ | ===== Boot flag ====== | ||
+ | |||
+ | This flag '' | ||
- | ^ oowow_mode | + | ^ boot flag ^ value ^ |
| disabled | | disabled | ||
- | | request | + | | [[/ |
- | | activated | + | | boot from SPI |
- | | passed | + | | boot from eMMC |3 | |
- | | rescue | + | |
- | ====== Reboot modes by MCU ======= | ||
- | '' | + | ```sh boot-flag read |
+ | i2cget | ||
+ | ``` | ||
+ | |||
+ | <WRAP important > | ||
+ | boot-flag will be used only one time and after reboot will be masked by '' | ||
+ | </ | ||
+ | |||
+ | ^ boot flag note ^ mask ^ | ||
+ | | spl mask |0x50 | | ||
+ | | oowow mask |0xA0 | | ||
- | ^ oowow_mode | ||
- | | spi |0 | | ||
- | | mmc |1 | | ||
- | | default reboot |2 | | ||
<WRAP important > | <WRAP important > | ||
- | At this moment all modes works same as '' | + | boot-flag value '' |
</ | </ | ||
- | + | ===== Reboot mode ====== | |
+ | |||
+ | We can reboot device by non standard way via MCU '' | ||
+ | |||
+ | ^ reboot mode ^ value ^ | ||
+ | | SPI | ||
+ | | normal reboot | ||
+ | | eMMC |2 | | ||
+ | |||
+ | ```sh reboot-mode read | ||
+ | i2cset -f -y 2 0x18 0x91 value | ||
+ | ``` | ||
+ | |||
+ | <WRAP important > | ||
+ | Device will be rebooted immediately after successful writing to '' | ||
+ | </ | ||
+ | |||
+ | <WRAP important > | ||
+ | Only '' | ||
+ | '' | ||
+ | '' | ||
+ | </ | ||
+ | |||
+ | |||
+ | See too: [[# | ||
====== Boot modes oowow shell usage ====== | ====== Boot modes oowow shell usage ====== | ||
WIP: | WIP: | ||
- | ==== Set boot mode ==== | + | ==== Boot mode setup examples |
```shell | ```shell | ||
+ | |||
+ | ## read current boot-mode | ||
+ | |||
~# bootmode | ~# bootmode | ||
spi | spi | ||
+ | |||
+ | ## setup to MMC | ||
~# bootmode mmc | ~# bootmode mmc | ||
Line 71: | Line 112: | ||
~# bootmode | ~# bootmode | ||
mmc | mmc | ||
+ | |||
+ | ## setup to SPI | ||
~# bootmode spi | ~# bootmode spi | ||
Line 104: | Line 147: | ||
``` | ``` | ||
- | ==== Reboot by MCU ==== | + | ==== Reboot by MCU examples |
Forced hardware reboot | Forced hardware reboot | ||
```shell | ```shell | ||
+ | ## oowow shell | ||
~# mcu_reboot | ~# mcu_reboot | ||
- | ~# i2cset -f -y 2 0x18 0x91 2 | + | ## common system |
+ | ~# i2cset -f -y 2 0x18 0x91 1 | ||
``` | ``` | ||
+ | |||
+ | ==== Reboot into OOWOW via i2c command ==== | ||
+ | |||
+ | ```sh reboot into oowow | ||
+ | i2cset -f -y 2 0x18 0x92 1 | ||
+ | i2cset -f -y 2 0x18 0x91 1 | ||
+ | ``` | ||
+ | |||
+ | ==== Reboot from SPI flash U-Boot via i2c command ==== | ||
+ | |||
+ | ```sh reset and use u-boot from spi flash | ||
+ | i2cset -f -y 2 0x18 0x91 0 | ||
+ | ``` | ||
+ | |||
+ | <WRAP important > | ||
+ | In this case U-boot will be started from SPI flash, next booting will in same u-boot prio '' | ||
+ | </ | ||
====== SPL stage ====== | ====== SPL stage ====== | ||
Line 122: | Line 184: | ||
</ | </ | ||
- | Boot mode '' | + | Boot mode '' |
+ | ====== U-Boot stage ====== | ||
- | ```log | + | Current |
- | U-Boot SPL board init | + | ===== oowow spi uboot ===== |
- | U-Boot SPL 2017.09 (Sep 15 2022 - 14:38:28) | + | |
- | MCU: bootmode: 1, oowow 3 | + | ```shell boot_targets |
- | MCU: oowow 0 | + | kedge2# printenv boot_targets |
- | board_boot_order: | + | boot_targets=usb0 mmc1 mmc0 pxe dhcp fail |
- | !!! same-as-spl: | + | |
- | !!! / | + | |
- | !!! / | + | |
- | !!! /spi@fe2b0000/ | + | |
- | Trying to boot from MMC2 :: 0 | + | |
- | Card did not respond to voltage select! | + | |
- | mmc_init: -95, time 12 | + | |
- | spl: mmc init failed with error: -95 | + | |
- | Trying to boot from MMC1 :: 1 | + | |
- | Trying fit image at 0x4000 sector | + | |
``` | ``` | ||
- | Boot mode '' | + | ===== mmc uboot ===== |
- | ```log | + | default eMMC u-boot log for Ubuntu images |
- | U-Boot SPL board init | + | |
- | U-Boot SPL 2017.09 (Sep 15 2022 - 14:38:28) | + | ```shell boot_targets |
- | MCU: bootmode: 0, oowow 3 | + | kedge2# printenv boot_targets |
- | MCU: oowow 0 | + | boot_targets=usb0 mmc1 mmc0 pxe dhcp |
- | board_boot_order: | + | |
- | !!! same-as-spl: | + | |
- | board_spl_was_booted_from: | + | |
- | +++ / | + | |
- | !!! / | + | |
- | !!! / | + | |
- | !!! / | + | |
- | Trying to boot from MTD2 :: 0 | + | |
- | Trying fit image at 0x300 sector | + | |
``` | ``` | ||
- | Boot [[:OOWOW:]] - hold '' | ||
- | ```log u-boot-spl-oowow-mode.log | ||
- | U-Boot SPL board init | ||
- | U-Boot SPL 2017.09 (Sep 15 2022 - 14:38:28) | ||
- | MCU: bootmode: 0, oowow 1 | ||
- | MCU: oowow 2 | ||
- | board_boot_order: | ||
- | !!! same-as-spl: | ||
- | +++ / | ||
- | !!! / | ||
- | !!! / | ||
- | !!! / | ||
- | Trying to boot from MTD2 :: 0 | ||
- | Trying fit image at 0x300 sector | ||
- | ``` | ||
- | Boot SPL from eMMC: | + | ====== Advanced ====== |
- | ```log u-boot-spl-mmc.log | + | ===== MCU registers annotation ===== |
- | U-Boot SPL board init | ||
- | U-Boot SPL 2017.09 (Oct 18 2022 - 20:45:10) | ||
- | Trying to boot from MMC2 | ||
- | Card did not respond to voltage select! | ||
- | mmc_init: -95, time 12 | ||
- | spl: mmc init failed with error: -95 | ||
- | Trying to boot from MMC1 | ||
- | spl: partition error | ||
- | Trying fit image at 0x4000 sector | ||
``` | ``` | ||
+ | MCU version: 02 & 03 | ||
- | Boot SPL from eMMC boot oowow u-boot from SD: | + | 0x91 REBOOT_MODE |
+ | 0 - reset and boot from SPI | ||
+ | 1 - reset normal | ||
+ | 2 - reset and boot from eMMC | ||
- | ```log u-boot-spl-mmc-sd-oowow.log | + | 0x92 BOOT_FLAG |
- | + | 0 - normal | |
- | U-Boot SPL board init | + | 1 - press FUNC boot-up |
- | U-Boot SPL 2017.09 (Oct 18 2022 - 20:45:10) | + | 2 - reset from SPI boot-up |
- | Trying to boot from MMC2 | + | |
- | part_get_info_efi: | + | |
- | ... | + | |
- | spl: partition error | + | |
- | Trying fit image at 0x4000 sector | + | |
``` | ``` | ||
+ | | ||
+ | See too: [[# | ||
- | SPI and eMMC boot loaders cleared. | + | ===== U-boot spl ===== |
- | ```log u-boot-spl-sd-oowow.log | + | WIP: |
- | U-Boot SPL board init | + | ```c u-boot/arch/arm/mach-rockchip/spl-boot-order.c |
- | U-Boot SPL 2017.09 (Jul 25 2022 - 10:32:06) | + | |
- | MCU: bootmode: 1, oowow 3 | + | |
- | MCU: oowow 0 | + | |
- | board_boot_order: | + | |
- | !!! same-as-spl: | + | |
- | !!! /mmc@fe2c0000: | + | |
- | !!! /mmc@fe2e0000: | + | |
- | !!! /spi@fe2b0000/ | + | |
- | Trying to boot from MMC2 :: 0 | + | |
- | Trying fit image at 0x4000 sector | + | |
- | ``` | + | |
- | Boot SPL android u-boot from eMMC: | + | // ...... |
- | ```log u-boot-spl-mmc-android.log | + | /* khadas mcu part begin */ |
- | U-Boot SPL board init | + | #define MCU_I2C_BUS_NUM |
- | U-Boot SPL 2017.09-gc060f28d70-220414 | + | #define MCU_I2C_CHIP_ADDR |
- | Failed to set cpub01 | + | #define MCU_I2C_REG_BOOT_MODE |
- | Failed to set cpub23 | + | #define MCU_I2C_REG_BOOT_MODE_SPI |
- | Trying to boot from MMC2 | + | #define MCU_I2C_REG_BOOT_MODE_MMC |
- | MMC: no card present | + | #define MCU_I2C_REG_BOOT_FLAG |
- | mmc_init: -123, time 0 | + | #define MCU_I2C_REG_RESET_MODE |
- | spl: mmc init failed with error: -123 | + | #define MCU_I2C_REG_BOOT_FLAG_NORMAL 0x00 |
- | Trying to boot from MMC1 | + | #define MCU_I2C_REG_BOOT_FLAG_FUNC |
- | Trying fit image at 0x4000 sector | + | #define MCU_I2C_REG_BOOT_FLAG_OOWOW |
+ | #define MCU_I2C_REG_BOOT_FLAG_SPI | ||
+ | #define MCU_I2C_REG_BOOT_FLAG_EMMC | ||
+ | #define MCU_I2C_REG_BOOT_FLAG_RESCUE 0x05 | ||
+ | #define MCU_I2C_REG_BOOT_FLAG_PASS | ||
- | ``` | + | #define MCU_I2C_REG_LED |
+ | /* khadas mcu part end */ | ||
- | ====== U-Boot stage ====== | + | void board_boot_order(u32 *spl_boot_list) |
+ | { | ||
+ | const void *blob = gd-> | ||
+ | int chosen_node | ||
+ | int idx = 0; | ||
+ | int elem; | ||
+ | int boot_device; | ||
+ | int node; | ||
+ | const char *conf; | ||
- | ===== oowow spi uboot ===== | + | /* khadas mcu part begin */ |
+ | uchar mcu_boot_mode; | ||
+ | uchar mcu_boot_flag; | ||
+ | uchar mcu_led_normal | ||
+ | uchar mcu_led_reset | ||
+ | int ret; | ||
+ | struct udevice *bus; | ||
+ | struct udevice *dev; | ||
- | ```shell boot_targets | + | ret = uclass_first_device(UCLASS_I2C, |
- | kedge2# printenv boot_targets | + | if (ret) goto mcu_skip; |
- | boot_targets=usb0 mmc1 mmc0 pxe dhcp fail | + | ret = i2c_get_chip(bus, |
- | ``` | + | if (ret) goto mcu_skip; |
+ | ret = dm_i2c_read(dev, | ||
+ | ret = dm_i2c_read(dev, | ||
+ | printf(" | ||
+ | mcu_boot_mode, | ||
+ | // reset boot flag | ||
+ | if ( mcu_boot_flag != 0 ) { | ||
+ | mcu_boot_flag = mcu_boot_flag > 10 ? 0 : mcu_boot_flag ^ MCU_I2C_REG_BOOT_FLAG_PASS; | ||
+ | dm_i2c_write(dev, | ||
+ | printf(" | ||
+ | if ( mcu_boot_flag != 0 ) | ||
+ | dm_i2c_write(dev, | ||
+ | } else { | ||
+ | dm_i2c_write(dev, | ||
+ | } | ||
+ | mcu_skip: | ||
+ | /* khadas mcu part end */ | ||
- | ===== mmc uboot ===== | + | if (chosen_node < 0) { |
+ | debug(" | ||
+ | __func__); | ||
+ | spl_boot_list[0] | ||
+ | return; | ||
+ | } | ||
- | default eMMC u-boot log for Ubuntu images | + | printf(" |
- | ```shell boot_targets | + | for (elem = 0; |
- | kedge2# printenv boot_targets | + | |
- | boot_targets=usb0 mmc1 mmc0 pxe dhcp | + | " |
- | ``` | + | |
+ | const char *alias; | ||
+ | printf(" | ||
+ | |||
+ | /* Handle the case of 'same device the SPL was loaded from' */ | ||
+ | if (strncmp(conf, | ||
+ | |||
+ | // / | ||
+ | // / | ||
+ | |||
+ | mcu_boot_flag &= 0x0F; // restore original flag | ||
+ | if (mcu_boot_flag == 1 || mcu_boot_flag == 2 || mcu_boot_flag == 5) | ||
+ | conf = "/ | ||
+ | else if (mcu_boot_flag == 3) | ||
+ | conf = "/ | ||
+ | else if (mcu_boot_mode == MCU_I2C_REG_BOOT_MODE_MMC) | ||
+ | continue; | ||
+ | else | ||
+ | conf = board_spl_was_booted_from(); | ||
+ | |||
+ | printf(" | ||
+ | if (!conf) | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | /* First check if the list element is an alias */ | ||
+ | alias = fdt_get_alias(blob, | ||
+ | if (alias) | ||
+ | conf = alias; | ||
+ | |||
+ | /* Try to resolve the config item (or alias) as a path */ | ||
+ | node = fdt_path_offset(blob, | ||
+ | if (node < 0) { | ||
+ | debug(" | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | /* Try to map this back onto SPL boot devices */ | ||
+ | boot_device = spl_node_to_boot_device(node); | ||
+ | if (boot_device < 0) { | ||
+ | debug(" | ||
+ | __func__, node); | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | spl_boot_list[idx++] = boot_device; | ||
+ | } | ||
+ | |||
+ | /* If we had no matches, fall back to spl_boot_device */ | ||
+ | if (idx == 0) | ||
+ | spl_boot_list[0] = spl_boot_device(); | ||
+ | } | ||
+ | #endif | ||
+ | |||
+ | ``` | ||
- | ==== SPI Flash partitions table ==== | + | ===== SPI Flash partitions table ===== |
```txt MTD parts | ```txt MTD parts |