ESP32 REPL working through debug UART

This commit is contained in:
Dan Halbert 2022-06-29 23:19:36 -04:00
parent 780c4963cb
commit b0efd130c9
5 changed files with 18 additions and 24 deletions

View File

@ -412,7 +412,7 @@ ESP_AUTOGEN_LD = $(BUILD)/esp-idf/esp-idf/$(IDF_TARGET)/$(IDF_TARGET)_out.ld $(B
FLASH_FLAGS = --flash_mode $(CIRCUITPY_ESP_FLASH_MODE) --flash_freq $(CIRCUITPY_ESP_FLASH_FREQ) --flash_size $(CIRCUITPY_ESP_FLASH_SIZE)
ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset --baud 460800
ESPTOOL_FLAGS ?= --before=default_reset --after=no_reset --baud 921600
ifeq ($(UF2_BOOTLOADER),1)
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2

View File

@ -34,6 +34,7 @@ CONFIG_PARTITION_TABLE_FILENAME="esp-idf-config/partitions-8MB-no-uf2.csv"
# ESP32-specific
#
CONFIG_ESP32_SPIRAM_SUPPORT=y
CONFIG_UART_ISR_IN_IRAM=y
# end of ESP32-specific
#

View File

@ -75,8 +75,8 @@ static void uart_event_task(void *param) {
void uart_reset(void) {
for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {
// Ignore the UART used by the IDF.
#ifdef CONFIG_CONSOLE_UART_NUM
if (num == CONFIG_CONSOLE_UART_NUM) {
#ifdef CONFIG_ESP_CONSOLE_UART_NUM
if (num == CONFIG_ESP_CONSOLE_UART_NUM) {
continue;
}
#endif

View File

@ -33,12 +33,11 @@
#include "components/driver/include/driver/gpio.h"
#include "components/hal/include/hal/gpio_hal.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
STATIC uint64_t never_reset_pins;
STATIC uint64_t in_use;
STATIC uint32_t never_reset_pins[2];
STATIC uint32_t in_use[2];
// 64-bit pin mask for a single bit
#define PIN_BIT(pin_number) (((uint64_t)1) << pin_number)
// Bit mask of all pins that should never ever be reset.
// 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) {
if (pin_number == NO_PIN) {
return;
}
never_reset_pins[pin_number / 32] |= 1 << pin_number % 32;
never_reset_pins |= PIN_BIT(pin_number);
}
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) {
STATIC void _reset_pin(gpio_num_t pin_number) {
// Never ever reset pins used for flash, RAM, and basic communication.
if (pin_mask_reset_forbidden & (((uint64_t)1) << pin_number)) {
if (pin_mask_reset_forbidden & PIN_BIT(pin_number)) {
return;
}
@ -152,8 +151,8 @@ void reset_pin_number(gpio_num_t pin_number) {
if (pin_number == NO_PIN) {
return;
}
never_reset_pins[pin_number / 32] &= ~(1 << pin_number % 32);
in_use[pin_number / 32] &= ~(1 << pin_number % 32);
never_reset_pins &= ~PIN_BIT(pin_number);
in_use &= ~PIN_BIT(pin_number);
_reset_pin(pin_number);
}
@ -170,30 +169,26 @@ void common_hal_reset_pin(const mcu_pin_obj_t *pin) {
}
void reset_all_pins(void) {
ESP_LOGI("Pin.c", "reset_all_pins");
for (uint8_t i = 0; i < GPIO_PIN_COUNT; i++) {
uint32_t iomux_address = GPIO_PIN_MUX_REG[i];
if (iomux_address == 0 ||
(never_reset_pins[i / 32] & (1 << i % 32)) != 0) {
(never_reset_pins & PIN_BIT(i))) {
continue;
}
ESP_LOGI("Pin.c", "about to reset pin %d", i);
vTaskDelay(100);
_reset_pin(i);
}
in_use[0] = never_reset_pins[0];
in_use[1] = never_reset_pins[1];
in_use = never_reset_pins;
}
void claim_pin_number(gpio_num_t pin_number) {
if (pin_number == NO_PIN) {
return;
}
in_use[pin_number / 32] |= (1 << (pin_number % 32));
in_use |= PIN_BIT(pin_number);
}
void claim_pin(const mcu_pin_obj_t *pin) {
in_use[pin->number / 32] |= (1 << (pin->number % 32));
claim_pin_number(pin->number);
}
void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin) {
@ -201,9 +196,7 @@ void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin) {
}
bool pin_number_is_free(gpio_num_t pin_number) {
uint8_t offset = pin_number / 32;
uint32_t mask = 1 << (pin_number % 32);
return (in_use[offset] & mask) == 0;
return in_use & PIN_BIT(pin_number);
}
bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {

View File

@ -54,7 +54,7 @@
#include "py/mpprint.h"
#include "shared-bindings/busio/UART.h"
busio_uart_obj_t debug_uart;
byte buf_array[64];
byte buf_array[256];
#endif
#if CIRCUITPY_USB_VENDOR