ESP32-S3, switching to Deep-Sleep only when Terminal not running

Hi,
I have a custom board, it has integrated USB/UART bridge CP2102,
with usual 2xNPN circuit for Auto-program switching:

It works correctly, I have already programmed the module many times,
no need to press any Reset or Boot buttons.

There appeared a problem when I started to experiment with Deep-Sleep mode.
I followed example:

my code makes some LED blinking, SPI transfers, I2C transfers, and ends with:
struct timeval now;
gettimeofday(&now, NULL);
printf(“deep sleep (%lds since last reset, %lds since last boot)\n”, now.tv_sec, now.tv_sec-last);
last = now.tv_sec;

// config Timer
esp_sleep_enable_timer_wakeup(1000000LL * 10); // 10s
// config IO
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_AUTO);
gpio_pullup_en((gpio_num_t)PIN_NUM_EGPIO0); // use pullUp on GPIO0
gpio_pulldown_dis((gpio_num_t)PIN_NUM_EGPIO0); // not use pullDown on GPIO0
esp_sleep_enable_ext0_wakeup((gpio_num_t)PIN_NUM_EGPIO0, 0);

printf(“deep sleep\n”);
esp_deep_sleep_start();

So the module should switch to Deep-Sleep, wake up via Timer after 10s or via Button on GPIO0.
I found it works, but only if terminal is not running.
I use Teraterm v4.71 @115200, with setting FlowControl: None.

I used logic analyzer and captured a record of 3 situations:
(UART signals RX,TX,DTR,RTS,
and generated outputs CHIP_PU(EN) and GPIO0)

  1. first 1/3 shows what happens during programming via PlatformIO
  2. after programming PIO makes Reset (approx.time “+10s”) and module works about 8s (deep-sleep)
  3. I start TeraTerm (approx.time “+20s”), DTR,RTS go Low and strange pulses appear on GPIO0,
    it shows period of resetting, about 2.3s, pulses starts 2.1ms after printing the “deep sleep”,
    probably at the moment when it calls esp_deep_sleep_start();

Detail of the pulses on GPIO0:

Why it keeps resetting every 2.3s when Terminal runs ?
Without the Terminal it works correctly and makes cycles of 10s deep-sleep.

I checked +3V3 power rail of ESP32, it seems to be solid, just little (<80us) pulses
when it drops 3.3V → 3.15V, probably because PFET switching power to rail with cap.10uF.
Anyway, I disabled Brownout Reset in Menuconfig. No change.

There are only 4 links between CP2102 and ESP32: U0TXD,U0RXD,CHIP_PU(EN) and GPIO0.
I see only this difference:
a) Terminal not running … DTR=1, RTS=1 (both Idle) → CHIP_PU(EN)=1, GPIO0=1
b) Terminal is running … DTR=0, RTS=0 (both Active) → CHIP_PU(EN)=1, GPIO0=1

I think all 4 signals connected to ESP32 are the same logic levels in both cases.
So why in case b) it keeps resetting instead of switching to deep-sleep ?
And what is explanation of the pulses on GPIO0 ? (program never removes pullUp)

Hi,
I mentioned there is this difference:
a) Terminal not running … DTR=1, RTS=1 (both Idle) → CHIP_PU(EN)=1, GPIO0=1
b) Terminal is running … DTR=0, RTS=0 (both Active) → CHIP_PU(EN)=1, GPIO0=1

In case a) (where deep-sleep works):
if both DTR,RTS=H, then RTS=+3.3V goes through R14=10k and Q2 base-to-collector
to GPIO0, so it is like having pullUp 10k to 2.6V (3.3V - 0.7V drop on Q2).

I tried to add pull-Up resistor 10k to signal GPIO0 and it fixed it, now it switches to deep-sleep
also when Terminal opened (i.e. DTR=0, RTS=0).

Instead on pulse on GPIO0 (image above) there is now voltage drop from original 3.3V to 2.5V all along the deep-sleep. See new image:

I guess it was the drop below 1.8V on GPIO0 what caused Reset when entering deep-sleep;
now it still drops but only downto 2.5V not causing the issue.
Could anybody explain this voltage drop when entering deep-sleep ?
And why it causes Reset (when ext.pull-Up not used) ?

Note: on first start was message:
rst:0x1 (POWERON),boot:0x28 (SPI_FAST_FLASH_BOOT)

on all next starts:
rst:0x1 (POWERON),boot:0x29 (SPI_FAST_FLASH_BOOT)
// BTW: what function is used to read the “boot:0x29” ?