From bd2c1198d9fa94cb70d15ff38e52823277b2de94 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 12 May 2023 14:51:59 -0700 Subject: [PATCH] Minor C3 debug tweaks --- ports/espressif/Makefile | 30 +++++++++++-------- .../common-hal/microcontroller/Pin.c | 5 ++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/ports/espressif/Makefile b/ports/espressif/Makefile index 2151c8e03c..740a87e322 100644 --- a/ports/espressif/Makefile +++ b/ports/espressif/Makefile @@ -120,19 +120,25 @@ CFLAGS += -DSTACK_CANARY_VALUE=0xa5a5a5a5 #Debugging/Optimization ifeq ($(DEBUG), 1) - CFLAGS += -DDEBUG -ggdb - OPTIMIZATION_FLAGS ?= -Og - # You may want to enable these flags to make setting breakpoints easier. - # CFLAGS += -fno-inline -fno-ipa-sra + CFLAGS += -ggdb + ifeq ($(IDF_TARGET_ARCH),riscv) + OPTIMIZATION_FLAGS ?= -Os + CFLAGS += -DNDEBUG + else + OPTIMIZATION_FLAGS ?= -Og + CFLAGS += -DDEBUG + endif + # You may want to enable these flags to make setting breakpoints easier. + # CFLAGS += -fno-inline -fno-ipa-sra else - CFLAGS += -DNDEBUG -ggdb3 - # RISC-V is larger than xtensa - # Use -Os for RISC-V when it overflows - ifeq ($(IDF_TARGET_ARCH),riscv) - OPTIMIZATION_FLAGS ?= -Os - else - OPTIMIZATION_FLAGS ?= -O2 - endif + CFLAGS += -DNDEBUG -ggdb3 + # RISC-V is larger than xtensa + # Use -Os for RISC-V when it overflows + ifeq ($(IDF_TARGET_ARCH),riscv) + OPTIMIZATION_FLAGS ?= -Os + else + OPTIMIZATION_FLAGS ?= -O2 + endif endif # option to override compiler optimization level, set in boards/$(BOARD)/mpconfigboard.mk diff --git a/ports/espressif/common-hal/microcontroller/Pin.c b/ports/espressif/common-hal/microcontroller/Pin.c index 12081c7e40..7c0d05526f 100644 --- a/ports/espressif/common-hal/microcontroller/Pin.c +++ b/ports/espressif/common-hal/microcontroller/Pin.c @@ -62,6 +62,11 @@ static const uint64_t pin_mask_reset_forbidden = GPIO_SEL_18 | // USB D- GPIO_SEL_19 | // USB D+ #endif + #if CONFIG_ESP_CONSOLE_UART_DEFAULT && CONFIG_ESP_CONSOLE_UART_NUM == 0 + // Never reset debug UART/console pins. + GPIO_SEL_20 | + GPIO_SEL_21 | + #endif #endif // ESP32C3 #if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3)