-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Board
ESP32-S3
Device Description
ESP32-S3-WROOM-1 as built into a circuit and also a Waveshare ESP32-S3 dev board.
Hardware Configuration
Nothing attached to the Waveshare dev board.
Lots of the GPIO of the ESP32-S3-WROOM-1 is attached to enable pins of power supplies.
Version
v3.2.1
Type
Bug
IDE Name
Arduino IDE
Operating System
Linux
Flash frequency
80MHz
PSRAM enabled
no
Upload speed
115200
Description
There is a clear bug when going from Arduino ESP32 library 3.2.0 to 3.2.1 (also present in 3.3.0).
An upgrade in library causes GPIO15 (an RTC GPIO) to glitch to a floating state during wake from deep sleep for less than 100ms, even when specifically set to low using these just before entering deep sleep:
digitalWrite(GPIO15, LOW);
rtc_gpio_hold_en(GPIO15);
GPIO16 and GPIO 17 do not glitch to floating during wake from deep sleep. The bug is only GPIO15 and it only appears when going from Arduino ESP32 library 3.2.0 to 3.2.1/3.3.0.
Sketch
#include "esp_vfs_dev.h"
#include "esp_sleep.h"
#include "driver/rtc_io.h"
#include "esp_pm.h"
#include "esp_timer.h"
#include "esp_heap_caps.h"
#define sleep_s(A) delay(A * 1000)
#define sleep_ms(A) delay(A)
#define sleep_us(A) esp_rom_delay_us(A)
#define NOT_3V3_SLEEP 42
#define LOAD_SWITCH_EN 40
#define SWITCH 10
RTC_DATA_ATTR int64_t rtc_us_at_sleep = 0;
void SleepSys(void) {
printf("Going to sleep.\n");
digitalWrite(6, LOW);
rtc_gpio_hold_en((gpio_num_t)6);
digitalWrite(7, LOW);
rtc_gpio_hold_en((gpio_num_t)7);
digitalWrite(15, LOW);
rtc_gpio_hold_en((gpio_num_t)15);
digitalWrite(16, LOW);
rtc_gpio_hold_en((gpio_num_t)16);
digitalWrite(17, LOW);
rtc_gpio_hold_en((gpio_num_t)17);
digitalWrite(NOT_3V3_SLEEP, LOW); // fine for it to float or be low
uint64_t wakeup_mask = (1ULL << SWITCH);
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
rtc_us_at_sleep = (int64_t)tv_now.tv_sec * 1000000L + (int64_t)tv_now.tv_usec;
sleep_ms(10);
esp_sleep_enable_ext1_wakeup(wakeup_mask, ESP_EXT1_WAKEUP_ANY_HIGH);
esp_deep_sleep_start();
}
void setup() {
// Glitch happens just before here.
struct timeval tv_now;
gettimeofday(&tv_now, NULL);
int64_t now = (int64_t)tv_now.tv_sec * 1000000L + (int64_t)tv_now.tv_usec;
// Enable high power, low efficiency mode for the 3.3V buck converter first of all.
pinMode(NOT_3V3_SLEEP, OUTPUT);
digitalWrite(NOT_3V3_SLEEP, HIGH);
sleep_ms(1);
pinMode(17, OUTPUT);
digitalWrite(17, LOW);
pinMode(16, OUTPUT);
digitalWrite(16, LOW);
pinMode(15, OUTPUT);
digitalWrite(15, LOW);
pinMode(7, OUTPUT);
digitalWrite(7, LOW);
pinMode(6, OUTPUT);
digitalWrite(6, LOW);
// Reconect RTC GPIO so we can toggle them. Do this AFTER pinMode or you get glitching.
rtc_gpio_hold_dis((gpio_num_t)6);
rtc_gpio_hold_dis((gpio_num_t)7);
rtc_gpio_hold_dis((gpio_num_t)15);
rtc_gpio_hold_dis((gpio_num_t)16);
rtc_gpio_hold_dis((gpio_num_t)17);
pinMode(SWITCH, INPUT_PULLDOWN);
Serial.begin(115200);
esp_vfs_dev_uart_use_driver(0);
while (!Serial) {}
uint64_t test = esp_sleep_get_ext1_wakeup_status();
for(int i = 0; i < 64; i++)
{
if(test & (1 << i))
{
printf("Woken by %d.\n", i);
}
}
esp_sleep_wakeup_cause_t wakeup_reason = esp_sleep_get_wakeup_cause();
if(wakeup_reason == ESP_SLEEP_WAKEUP_EXT1)
{
printf("\nSlept for %d seconds.\n\n", (int)((now - rtc_us_at_sleep) / 1000000));
}
else
{
printf("\nPower newly attached (%d).\n\n", wakeup_reason);
}
printf("All setup done. Sleeping...\n");
sleep(2);
SleepSys();
}
void loop() {
sleep_ms(10);
}
Debug Message
No error message, just a glitch of one of the GPIO outputs to floating.
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.