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/05/15 22:35] hyphop [Edge2 Boot flow] |
products:sbc:edge2:hardware:edge2-boot-flow [2023/07/17 03:09] hyphop [Uboot oowow defconfig] |
||
---|---|---|---|
Line 41: | Line 41: | ||
===== Boot flag ====== | ===== Boot flag ====== | ||
- | This flag '' | + | This flag '' |
^ boot flag ^ value ^ | ^ boot flag ^ value ^ | ||
| disabled | | disabled | ||
| [[/ | | [[/ | ||
+ | | boot from SPI |2 | | ||
+ | | boot from eMMC | ||
+ | |||
```sh boot-flag read | ```sh boot-flag read | ||
Line 51: | Line 54: | ||
``` | ``` | ||
- | ===== Reboot | + | <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 | | ||
+ | |||
+ | |||
+ | <WRAP important > | ||
+ | boot-flag value ''> | ||
+ | </ | ||
+ | |||
+ | ===== Reboot | ||
We can reboot device by non standard way via MCU '' | We can reboot device by non standard way via MCU '' | ||
Line 60: | Line 76: | ||
| eMMC |2 | | | eMMC |2 | | ||
- | '' | + | ```sh reboot-mode read |
+ | i2cset -f -y 2 0x18 0x91 value | ||
+ | ``` | ||
<WRAP important > | <WRAP important > | ||
Device will be rebooted immediately after successful writing to '' | Device will be rebooted immediately after successful writing to '' | ||
</ | </ | ||
+ | |||
+ | <WRAP important > | ||
+ | Only '' | ||
+ | '' | ||
+ | '' | ||
+ | </ | ||
+ | |||
See too: [[# | See too: [[# | ||
Line 71: | Line 96: | ||
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 82: | Line 112: | ||
~# bootmode | ~# bootmode | ||
mmc | mmc | ||
+ | |||
+ | ## setup to SPI | ||
~# bootmode spi | ~# bootmode spi | ||
Line 115: | 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 | ||
``` | ``` | ||
Line 134: | Line 168: | ||
==== Reboot from SPI flash U-Boot via i2c command ==== | ==== Reboot from SPI flash U-Boot via i2c command ==== | ||
- | WIP: not works as need | + | ```sh reset and use u-boot from spi flash |
- | + | ||
- | ```sh reboot into oowow | + | |
- | i2cset | + | |
i2cset -f -y 2 0x18 0x91 0 | 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 197: | Line 232: | ||
```c u-boot/ | ```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 | ||
+ | |||
``` | ``` | ||
Line 213: | Line 377: | ||
``` | ``` | ||
+ | ===== 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 | ||
+ | ``` |