[HELP] ESP32C3 sleep after software reset
Description
I tested LUATOS ESP32C3 and ESP32-C3-mini
I tried these
- boardctl(BOARDIOC_RESET, 0);
- esp_restart();
- esp_rom_software_reset_cpu(0);
But it sleep always.
I tried esp_restart from esp-idf project, it works normally. So how to know where is the bug? NuttX or MCUboot ?
esp32c3-legacy works normally also.
Verification
- [X] I have verified before submitting the report.
Hi,
Please check esp32c3-generic:sta_softap defconfig. It enables the reboot command (just type reboot). It uses the boardctl(BOARDIOC_RESET, 0) interface for that.
If it still does not work, please enable the following configs in menuconfig:
CONFIG_SYSTEM_NXDIAG=y
CONFIG_SYSTEM_NXDIAG_COMP_FLAGS=y
CONFIG_SYSTEM_NXDIAG_CONF=y
CONFIG_SYSTEM_NXDIAG_ESPRESSIF=y
CONFIG_SYSTEM_NXDIAG_HOST_PATH=y
And run in NuttX nxdiag --all (sharing your results here).
Also, please double-check which hardware exactly you are using (Is it a module? a board? Which Espressif module/chip is being used?)
Thank you I found the problem is CONFIG_ELF now. I will try where the problem is.
Skip this, reboot works.
#ifdef CONFIG_ELF
ret = elf_initialize();
if (ret < 0)
{
berr("ERROR: elf_initialize failed: %d\n", ret);
}
#endif
But skip here, it will sleep
int elf_initialize(void)
{
int ret;
/* Register ourselves as a binfmt loader */
binfo("Registering ELF\n");
ret = register_binfmt(&g_elfbinfmt);
if (ret != 0)
{
berr("Failed to register binfmt: %d\n", ret);
}
return ret;
}
Very strange...
I guest the problem is mcuboot the ESP32-C3 generic is supported mcuboot only. And if firmware is over than 1MB It stuck at mcuboot (after the esp32 rom bootloader)
I tried esp-idf v5.1.1 ~ v5.3.1 to build mcuboot bootloader, but it's the same. how to check what the flags is controlled the sleep?
NuttShell (NSH) NuttX-12.7.0
nsh> reboot
reboot status=0
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0xc (RTC_SW_CPU_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x40381be6
SPIWP:0xee
mode:DIO, clock div:2
load:0x3fcd89a8,len:0x1458
load:0x403c7000,len:0x22c0
load:0x403d0000,len:0x22a8
ent
Hi @metarutaiga ,
esp-idf is not required to build MCUboot. Can you share exactly the steps you are doing? Also, can you please post your defconfig (run make savedefconfig and a new defconfig will be generated)? (If not possible, please share a reduced version of it with the same error)
I used the mcuboot repository to build it directly. Any MCUboot version is not affect the result.
I known it's hang not sleep now. I am sure that if binary size is over than 1MB, it hangs when reboot.
I used the mcuboot repository to build it directly. Any MCUboot version is not affect the result.
I known it's hang not sleep now. I am sure that if binary size is over than 1MB, it hangs when reboot.
Right, can you provide the steps to reproduce and a failing branch of nuttx and nuttx-apps, please?
https://github.com/NyankoLab/esp32c3-nuttx
if it enabled wget and uiP web Client, it would be over 1MB.
Hi @metarutaiga , I couldn't reproduce your issue. I need clearer and more detailed instructions.
I tried:
esp32c6-devkitc:sta_softap, enablingwget,uiP web clientandmbedTLS(with example applications). Firmware is over 1MB and the device boots successfully andrebootcommands reboots the device successfully.esp32c6-devkitc:sta_softap, enablingwget,uiP web clientandmbedTLS(with example applications) and MCUboot (CONFIG_ESPRESSIF_BOOTLOADER_MCUBOOT=y). I adjusted the slots accordingly (default slot size is 1MB):CONFIG_ESPRESSIF_OTA_SCRATCH_OFFSET=0x410000,CONFIG_ESPRESSIF_OTA_SECONDARY_SLOT_OFFSET=0x210000andCONFIG_ESPRESSIF_OTA_SLOT_SIZE=0x200000to 2MB. Same result: device boots as expected and reboots successfully.
Hmmm, it's almost the same instructions. I give up to find the problem.
Hmmm, it's almost the same instructions. I give up to find the problem.
Can you try to repeat the steps using NuttX upstream (either master or a fixed version). We need to have detailed steps to reproduce the problem and information about your host OS, compiler version and NuttX (OS and apps) being used. Please let me know if you are able to reproduce the problem.