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

[HELP] ESP32C3 sleep after software reset #13230

Open
1 task done
metarutaiga opened this issue Aug 29, 2024 · 12 comments
Open
1 task done

[HELP] ESP32C3 sleep after software reset #13230

metarutaiga opened this issue Aug 29, 2024 · 12 comments
Labels
Community: Question Further information is requested

Comments

@metarutaiga
Copy link

metarutaiga commented Aug 29, 2024

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

  • I have verified before submitting the report.
@metarutaiga metarutaiga added the Community: Question Further information is requested label Aug 29, 2024
@tmedicci
Copy link
Contributor

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

@metarutaiga
Copy link
Author

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

@metarutaiga
Copy link
Author

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
Copy link
Author

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
Copy link
Author

metarutaiga commented Oct 12, 2024

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

@tmedicci
Copy link
Contributor

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)

@metarutaiga
Copy link
Author

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.

@tmedicci
Copy link
Contributor

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?

@metarutaiga
Copy link
Author

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

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

@tmedicci
Copy link
Contributor

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.

@metarutaiga
Copy link
Author

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

@tmedicci
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants