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 [2022/10/31 01:38] hyphop [Reboot by MCU] |
products:sbc:edge2:hardware:edge2-boot-flow [2023/07/17 03:09] hyphop [Uboot oowow defconfig] |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~tag> Edge2 boot~~ | ||
+ | |||
====== Edge2 Boot flow ====== | ====== Edge2 Boot flow ====== | ||
- | Edge2 have advanced and flexible | + | [[:Edge2]] have advanced and flexible |
- | ====== Bootmode ======= | ||
- | '' | + | MCU => BROM => [[#spl-stage|SPL]] => [[#u-boot-stage|U-Boot]] => OS target |
+ | |||
- | ^ bootmode | + | <WRAP important > |
+ | Next information actual for MCU ver: 0x0002 | ||
+ | </ | ||
+ | |||
+ | ====== Hardware buttons ====== | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | More detail: [[./ | ||
+ | |||
+ | |||
+ | ====== MCU features ====== | ||
+ | |||
+ | 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 | ||
+ | ``` | ||
- | ^ oowow_mode | + | <WRAP important > |
- | | spi |0 | | + | boot-flag will be used only one time and after reboot will be masked by '' |
- | | mmc |1 | | + | </ |
- | | default reboot |2 | | + | |
- | + | ^ boot flag note ^ mask ^ | |
- | ===== Boot modes oowow shell usage ===== | + | | spl mask |0x50 | |
+ | | oowow mask |0xA0 | | ||
+ | |||
+ | |||
+ | <WRAP important > | ||
+ | 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 ====== | ||
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 47: | Line 112: | ||
~# bootmode | ~# bootmode | ||
mmc | mmc | ||
+ | |||
+ | ## setup to SPI | ||
~# bootmode spi | ~# bootmode spi | ||
Line 80: | 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 ====== | ||
- | SPL boot loader priority: '' | + | SPL boot loader priority: '' |
<WRAP important > | <WRAP important > | ||
- | SPL boot loader priority not same as mcu bootmode | + | SPL boot loader priority not same as mcu bootmode. MCU boot mode works only after SPL boot stage passed. |
</ | </ | ||
- | 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) | + | |
- | Failed to set cpub01 | + | ```shell boot_targets |
- | Failed to set cpub23 | + | kedge2# printenv boot_targets |
- | I2c2 speed: 100000Hz | + | boot_targets=usb0 mmc1 mmc0 pxe dhcp fail |
- | MCU: bootmode: 1, oowow 3 | + | |
- | MCU: oowow 0 | + | |
- | board_boot_order: | + | |
- | !!! 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 | + | ====== Advanced ====== |
- | U-Boot SPL 2017.09 (Sep 15 2022 - 14:38:28) | + | |
- | MCU: bootmode: 0, oowow 1 | + | ===== MCU registers annotation ===== |
- | MCU: oowow 2 | + | |
- | board_boot_order: | + | |
- | !!! same-as-spl: | + | |
- | +++ / | + | |
- | !!! / | + | |
- | !!! / | + | |
- | !!! / | + | |
- | Trying to boot from MTD2 :: 0 | + | |
- | Trying fit image at 0x300 sector | + | |
``` | ``` | ||
- | ====== U-Boot stage ====== | + | MCU version: 02 & 03 |
- | ```shell boot_targets | + | 0x91 REBOOT_MODE |
- | kedge2# printenv boot_targets | + | 0 - reset and boot from SPI |
- | boot_targets=usb0 mmc1 mmc0 pxe dhcp fail | + | 1 - reset normal |
+ | 2 - reset and boot from eMMC | ||
+ | |||
+ | 0x92 BOOT_FLAG | ||
+ | 0 - normal | ||
+ | 1 - press FUNC boot-up | ||
+ | 2 - reset from SPI boot-up | ||
+ | 3 - reset from eMMC boot-up | ||
+ | ``` | ||
+ | |||
+ | See too: [[#mcu-features]] | ||
+ | |||
+ | ===== U-boot spl ===== | ||
+ | |||
+ | WIP: | ||
+ | |||
+ | ```c u-boot/ | ||
+ | |||
+ | // ...... | ||
+ | |||
+ | /* khadas mcu part begin */ | ||
+ | #define MCU_I2C_BUS_NUM | ||
+ | #define MCU_I2C_CHIP_ADDR | ||
+ | #define MCU_I2C_REG_BOOT_MODE | ||
+ | #define MCU_I2C_REG_BOOT_MODE_SPI | ||
+ | #define MCU_I2C_REG_BOOT_MODE_MMC | ||
+ | #define MCU_I2C_REG_BOOT_FLAG | ||
+ | #define MCU_I2C_REG_RESET_MODE | ||
+ | #define MCU_I2C_REG_BOOT_FLAG_NORMAL 0x00 | ||
+ | #define MCU_I2C_REG_BOOT_FLAG_FUNC | ||
+ | #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 */ | ||
+ | |||
+ | void board_boot_order(u32 *spl_boot_list) | ||
+ | { | ||
+ | const void *blob = gd-> | ||
+ | int chosen_node = fdt_path_offset(blob, | ||
+ | int idx = 0; | ||
+ | int elem; | ||
+ | int boot_device; | ||
+ | int node; | ||
+ | const char *conf; | ||
+ | |||
+ | /* khadas mcu part begin */ | ||
+ | uchar mcu_boot_mode; | ||
+ | uchar mcu_boot_flag; | ||
+ | uchar mcu_led_normal = 8; /* white breath */ | ||
+ | uchar mcu_led_reset | ||
+ | int ret; | ||
+ | struct udevice *bus; | ||
+ | struct udevice *dev; | ||
+ | |||
+ | ret = uclass_first_device(UCLASS_I2C, | ||
+ | if (ret) goto mcu_skip; | ||
+ | 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 */ | ||
+ | |||
+ | if (chosen_node < 0) { | ||
+ | debug(" | ||
+ | __func__); | ||
+ | spl_boot_list[0] = spl_boot_device(); | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | printf(" | ||
+ | |||
+ | for (elem = 0; | ||
+ | (conf = fdt_stringlist_get(blob, | ||
+ | " | ||
+ | | ||
+ | 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 ===== | ||
+ | |||
+ | ```txt MTD parts | ||
+ | 0x000000000000-0x000000080000 : " | ||
+ | 0x000000080000-0x0000000a6000 : " | ||
+ | 0x0000000a6000-0x0000000c8000 : " | ||
+ | 0x0000000c8000-0x000000148000 : " | ||
+ | 0x000000148000-0x000000448000 : " | ||
+ | 0x000000448000-0x000000488000 : " | ||
+ | 0x000000488000-0x0000004c8000 : " | ||
+ | 0x0000004c8000-0x0000006c8000 : " | ||
+ | 0x0000006c8000-0x000002000000 : " | ||
+ | ``` | ||
+ | |||
+ | ===== Uboot ===== | ||
+ | |||
+ | |||
+ | ==== Uboot image format ==== | ||
+ | |||
+ | Need be stored by offset '' | ||
+ | |||
+ | ```txt uboot-info | ||
+ | Info: UBOOT_COMPRESSION: | ||
+ | FIT description: | ||
+ | Created: | ||
+ | Image 0 (uboot) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 430151 Bytes = 420.07 KiB = 0.41 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0x00200000 | ||
+ | Entry Point: | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 1 (atf-1) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 47147 Bytes = 46.04 KiB = 0.04 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0x00040000 | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 2 (atf-2) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 28672 Bytes = 28.00 KiB = 0.03 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0x000f0000 | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 3 (atf-3) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 20480 Bytes = 20.00 KiB = 0.02 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0xff100000 | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 4 (atf-4) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 8192 Bytes = 8.00 KiB = 0.01 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0xff001000 | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 5 (optee) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: | ||
+ | Compression: | ||
+ | Data Size: 177774 Bytes = 173.61 KiB = 0.17 MiB | ||
+ | Architecture: | ||
+ | Load Address: 0x08400000 | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | Image 6 (fdt) | ||
+ | Description: | ||
+ | Created: | ||
+ | Type: Flat Device Tree | ||
+ | Compression: | ||
+ | Data Size: 8262 Bytes = 8.07 KiB = 0.01 MiB | ||
+ | Architecture: | ||
+ | Hash algo: sha256 | ||
+ | Hash value: | ||
+ | | ||
+ | | ||
+ | Description: | ||
+ | Kernel: | ||
+ | Firmware: | ||
+ | FDT: fdt | ||
+ | Loadables: | ||
+ | atf-2 | ||
+ | atf-3 | ||
+ | atf-4 | ||
+ | optee | ||
+ | -rw-rw-r-- 1 master master 725504 Jul 17 14:59 u-boot-cmp.itb | ||
+ | Info: pack uboot.img okay! | ||
+ | Info: Generating uboot-sd.img ... 0x4000 == 16384 > u-boot.itb | ||
``` | ``` |