nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

[HELP] ESP32C3 sleep after software reset

Open metarutaiga opened this issue 1 year ago • 11 comments

Description

I tested LUATOS ESP32C3 and ESP32-C3-mini

I tried these

  1. boardctl(BOARDIOC_RESET, 0);
  2. esp_restart();
  3. 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.

metarutaiga avatar Aug 29 '24 05:08 metarutaiga

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?)

tmedicci avatar Aug 29 '24 14:08 tmedicci

Thank you I found the problem is CONFIG_ELF now. I will try where the problem is.

metarutaiga avatar Aug 29 '24 15:08 metarutaiga

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...

metarutaiga avatar Aug 29 '24 15:08 metarutaiga

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)

metarutaiga avatar Oct 08 '24 04:10 metarutaiga

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

metarutaiga avatar Oct 12 '24 17:10 metarutaiga

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)

tmedicci avatar Oct 16 '24 13:10 tmedicci

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.

metarutaiga avatar Oct 16 '24 14:10 metarutaiga

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?

tmedicci avatar Oct 16 '24 14:10 tmedicci

https://github.com/NyankoLab/esp32c3-nuttx

if it enabled wget and uiP web Client, it would be over 1MB.

metarutaiga avatar Oct 18 '24 03:10 metarutaiga

Hi @metarutaiga , I couldn't reproduce your issue. I need clearer and more detailed instructions.

I tried:

  1. esp32c6-devkitc:sta_softap, enabling wget, uiP web client and mbedTLS (with example applications). Firmware is over 1MB and the device boots successfully and reboot commands reboots the device successfully.
  2. esp32c6-devkitc:sta_softap, enabling wget, uiP web client and mbedTLS (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=0x210000 and CONFIG_ESPRESSIF_OTA_SLOT_SIZE=0x200000 to 2MB. Same result: device boots as expected and reboots successfully.

tmedicci avatar Oct 21 '24 19:10 tmedicci

Hmmm, it's almost the same instructions. I give up to find the problem.

metarutaiga avatar Oct 22 '24 04:10 metarutaiga

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.

tmedicci avatar Oct 22 '24 16:10 tmedicci