Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:hardware:edge2-boot-flow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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 21:55]
hyphop [Reboot modes by MCU]
products:sbc:edge2:hardware:edge2-boot-flow [2023/05/17 07:15]
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 booting sequence... WIP:+[[:Edge2]] have advanced and flexible boot flow ... see also [[boot-sequence]]
  
  
Line 14: Line 14:
  
 ====== Hardware buttons ====== ====== Hardware buttons ======
- 
-WIP: 
  
   * ''FUNCTION'' + ''RESET'' - [[/software/oowow/getting-started#what-is-oowow|oowow mode]]    * ''FUNCTION'' + ''RESET'' - [[/software/oowow/getting-started#what-is-oowow|oowow mode]] 
Line 24: Line 22:
          
  
-====== Bootmode =======+====== MCU features ======
  
-''i2cget --y  2 0x18 0x20''+See too: [[#mcu-registers-annotation]]
  
-bootmode    ^ value ^ +===== Boot mode ====== 
 + 
 +Common boot mode configuration ''0x20'' 
 + 
 +boot mode    ^ value ^ 
 | spi         | 0     | | spi         | 0     |
 | mmc         | 1     | | mmc         | 1     |
  
-====== Reboot mode ======= 
  
-''i2cget -f -y  2 0x18 0x92''+```sh boot-mode read 
 +i2cget -f -y 2 0x18 0x20 
 +``` 
 + 
 +===== Boot flag ====== 
 + 
 +This flag ''0x92'' will be used one time on next reboot! and not change common [[#boot-mode]]
  
-^  reboot mode    ^ value ^ +^  boot flag    ^ value ^ 
 | disabled      |0      | | disabled      |0      |
-| OOWOW request |1      | +| [[/software/oowow/getting-started#what-is-oowow|OOWOW request]] |1      | 
-OOWOW rescue  |     |+boot from SPI      |2      | 
 +| boot from eMMC     |     |
  
-====== Reboot modes by MCU ======= 
  
-''i2cset -f -y  2 0x18 0x91 value''+```sh boot-flag read 
 +i2cget -f -y 2 0x18 0x92 
 +```
  
-oowow_mode     ^ value ^  +<WRAP important > 
-spi            |0      | +boot-flag will be used only one time and after reboot will be masked by ''0x50'' on SPL stage 
-mmc            |1      | +</WRAP> 
-default reboot |2      |+ 
 +^  boot flag note  ^ mask ^  
 +| spl mask      |0x50      | 
 +| oowow mask      |0xA0      | 
 + 
 + 
 +<WRAP important > 
 +boot-flag value ''> 10'' will be reset to ''0'' on reboot SPL stage 
 +</WRAP> 
 + 
 +===== Reboot mode ====== 
 + 
 +We can reboot device by non standard way via MCU ''0x91'' register with special options. 
 +  
 +^ reboot mode     ^ value ^  
 +SPI             |0      | 
 +normal reboot   |1      | 
 +eMMC            |2      | 
 + 
 +```sh reboot-mode read 
 +i2cset -f -y  2 0x18 0x91 value 
 +```
  
 <WRAP important > <WRAP important >
Line 54: Line 84:
 </WRAP> </WRAP>
  
-   +<WRAP important > 
 +Only ''normal reboot == 1'' dos not change [[#boot-flag]] on next reboot!\\ 
 +''SPI == 0'' will change [[#boot-flag]] to ''2'' on next reboot\\ 
 +''eMMC == 2'' will change [[#boot-flag]] to ''3'' on next reboot\\ 
 +</WRAP> 
 + 
 + 
 +See too: [[#mcu-registers-annotation]]
 ====== 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 70: Line 112:
 ~# bootmode ~# bootmode
 mmc mmc
 +
 +## setup to SPI
  
 ~# bootmode spi ~# bootmode spi
Line 103: 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 122: 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 -f -y 2 0x18 0x92 0+
 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 ''USB'' ''SD'' ''eMMC'' and ''Rescue OOWOW mode'' will be last! If u need start oowow please use [[#reboot-into-oowow-via-i2c-command]] 
 +</WRAP>
  
 ====== SPL stage ====== ====== SPL stage ======
Line 166: Line 213:
 MCU version: 02 & 03 MCU version: 02 & 03
  
-0x91  +0x91 REBOOT_MODE 
-    0 - reset and boot from spi +    0 - reset and boot from SPI 
-    - reset and boot from emmc +    - reset normal 
-    - reset+    - reset and boot from eMMC
  
-0x92 BOOT_FLAG (oowow will check this register about boot mode)+0x92 BOOT_FLAG
     0 - normal     0 - normal
-    1 - press FUNC bootup +    1 - press FUNC boot-up 
-    2 - reset from spi bootup +    2 - reset from SPI boot-up 
-    3 - reset from emmc bootup+    3 - reset from eMMC boot-up
 ``` ```
          
 +See too: [[#mcu-features]]
 +
 ===== U-boot spl  ===== ===== U-boot spl  =====
  
 +WIP:
  
 ```c u-boot/arch/arm/mach-rockchip/spl-boot-order.c ```c u-boot/arch/arm/mach-rockchip/spl-boot-order.c
 +
 +// ......
 +
 /* khadas mcu part begin */ /* khadas mcu part begin */
-#define MCU_I2C_BUS_NUM         +#define MCU_I2C_BUS_NUM              
-#define MCU_I2C_CHIP_ADDR       0x18 +#define MCU_I2C_CHIP_ADDR            0x18 
-#define MCU_I2C_REG_BOOT_MODE   0x20 +#define MCU_I2C_REG_BOOT_MODE        0x20 
-#define MCU_I2C_REG_BOOT_MODE_SPI   0x00 +#define MCU_I2C_REG_BOOT_MODE_SPI    0x00 
-#define MCU_I2C_REG_BOOT_MODE_MMC   0x01 +#define MCU_I2C_REG_BOOT_MODE_MMC    0x01 
-#define MCU_I2C_REG_OOWOW_MODE  0x92 +#define MCU_I2C_REG_BOOT_FLAG        0x92 
-#define MCU_I2C_REG_OOWOW_MODE_NONE    0x00 +#define MCU_I2C_REG_RESET_MODE       0x91 
-#define MCU_I2C_REG_OOWOW_MODE_ACTIVE  0x01 +#define MCU_I2C_REG_BOOT_FLAG_NORMAL 0x00 
-#define MCU_I2C_REG_OOWOW_MODE_PASS    0x02+#define MCU_I2C_REG_BOOT_FLAG_FUNC   0x01 
 +#define MCU_I2C_REG_BOOT_FLAG_OOWOW  0x01 
 +#define MCU_I2C_REG_BOOT_FLAG_SPI    0x02 
 +#define MCU_I2C_REG_BOOT_FLAG_EMMC   0x03 
 +#define MCU_I2C_REG_BOOT_FLAG_RESCUE 0x05 
 +#define MCU_I2C_REG_BOOT_FLAG_PASS   0x50 
 #define MCU_I2C_REG_LED  0x89 #define MCU_I2C_REG_LED  0x89
 /* khadas mcu part end */ /* khadas mcu part end */
Line 207: Line 266:
 /* khadas mcu part begin */ /* khadas mcu part begin */
  uchar mcu_boot_mode;  uchar mcu_boot_mode;
- uchar mcu_oowow_mode;+ uchar mcu_boot_flag;
  uchar mcu_led_normal = 8; /* white breath */  uchar mcu_led_normal = 8; /* white breath */
- uchar mcu_led_oowow  = 1; /* white solid */+ uchar mcu_led_reset  = 1; /* white solid */
  int ret;  int ret;
  struct udevice *bus;  struct udevice *bus;
Line 219: Line 278:
  if (ret) goto mcu_skip;  if (ret) goto mcu_skip;
  ret = dm_i2c_read(dev, MCU_I2C_REG_BOOT_MODE, &mcu_boot_mode, 1);  ret = dm_i2c_read(dev, MCU_I2C_REG_BOOT_MODE, &mcu_boot_mode, 1);
- ret = dm_i2c_read(dev, MCU_I2C_REG_OOWOW_MODE, &mcu_oowow_mode, 1); + ret = dm_i2c_read(dev, MCU_I2C_REG_BOOT_FLAG, &mcu_boot_flag, 1); 
- printf("MCU: bootmode: %d, oowow %d\n", mcu_boot_mode, mcu_oowow_mode); + printf("MCU: boot mode 0x20: %d, flag 0x92: %d\n", 
- // reset oowow mode +                          mcu_boot_mode, mcu_boot_flag); 
- if ( mcu_oowow_mode != 0 ) { + // reset boot flag 
- mcu_oowow_mode mcu_oowow_mode == 1 0+ if ( mcu_boot_flag != 0 ) { 
- ret = dm_i2c_write(dev, MCU_I2C_REG_OOWOW_MODE, &mcu_oowow_mode, 1); + mcu_boot_flag mcu_boot_flag > 10 mcu_boot_flag ^ MCU_I2C_REG_BOOT_FLAG_PASS
- printf("MCU: oowow %d\n", mcu_oowow_mode); + dm_i2c_write(dev, MCU_I2C_REG_BOOT_FLAG, &mcu_boot_flag, 1); 
- ret = dm_i2c_write(dev, MCU_I2C_REG_LED, &mcu_led_oowow, 1);+ printf("MCU: boot flag < %d\n", mcu_boot_flag); 
 + if ( mcu_boot_flag !0 ) 
 +     dm_i2c_write(dev, MCU_I2C_REG_LED, &mcu_led_reset, 1);
  } else {  } else {
- ret = dm_i2c_write(dev, MCU_I2C_REG_LED, &mcu_led_normal, 1);+ dm_i2c_write(dev, MCU_I2C_REG_LED, &mcu_led_normal, 1);
  }  }
 mcu_skip: mcu_skip:
Line 252: Line 313:
  /* Handle the case of 'same device the SPL was loaded from' */  /* Handle the case of 'same device the SPL was loaded from' */
  if (strncmp(conf, "same-as-spl", 11) == 0) {  if (strncmp(conf, "same-as-spl", 11) == 0) {
- if (mcu_oowow_mode)+ 
 + // /mmc@fe2c0000 - SD 
 + // /mmc@fe2e0000 - EMMC 
 + 
 + mcu_boot_flag &= 0x0F; // restore original flag 
 + if (mcu_boot_flag == 1 || mcu_boot_flag == 2 || mcu_boot_flag == 5)
      conf = "/spi@fe2b0000/flash@1";      conf = "/spi@fe2b0000/flash@1";
 + else if (mcu_boot_flag == 3)
 +     conf = "/mmc@fe2e0000";
  else if (mcu_boot_mode == MCU_I2C_REG_BOOT_MODE_MMC)  else if (mcu_boot_mode == MCU_I2C_REG_BOOT_MODE_MMC)
      continue;      continue;
Last modified: 2023/07/17 03:15 by hyphop