espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.49k stars 7.26k forks source link

Light Sleep kills serial port output - S3 USB to Serial (IDFGH-12345) #13376

Closed SolidStateLEDLighting closed 6 months ago

SolidStateLEDLighting commented 7 months ago

Answers checklist.

IDF version.

5.2

Espressif SoC revision.

ESP32S3

Operating System used.

Windows

How did you build your project?

VS Code IDE

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

None

Development Kit.

DevKitC

Power Supply used.

USB

What is the expected behavior?

The process of going to light sleep and waking up again IS WORKING -- but it disables my serial port output in the IDE.

The example code doesn't indicate that the serial port would be disabled. And it doesn't indicate that I need to restart it.

I never start the seral port manually in my IDF builds. Can someone point me in a direction where I can get the commands to manually reset/restart the serial port?

What is the actual behavior?

When I have this issue, I can depress the reset button on the unit and then I see:

None (written in red) Waiting for the device to reconnect (written in yellow)

I believe that I have seen the solution for Arduino -- you just restart the serial port. But, I don't know where those commands are in the IDF version of the startup process. Can someone point me in the right direction? ### Steps to reproduce. printf("Entering Light Sleep...\n"); // DOES PRINT taskYIELD(); esp_light_sleep_start(); taskYIELD(); printf("Returned from light sleep...\n"); // WILL NOT PRINT UPON RETURN ### Debug Logs. ```plain I (302) esp_image: segment 4: paddr=000f9534 vaddr=4037b4I (343) cpu_start: Multicore app I (343) octal_psram: vendor id : 0x0d (AP) I (344) octal_psram: dev id : 0x02 (generation 3) I (347) octal_psram: density : 0x03 (64 Mbit) I (352) octal_psram: good-die : 0x01 (Pass) I (357) octal_psram: Latency : 0x01 (Fixed) I (362) octal_psram: VCC : 0x01 (3V) I (368) octal_psram: SRF : 0x01 (Fast Refresh) I (373) octal_psram: BurstType : 0x01 (Hybrid Wrap) I (379) octal_psram: BurstLen : 0x01 (32 Byte) I (385) octal_psram: Readlatency : 0x02 (10 cycles@Fixed) I (391) octal_psram: DriveStrength: 0x00 (1/1) I (396) esp_psram: Found 8MB PSRAM device I (401) esp_psram: Speed: 40MHz I (1136) esp_psram: SPI SRAM memory test OK I (1145) cpu_start: Pro cpu start user code I (1145) cpu_start: cpu freq: 160000000 Hz I (1145) cpu_start: Application information: I (1148) cpu_start: Project name: esp-idf-advanced-template-alpha I (1155) cpu_start: App version: 42eb1b7-dirty I (1161) cpu_start: Compile time: Mar 13 2024 23:18:22 I (1167) cpu_start: ELF file SHA256: f6b2d2635... I (1172) cpu_start: ESP-IDF: v5.2-dirty I (1178) cpu_start: Min chip rev: v0.0 I (1182) cpu_start: Max chip rev: v0.99 I (1187) cpu_start: Chip rev: v0.1 I (1192) heap_init: Initializing. RAM available for dynamic allocation: I (1200) heap_init: At 3FCA3F18 len 000457F8 (277 KiB): RAM I (1206) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM I (1212) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (1218) heap_init: At 600FE05C len 00001F8C (7 KiB): RTCRAM I (1225) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator I (1233) spi_flash: detected chip: gd I (1236) spi_flash: flash io: dio I (1241) sleep: Configure to isolate all GPIO pins in sleep state I (1247) sleep: Enable automatic switching of GPIO sleep configuration I (1255) main_task: Started on CPU0 I (1265) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations I (1265) main_task: Calling app_main() I (1305) _sys: System(): runStackSizek: 8 I (1305) _sys: run(): SYS_INIT::Start I (1305) _sys: run(): SYS_INIT::Start_Network_Interface - Step 2 I (1315) _sys: run(): SYS_INIT::Create_Default_Event_Loop - Step 3 I (1315) _sys: run(): SYS_INIT::Start_GPIO - Step 4 I (1325) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 1| Intr:2 I (1335) _sys: initGPIOTask() I (1335) main_task: Returned from app_main() I (1335) _sys: initGPIOTask(): Started gpio isr service... I (1345) _sys: initGPIOTask(): gpioStackSizeK: 5 I (1355) _sys: run(): SYS_INIT::Create_Indication - Step 5 I (1365) _sys: run(): SYS_INIT::Wait_On_Indication - Step 6 I (1365) gpio: GPIO[48]| InputEn: 1| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (1375) _sys: run(): SYS_INIT::Create_Wifi - Step 7 I (1385) _wifi: Wifi(): runStackSizek: 14 I (1385) _sys: run(): SYS_INIT::Wait_On_Wifi - Step 8 I (1635) _wifi: run(): WIFI_INIT::Start I (1635) _wifi: run(): WIFI_INIT::Checks - Step 1 I (1635) _wifi: run(): WIFI_INIT::Set_Variables_From_Config - Step 2 I (1635) _wifi: run(): Using ssidPri from nvs with a value of Hippo I (1645) _wifi: run(): Using ssidPwdPri from nvs with a value of Grape-Juice I (1655) _wifi: run(): WIFI_INIT::Auto_Connect - Step 3 I (1655) _wifi: run(): WIFI_INIT::Finished I (1665) _sys: run(): SYS_INIT::Finished I (1665) _sys: initSysTimerTask(): timerStackSizeK: 4 I (9695) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 Entering Light Sleep... ``` ### More Information. None
SolidStateLEDLighting commented 7 months ago

I just noticed some improvement by moving my USB input line away from "USB" over to the other USB input that is labeled "COM". This registered another serial port in my system -- and I moved my IDE to it.

The program behavior is pretty much normal now when I awake from light sleep.

So, evidently I have been getting my serial out through the USB previously (GPIO pins 19 and 20) and now I'm getting the I/O through the normal expected default Tx/Rx serial port which is buffered in the USB to UART bridge chip (CH343).

Any ideas on why the native USB port (GPIO pins 19 and 20) remain inoperative after light sleep? Is there a command that stimulates that port back into service?

SolidStateLEDLighting commented 7 months ago

It is confirmed now -- everything works exactly as expected on the real physical serial port UART0 (pins 36 and 37 for this S3).

Can anyone shed some light on why the USB output dies on light sleep? Is there any restore call that might bring that USB serial output back after sleep?

Frankie6626 commented 6 months ago

Got the same issue. This is solved by switching from the micro USB port "USB" to the other micro USB port labeled "UART"