Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32s3: add simple boot support #12165

Merged

Conversation

almir-okato
Copy link
Contributor

Summary

The Simple Boot feature for Espressif chips is a method of booting that doesn't depend on a 2nd stage bootloader. Its not the intention to replace a 2nd stage bootloader such as MCUboot and ESP-IDF bootloader, but to have a minimal and straight-forward way of booting, and also simplify the building.

This commit also removes deprecated code and makes this bootloader configuration as default for esp32s3 targets and removes the need for running 'make bootloader' command for it.

Other related fix, but not directly to Simple Boot:

  • Instrumentation is required to run from IRAM to support it during initialization. is_eco0 function also needs to run from IRAM.
  • rtc.data section placement was fixed.
  • Provide arch-defined interfaces for efuses, in order to decouple board config level from arch-defined values.

Impact

ESP32-S3 targets and bootloader.

Testing

Internal CI testing

The Simple Boot feature for Espressif chips is a method of booting
that doesn't depend on a 2nd stage bootloader. Its not the
intention to replace a 2nd stage bootloader such as MCUboot and
ESP-IDF bootloader, but to have a minimal and straight-forward way
of booting, and also simplify the building.

This commit also removes deprecated code and makes this bootloader
configuration as default for esp32s3 targets and removes the need
for running 'make bootloader' command for it.

Other related fix, but not directly to Simple Boot:
- Instrumentation is required to run from IRAM to support it during
initialization. `is_eco0` function also needs to run from IRAM.
- `rtc.data` section placement was fixed.
- Provide arch-defined interfaces for efuses, in order to decouple
board config level from arch-defined values.

Signed-off-by: Almir Okato <almir.okato@espressif.com>
@almir-okato
Copy link
Contributor Author

@xiaoxiang781216 xiaoxiang781216 merged commit d098c1d into apache:master Apr 17, 2024
26 checks passed
@yamt
Copy link
Contributor

yamt commented Apr 30, 2024

@almir-okato have you tested CONFIG_ESP32S3_APP_FORMAT_LEGACY=y with this patch?
my attempt to fix it: #12264

@yamt
Copy link
Contributor

yamt commented May 1, 2024

@almir-okato is this supposed to work for esp32s3 with 32MB flash?

i've got:

ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
Octal Flash Mode Enabled
For OPI Flash, Use Default Flash Boot Mode
mode:SLOW_RD, clock div:2
load:0x3fc9def0,len:0x2b50
load:0x40374000,len:0xacf0
SHA-256 comparison failed:
Calculated: 1537b56fc55c4dec244926d9c9c4a21d13bff2c351d5a4f1979c9469d4074ea5
Expected: 0000000080270000000000000000000000000000000000000000000000000000
Attempting to boot anyway...
entry 0x40374fcc
*** Booting NuttX ***
dram: lma 0x00000020 vma 0x3fc9def0 len 0x2b50   (11088)
iram: lma 0x00002b78 vma 0x40374000 len 0xacf0   (44272)
padd: lma 0x0000d878 vma 0x00000000 len 0x2780   (10112)
imap: lma 0x00010000 vma 0x42030000 len 0x9b55c  (636252)
padd: lma 0x000ab564 vma 0x00000000 len 0x4ab4   (19124)
dmap: lma 0x000b0020 vma 0x3c000020 len 0x287ec  (165868)
total segments stored 6
AB[CPU1] nx_mount: found procfs
[CPU1] esp32s3_spiflash_alloc_mtdpart: ESP32-S3 SPI Flash information:
[CPU1] esp32s3_spiflash_alloc_mtdpart:  ID = 0x0
[CPU1] esp32s3_spiflash_alloc_mtdpart:  Status mask = 0xffff
[CPU1] esp32s3_spiflash_alloc_mtdpart:  Chip size = 16384 KB
[CPU1] esp32s3_spiflash_alloc_mtdpart:  Page size = 256 B
[CPU1] esp32s3_spiflash_alloc_mtdpart:  Sector size = 4 KB
[CPU1] esp32s3_spiflash_alloc_mtdpart:  Block size = 64 KB
[CPU1] esp32s3_spiflash_alloc_mtdpart:  MTD offset = 0x180000
[CPU1] esp32s3_spiflash_alloc_mtdpart:  MTD size = 0x1e80000
[CPU1] esp32s3_ioctl: cmd: 1537
[CPU1] esp32s3_ioctl: blocksize: 256 erasesize: 4096 neraseblocks: 4096
[CPU1] esp32s3_ioctl: return 0
[CPU1] mtd_partition: ERROR: sub-region too big
[CPU1] esp32s3_spiflash_alloc_mtdpart: ERROR: Failed to create MTD partition
[CPU1] ERROR: Failed to alloc MTD partition of SPI Flash
[CPU1] ERROR: Failed to initialize SPI Flash

i can use the same board with ESP32S3_APP_FORMAT_LEGACY.
(using CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE=y)


/* ------------------Enable Cache----------------------------------- */

cache_hal_enable(CACHE_TYPE_ALL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can these apis (cache_hal_enable/cache_hal_disable) be used w/o calling cache_hal_init?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yamt , the cache_hal_init is called from bootloader_init. Same routine is called from MCUboot bootloader.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yamt , the cache_hal_init is called from bootloader_init. Same routine is called from MCUboot bootloader.

this one? https://github.com/espressif/esp-hal-3rdparty/blob/7c4fae7ebc5342b19cab03511bfa277176bba377/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c#L214

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants