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

The light_sleep example produces incorrect output. (IDFGH-8008) #9518

Closed
2 of 3 tasks
jcassette opened this issue Aug 7, 2022 · 1 comment
Closed
2 of 3 tasks

The light_sleep example produces incorrect output. (IDFGH-8008) #9518

jcassette opened this issue Aug 7, 2022 · 1 comment
Assignees
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally

Comments

@jcassette
Copy link

Environment

  • Development Kit: none
  • Kit version: none
  • Module or chip used: ESP32-C3-MINI-1-N4
  • IDF version: v4.4.2
  • Build System: idf.py
  • Compiler version: riscv32-esp-elf-gcc (crosstool-NG esp-2021r2-patch3) 8.4.0
  • Operating System: Linux
  • Using an IDE: No
  • Power Supply: USB

Problem Description

The light_sleep example produces incorrect output.

Expected Behavior

The following message should be printed every 2 seconds, with XXXXX being incremented by 2000 each time:

Entering light sleep
Returned from light sleep, reason: timer, t=XXXXX ms, slept for 2000 ms

Actual Behavior

Some lines are not printed at all, some lines are printed incomplete.

Steps to reproduce

  1. idf.py build erase-flash flash monitor

Code to reproduce this issue

See the light_sleep example and/or the files attached.

Debug Logs

Waiting for GPIO4 to go high...
Entering light sleep
Returned from light sleep, reason: timer, t=3772 ms, slept for 2000 ms
Entering light sleep
000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=7861 ms, slept for 2000 ms
Entering light sleep
Entering light sleep
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=81353 ms, slept for 2000 ms
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=85449 ms, slept for 2000 ms
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=89549 ms, slept for 2000 ms
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=93646 ms, slept for 2000 ms
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=97744 ms, slept for 2000 ms
Entering light sleep
2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=101841 ms, slept for 2000 ms
Entering light sleep
 2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=105940 ms, slept for 2000 ms
Entering light sleep
 2000 ms
Entering light sleep
Returned from light sleep, reason: timer, t=110038 ms, slept for 2000 ms
Entering light sleep
Entering light sleep
 2000 ms
Entering light sleep

Other items if possible

  • sdkconfig file (attach the sdkconfig file from your project folder)
  • elf file in the build folder (note this may contain all the code details and symbols of your project.)
  • coredump (This provides stacks of tasks.)

light_sleep.zip

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 7, 2022
@github-actions github-actions bot changed the title The light_sleep example produces incorrect output. The light_sleep example produces incorrect output. (IDFGH-8008) Aug 7, 2022
@espressif-bot espressif-bot added Status: Selected for Development Issue is selected for development and removed Status: Opened Issue is new labels Apr 13, 2023
@Dazza0
Copy link
Contributor

Dazza0 commented Nov 23, 2023

@jcassette Apologies for the late follow up. The reason some your output is truncated is because your example uses the USB Serial JTAG (USJ) peripheral for serial output, and the USJ output isn't flushed before entering light sleep (as opposed to using UART for serail output which is automatically flushed before light sleep begins).

Unfortunately, there are a few reasons why flushing the USJ serial output can't be achieved.

  • USJ is a USB device. Thus, transmitting any serial data requires the USB Host (i.e., the PC) to request it via a USB BULK IN transfer. Most USB Host CDC drivers in typical PCs poll at a rate of 10s to 100s of milliseconds. If we were flush the USJ TX by waiting for the USB Host to request all the pending data, it could delay light sleep entry leading to increased power consumption.
  • USJ cannot operate during light sleep on the ESP32-C3 as the entire peripheral is clock gated. In some cases, this can lead to some Host PCs detecting a disconnection of the ESP32-C3 serial port (again, depends on the poll rate).

Thus, the USJ can't be effectively used if light/deep sleep is involved (see #12628 for more details).

Unfortunately, I don't think there's not much we can do in this case. If you need a constantly connected serial port that persists over sleep, using UART would be the better option.

@Dazza0 Dazza0 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Won't Do This will not be worked on and removed Status: Selected for Development Issue is selected for development labels Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Won't Do This will not be worked on Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests

3 participants