Skip to content

Commit b0efd13

Browse files
committed
ESP32 REPL working through debug UART
1 parent 780c496 commit b0efd13

File tree

5 files changed

+18
-24
lines changed

5 files changed

+18
-24
lines changed

ports/espressif/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ ESP_AUTOGEN_LD = $(BUILD)/esp-idf/esp-idf/$(IDF_TARGET)/$(IDF_TARGET)_out.ld $(B
412412

413413
FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
414414

415-
ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset --baud 460800
415+
ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset --baud 921600
416416

417417
ifeq ($(UF2_BOOTLOADER),1)
418418
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2

ports/espressif/boards/adafruit_feather_esp32_v2/sdkconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB-no-uf2.csv"
3434
# ESP32-specific
3535
#
3636
CONFIG_ESP32_SPIRAM_SUPPORT=y
37+
CONFIG_UART_ISR_IN_IRAM=y
3738
# end of ESP32-specific
3839

3940
#

ports/espressif/common-hal/busio/UART.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ static void uart_event_task(void *param) {
7575
void uart_reset(void) {
7676
for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
7777
// Ignore the UART used by the IDF.
78-
#ifdef CONFIG_CONSOLE_UART_NUM
79-
if (num == CONFIG_CONSOLE_UART_NUM) {
78+
#ifdef CONFIG_ESP_CONSOLE_UART_NUM
79+
if (num == CONFIG_ESP_CONSOLE_UART_NUM) {
8080
continue;
8181
}
8282
#endif

ports/espressif/common-hal/microcontroller/Pin.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@
3333
#include "components/driver/include/driver/gpio.h"
3434
#include "components/hal/include/hal/gpio_hal.h"
3535

36-
#include "esp_log.h"
37-
#include "freertos/FreeRTOS.h"
38-
#include "freertos/task.h"
36+
STATIC uint64_t never_reset_pins;
37+
STATIC uint64_t in_use;
3938

40-
STATIC uint32_t never_reset_pins[2];
41-
STATIC uint32_t in_use[2];
39+
// 64-bit pin mask for a single bit
40+
#define PIN_BIT(pin_number) (((uint64_t)1) << pin_number)
4241

4342
// Bit mask of all pins that should never ever be reset.
4443
// Typically these are SPI flash and PSRAM control pins, and communication pins.
@@ -111,7 +110,7 @@ void never_reset_pin_number(gpio_num_t pin_number) {
111110
if (pin_number == NO_PIN) {
112111
return;
113112
}
114-
never_reset_pins[pin_number / 32] |= 1 << pin_number % 32;
113+
never_reset_pins |= PIN_BIT(pin_number);
115114
}
116115

117116
void common_hal_never_reset_pin(const mcu_pin_obj_t *pin) {
@@ -127,7 +126,7 @@ MP_WEAK bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
127126

128127
STATIC void _reset_pin(gpio_num_t pin_number) {
129128
// Never ever reset pins used for flash, RAM, and basic communication.
130-
if (pin_mask_reset_forbidden & (((uint64_t)1) << pin_number)) {
129+
if (pin_mask_reset_forbidden & PIN_BIT(pin_number)) {
131130
return;
132131
}
133132

@@ -152,8 +151,8 @@ void reset_pin_number(gpio_num_t pin_number) {
152151
if (pin_number == NO_PIN) {
153152
return;
154153
}
155-
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
156-
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
154+
never_reset_pins &= ~PIN_BIT(pin_number);
155+
in_use &= ~PIN_BIT(pin_number);
157156

158157
_reset_pin(pin_number);
159158
}
@@ -170,40 +169,34 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
170169
}
171170

172171
void reset_all_pins(void) {
173-
ESP_LOGI("Pin.c", "reset_all_pins");
174172
for (uint8_t i = 0; i < GPIO_PIN_COUNT; i++) {
175173
uint32_t iomux_address = GPIO_PIN_MUX_REG[i];
176174
if (iomux_address == 0 ||
177-
(never_reset_pins[i / 32] & (1 << i % 32)) != 0) {
175+
(never_reset_pins & PIN_BIT(i))) {
178176
continue;
179177
}
180-
ESP_LOGI("Pin.c", "about to reset pin %d", i);
181-
vTaskDelay(100);
182178
_reset_pin(i);
183179
}
184-
in_use[0] = never_reset_pins[0];
185-
in_use[1] = never_reset_pins[1];
180+
in_use = never_reset_pins;
186181
}
187182

188183
void claim_pin_number(gpio_num_t pin_number) {
189184
if (pin_number == NO_PIN) {
190185
return;
191186
}
192-
in_use[pin_number / 32] |= (1 << (pin_number % 32));
187+
in_use |= PIN_BIT(pin_number);
193188
}
194189

195190
void claim_pin(const mcu_pin_obj_t *pin) {
196-
in_use[pin->number / 32] |= (1 << (pin->number % 32));
191+
claim_pin_number(pin->number);
197192
}
198193

199194
void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin) {
200195
claim_pin(pin);
201196
}
202197

203198
bool pin_number_is_free(gpio_num_t pin_number) {
204-
uint8_t offset = pin_number / 32;
205-
uint32_t mask = 1 << (pin_number % 32);
206-
return (in_use[offset] & mask) == 0;
199+
return in_use & PIN_BIT(pin_number);
207200
}
208201

209202
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {

supervisor/shared/serial.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include "py/mpprint.h"
5555
#include "shared-bindings/busio/UART.h"
5656
busio_uart_obj_t debug_uart;
57-
byte buf_array[64];
57+
byte buf_array[256];
5858
#endif
5959

6060
#if CIRCUITPY_USB_VENDOR

0 commit comments

Comments
 (0)