esp-iot-solution icon indicating copy to clipboard operation
esp-iot-solution copied to clipboard

esp-tinyuf2 + power management: crash when cpu frequency dynamic scaling is enabled (AEGHB-632)

Open wuyuanyi135 opened this issue 10 months ago • 0 comments

Answers checklist.

  • [X] I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • [X] I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • [X] I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.3-dev-3499-g636ff35b52

Espressif SoC revision.

ESP32S3

Operating System used.

Windows

How did you build your project?

Command line with Make

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

N8R2

Power Supply used.

USB

What is the expected behavior?

App should not crash when calling esp_tinyuf2_install if power management is activated:

esp_pm_config_t pm_cfg{
      160,
      20,
      true};
  ESP_ERROR_CHECK(esp_pm_configure(&pm_cfg));

What is the actual behavior?

App crashes. No stack trace to provide since the usb is switched to uf2 and the console is no longer connected. Interestingly, the coredump in flash was also not written in this circumstance.

Steps to reproduce.

esp_pm_config_t pm_cfg{
      160,
      20,
      true};
  ESP_ERROR_CHECK(esp_pm_configure(&pm_cfg));
  1. esp_tinyuf2_install

Debug Logs.

No log

More Information.

  1. This is solved by first creating a max cpu lock
  esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "cpu_max", &pm_locks_cpu_max);
  1. before esp_tinyuf2_install, call esp_pm_lock_acquire(pm_locks_cpu_max);

I understand using USB and power management simultaneously is counter-intuitive because of USB powering. However, there might be chance that the uf2 was used for configuring a low power device that has pm configured at the first place.

Please add proper power management lock in the great tinyuf2 library, or maybe provide some doucmentation or warning to the users. After all, debugging USB is tricky especially for those using USB JTAG solely to retrieve the console logs.

wuyuanyi135 avatar Apr 20 '24 18:04 wuyuanyi135