Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest 9.1.x fixes to main #9580

Merged
merged 12 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/actions/upload_aws/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ runs:
steps:
- name: Upload to S3
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository_owner == 'adafruit') ||
(github.event_name == 'release' && (github.event.action == 'published' || github.event.action == 'rerequested'))
(github.event_name == 'push' && github.repository_owner == 'adafruit') &&
(github.ref == 'refs/heads/main' ||
(startswith(github.ref, 'refs/heads/') && endswith(github.ref, '.x'))) ||
(github.event_name == 'release' &&
(github.event.action == 'published' || github.event.action == 'rerequested'))
run: >-
[ -z "$AWS_ACCESS_KEY_ID" ] ||
aws s3 cp ${{ inputs.source }} s3://adafruit-circuit-python/bin/${{ inputs.destination }}
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
version: 2

build:
os: ubuntu-20.04
os: ubuntu-24.04
tools:
python: "3"
jobs:
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/adafruit_feather_esp32_v2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 2) {
// Turn on NeoPixel and I2C power by default.
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 20) {
// Turn on I2C power by default.
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 7) {
// Turn on TFT and I2C
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 21) {
// Turn on TFT and I2C
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 7) {
// Turn on TFT and I2C
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 21) {
// Turn on TFT and I2C
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/adafruit_itsybitsy_esp32/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 2) {
// Turn on NeoPixel and I2C power by default.
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ IDF_TARGET = esp32s3

CIRCUITPY_ESP_FLASH_SIZE = 16MB
CIRCUITPY_ESP_FLASH_MODE = qio
CIRCUITPY_ESP_FLASH_FREQ = 80m
CIRCUITPY_ESP_FLASH_FREQ = 120m

CIRCUITPY_ESP_PSRAM_SIZE = 8MB
CIRCUITPY_ESP_PSRAM_MODE = opi
CIRCUITPY_ESP_PSRAM_FREQ = 80m
CIRCUITPY_ESP_PSRAM_FREQ = 120m

CIRCUITPY_DOTCLOCKFRAMEBUFFER = 1
10 changes: 8 additions & 2 deletions ports/espressif/boards/arduino_nano_esp32s3/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 13) {
// Set D13 LED to input when not in use
gpio_set_direction(pin_number, GPIO_MODE_DEF_INPUT);
gpio_set_pull_mode(pin_number, GPIO_PULLDOWN_ONLY);
gpio_config_t cfg = {
.pin_bit_mask = BIT64(pin_number),
.mode = GPIO_MODE_INPUT,
.pull_up_en = false,
.pull_down_en = true,
.intr_type = GPIO_INTR_DISABLE,
};
gpio_config(&cfg);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 13) {
// Set D13 LED to input when not in use
gpio_set_direction(pin_number, GPIO_MODE_DEF_INPUT);
gpio_set_pull_mode(pin_number, GPIO_PULLDOWN_ONLY);
gpio_config_t cfg = {
.pin_bit_mask = BIT64(pin_number),
.mode = GPIO_MODE_INPUT,
.pull_up_en = false,
.pull_down_en = true,
.intr_type = GPIO_INTR_DISABLE,
};
gpio_config(&cfg);
return true;
}

Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/cytron_maker_feather_aiot_s3/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {

void reset_board(void) {
// Turn on VP by default.
gpio_set_direction(11, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(11, true);
config_pin_as_output_with_level(11, true);
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
3 changes: 1 addition & 2 deletions ports/espressif/boards/hexky_s2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 21) {
// Turn on TFT and I2C
gpio_set_direction(21, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(21, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/lilygo_tdisplay_s3/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Override the I2C/TFT power pin reset to prevent resetting the display.
if (pin_number == 15) {
// Turn on TFT
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/lilygo_twatch_2020_v3/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ void board_init(void) {
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == MOTOR_PIN) {
// no motor
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/m5stack_core_basic/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ void board_init(void) {
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Set speaker gpio to ground to prevent noise from the speaker
if (pin_number == 25) {
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/m5stack_core_fire/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ void board_init(void) {
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Set speaker gpio to ground to prevent noise from the speaker
if (pin_number == 25) {
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
Expand Down
5 changes: 2 additions & 3 deletions ports/espressif/boards/m5stack_dial/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ void board_init(void) {
}

bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Hold pind must be set high to avoid a power off when battery powered
// Hold pin must be set high to avoid a power off when battery powered
if (pin_number == 46) {
// Turn on hold output
gpio_set_direction(46, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(46, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/m5stack_stick_c/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ void board_init(void) {
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Set IR led gpio high to prevent power drain from the led
if (pin_number == 9) {
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/m5stack_stick_c_plus/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ void board_init(void) {
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Set IR led gpio high to prevent power drain from the led
if (pin_number == 9) {
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/m5stack_timer_camera_x/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
* when usb is disconnected or
* the power button is released.
*/
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/seeed_xiao_esp32c6/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 16) {
// Turn on I2C power by default.
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, true);
config_pin_as_output_with_level(pin_number, true);
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions ports/espressif/boards/seeed_xiao_esp32c6/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ IDF_TARGET = esp32c6
CIRCUITPY_ESP_FLASH_MODE = qio
CIRCUITPY_ESP_FLASH_FREQ = 80m
CIRCUITPY_ESP_FLASH_SIZE = 4MB

CIRCUITPY_ESP_USB_SERIAL_JTAG = 1
10 changes: 3 additions & 7 deletions ports/espressif/boards/sqfmi_watchy/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,16 @@ bool board_requests_safe_mode(void) {

bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
if (pin_number == 13) {
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
}

void reset_board(void) {
gpio_set_direction(13, GPIO_MODE_OUTPUT);
gpio_set_level(13, false);

config_pin_as_output_with_level(13, false);
}

void board_deinit(void) {
gpio_set_direction(13, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(13, false);
config_pin_as_output_with_level(13, false);
}
3 changes: 1 addition & 2 deletions ports/espressif/boards/sunton_esp32_2432S028/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Pull the speaker pin low to reduce noise on reset
if (pin_number == 26) {
// Turn on TFT
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
Expand Down
3 changes: 1 addition & 2 deletions ports/espressif/boards/sunton_esp32_2432S032C/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
// Pull the speaker pin low to reduce noise on reset
if (pin_number == 26) {
// Turn on audio
gpio_set_direction(pin_number, GPIO_MODE_DEF_OUTPUT);
gpio_set_level(pin_number, false);
config_pin_as_output_with_level(pin_number, false);
return true;
}
return false;
Expand Down
20 changes: 19 additions & 1 deletion ports/espressif/common-hal/busio/UART.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,22 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
self->timeout_ms = timeout * 1000;

self->uart_num = UART_NUM_MAX;
for (uart_port_t num = 0; num < UART_NUM_MAX; num++) {

// ESP32-C6 and ESP32-P4 both have a single LP (low power) UART, which is
// limited in what it can do and which pins it can use. Ignore it for now.
// Its UART number is higher than the numbers for the regular ("HP", high-power) UARTs.

// SOC_UART_LP_NUM is not defined for chips without an LP UART.
#if defined(SOC_UART_LP_NUM) && (SOC_UART_LP_NUM >= 1)
#define UART_LIMIT LP_UART_NUM_0
#else
#define UART_LIMIT UART_NUM_MAX
#endif

for (uart_port_t num = 0; num < UART_LIMIT; num++) {
if (!uart_is_driver_installed(num)) {
self->uart_num = num;
break;
}
}
if (self->uart_num == UART_NUM_MAX) {
Expand Down Expand Up @@ -224,6 +237,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
int rx_num = -1;
int rts_num = -1;
int cts_num = -1;

if (have_tx) {
claim_pin(tx);
self->tx_pin = tx;
Expand Down Expand Up @@ -254,9 +268,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
self->rts_pin = rs485_dir;
rts_num = rs485_dir->number;
}

if (uart_set_pin(self->uart_num, tx_num, rx_num, rts_num, cts_num) != ESP_OK) {
// Uninstall driver and clean up.
common_hal_busio_uart_deinit(self);
raise_ValueError_invalid_pins();
}

if (have_rx) {
// On ESP32-C3 and ESP32-S3 (at least), a junk byte with zero or more consecutive 1's can be
// generated, even if the pin is pulled high (normal UART resting state) to begin with.
Expand Down
13 changes: 13 additions & 0 deletions ports/espressif/common-hal/microcontroller/Pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,3 +393,16 @@ bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin) {
uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin) {
return pin ? pin->number : NO_PIN;
}

void config_pin_as_output_with_level(gpio_num_t pin_number, bool level) {
gpio_config_t cfg = {
.pin_bit_mask = BIT64(pin_number),
.mode = GPIO_MODE_OUTPUT,
.pull_up_en = false,
.pull_down_en = false,
.intr_type = GPIO_INTR_DISABLE,
};
gpio_config(&cfg);

gpio_set_level(pin_number, level);
}
4 changes: 4 additions & 0 deletions ports/espressif/common-hal/microcontroller/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ extern void clear_pin_preservations(void);
// Return true to indicate that the pin was reset. Returning false will lead to
// the port-default reset behavior.
extern bool espressif_board_reset_pin_number(gpio_num_t pin_number);

// Configure the IOMUX for the pin as GPIO, set the pin as output, and then set output the level.
// This ensures the IOMUX setting is correct.
extern void config_pin_as_output_with_level(gpio_num_t pin_number, bool level);
15 changes: 15 additions & 0 deletions ports/espressif/esp-idf-config/sdkconfig-flash-120m.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CONFIG_ESPTOOLPY_FLASHFREQ_120M=y
# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_64M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_60M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_48M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_40M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_32M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_30M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_24M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_16M is not set
# CONFIG_ESPTOOLPY_FLASHFREQ_15M is not set
CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y
CONFIG_SPI_FLASH_UNDER_HIGH_FREQ=y
Loading