Skip to content

Commit 5fcf8ae

Browse files
committed
Merge remote-tracking branch 'adafruit/main' into synthio_fixedpoint_fix
2 parents 511df46 + 36bc41c commit 5fcf8ae

File tree

41 files changed

+524
-117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+524
-117
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
[submodule "ports/raspberrypi/sdk"]
174174
path = ports/raspberrypi/sdk
175175
url = https://github.com/adafruit/pico-sdk.git
176-
branch = force_inline_critical_section
176+
branch = force_inline_critical_section_2.1.1
177177
[submodule "data/nvm.toml"]
178178
path = data/nvm.toml
179179
url = https://github.com/adafruit/nvm.toml.git

extmod/vfs_fat.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
// CIRCUITPY-CHANGE: extra includes
4040
#include <string.h>
41+
#include "py/gc.h"
4142
#include "py/obj.h"
4243
#include "py/objproperty.h"
4344
#include "py/runtime.h"
@@ -342,7 +343,10 @@ static mp_obj_t fat_vfs_stat(mp_obj_t vfs_in, mp_obj_t path_in) {
342343
FRESULT res = f_stat(&self->fatfs, path, &fno);
343344
if (res != FR_OK) {
344345
// CIRCUITPY-CHANGE
345-
mp_raise_OSError_fresult(res);
346+
if (gc_alloc_possible()) {
347+
mp_raise_OSError_fresult(res);
348+
}
349+
return mp_const_none;
346350
}
347351
}
348352

locale/sv.po

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ msgstr ""
66
"Project-Id-Version: PACKAGE VERSION\n"
77
"Report-Msgid-Bugs-To: \n"
88
"POT-Creation-Date: 2021-01-04 12:55-0600\n"
9-
"PO-Revision-Date: 2025-04-21 18:19+0000\n"
9+
"PO-Revision-Date: 2025-04-23 08:01+0000\n"
1010
"Last-Translator: Jonny Bergdahl <[email protected]>\n"
1111
"Language-Team: LANGUAGE <[email protected]>\n"
1212
"Language: sv\n"
@@ -2642,7 +2642,7 @@ msgstr "bits måste vara 32 eller färre"
26422642
#: shared-bindings/audiofilters/Distortion.c
26432643
#: shared-bindings/audiodelays/Reverb.c
26442644
msgid "bits_per_sample must be 16"
2645-
msgstr ""
2645+
msgstr "bits_per_sample måste vara 16"
26462646

26472647
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Distortion.c
26482648
#: shared-bindings/audiofilters/Filter.c shared-bindings/audiomixer/Mixer.c
@@ -4071,7 +4071,7 @@ msgstr "rsplit(None,n)"
40714071

40724072
#: shared-bindings/audiodelays/Reverb.c
40734073
msgid "samples_signed must be true"
4074-
msgstr ""
4074+
msgstr "samples_signed måste vara sann"
40754075

40764076
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
40774077
#: ports/raspberrypi/common-hal/audiobusio/PDMIn.c
@@ -4080,7 +4080,7 @@ msgstr "samplingsfrekvens utanför räckvidden"
40804080

40814081
#: py/modmicropython.c
40824082
msgid "schedule queue full"
4083-
msgstr "schemakön full"
4083+
msgstr "schemakö full"
40844084

40854085
#: py/builtinimport.c
40864086
msgid "script compilation not supported"

main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,19 @@ static bool __attribute__((noinline)) run_code_py(safe_mode_t safe_mode, bool *s
457457
usb_setup_with_vm();
458458
#endif
459459

460+
// Always return to root before trying to run files.
461+
common_hal_os_chdir("/");
460462
// Check if a different run file has been allocated
461463
if (next_code_configuration != NULL) {
462464
next_code_configuration->options &= ~SUPERVISOR_NEXT_CODE_OPT_NEWLY_SET;
463465
next_code_options = next_code_configuration->options;
464466
if (next_code_configuration->filename[0] != '\0') {
467+
if (next_code_configuration->working_directory != NULL) {
468+
common_hal_os_chdir(next_code_configuration->working_directory);
469+
}
465470
// This is where the user's python code is actually executed:
466471
const char *const filenames[] = { next_code_configuration->filename };
467-
found_main = maybe_run_list(filenames, MP_ARRAY_SIZE(filenames));
472+
found_main = maybe_run_list(filenames, 1);
468473
if (!found_main) {
469474
serial_write(next_code_configuration->filename);
470475
serial_write_compressed(MP_ERROR_TEXT(" not found.\n"));
@@ -1105,9 +1110,6 @@ int __attribute__((used)) main(void) {
11051110
}
11061111
simulate_reset = false;
11071112

1108-
// Always return to root before trying to run files.
1109-
common_hal_os_chdir("/");
1110-
11111113
if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) {
11121114
// If code.py did a fake deep sleep, pretend that we
11131115
// are running code.py for the first time after a hard

ports/atmel-samd/boards/circuitbrains_basic_m0/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ SPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q32JVxQ"
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_CODEOP = 0
1314
CIRCUITPY_JPEGIO = 0

ports/atmel-samd/boards/circuitbrains_deluxe_m4/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "W25Q64JVxQ, S25FL064L"
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_PS2IO = 1
1415
CIRCUITPY_JPEGIO = 0
1516
CIRCUITPY_SPITARGET = 0

ports/atmel-samd/boards/datalore_ip_m4/mpconfigboard.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ CHIP_FAMILY = samd51
99
QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "GD25Q16C, W25Q16JVxQ, W25Q16JVxM"
1111
LONGINT_IMPL = MPZ
12-
CIRCUITPY_SYNTHIO = 0
12+
13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_JPEGIO = 0
1415
CIRCUITPY_SPITARGET = 0
16+
CIRCUITPY_SYNTHIO = 0
1517
CIRCUITPY_TILEPALETTEMAPPER = 0

ports/atmel-samd/boards/feather_m0_supersized/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ CHIP_FAMILY = samd21
99
SPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = "S25FL064L"
1111
LONGINT_IMPL = MPZ
12+
13+
CIRCUITPY_CODEOP = 0

ports/atmel-samd/boards/feather_m4_can/mpconfigboard.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ CIRCUITPY__EVE = 1
1414
CIRCUITPY_BITMAPFILTER = 0
1515
CIRCUITPY_CANIO = 1
1616
CIRCUITPY_FLOPPYIO = 0
17-
CIRCUITPY_SYNTHIO = 0
1817
CIRCUITPY_GIFIO = 0
18+
CIRCUITPY_I2CTARGET = 0
1919
CIRCUITPY_JPEGIO = 0
20+
CIRCUITPY_SYNTHIO = 0
2021

2122
CIRCUITPY_LTO_PARTITION = one
2223

ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = GD25Q16C
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_FLOPPYIO = 0
14+
CIRCUITPY_I2CTARGET = 0
15+
CIRCUITPY_JPEGIO = 0
1316
CIRCUITPY_KEYPAD = 1
1417
CIRCUITPY_SYNTHIO = 0
15-
CIRCUITPY_JPEGIO = 0
16-
CIRCUITPY_FLOPPYIO = 0
1718
CIRCUITPY_TERMINALIO_VT100 = 0
1819
CIRCUITPY_TILEPALETTEMAPPER = 0

ports/atmel-samd/boards/silicognition-m4-shim/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ QSPI_FLASH_FILESYSTEM = 1
1010
EXTERNAL_FLASH_DEVICES = GD25Q16C
1111
LONGINT_IMPL = MPZ
1212

13+
CIRCUITPY_I2CTARGET = 0
1314
CIRCUITPY_JPEGIO = 0
1415
CIRCUITPY_SPITARGET = 0
1516
CIRCUITPY_SYNTHIO = 0

ports/atmel-samd/mpconfigport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
// See https://github.com/micropython/micropython/pull/11353
5252
#define MICROPY_NLR_THUMB_USE_LONG_JUMP (1)
5353

54+
// Don't store qstr hashes and do string compares instead.
55+
#define MICROPY_QSTR_BYTES_IN_HASH (0)
5456

5557
#endif // SAMD21
5658

ports/espressif/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,19 @@ CFLAGS += \
360360
-DCFG_TUD_TASK_QUEUE_SZ=32
361361
endif
362362
ifeq ($(CIRCUITPY_USB_DEVICE),1)
363+
ifeq ($(IDF_TARGET),esp32s2)
364+
# Make more room in internal RAM on the S2.
365+
CFLAGS += \
366+
-DCFG_TUD_CDC_RX_BUFSIZE=128 \
367+
-DCFG_TUD_CDC_TX_BUFSIZE=128 \
368+
-DCFG_TUD_MSC_BUFSIZE=1024
369+
else
363370
CFLAGS += \
364371
-DCFG_TUD_CDC_RX_BUFSIZE=1024 \
365372
-DCFG_TUD_CDC_TX_BUFSIZE=1024 \
366-
-DCFG_TUD_MSC_BUFSIZE=4096 \
373+
-DCFG_TUD_MSC_BUFSIZE=4096
374+
endif
375+
CFLAGS += \
367376
-DCFG_TUD_MIDI_RX_BUFSIZE=128 \
368377
-DCFG_TUD_MIDI_TX_BUFSIZE=128 \
369378
-DCFG_TUD_VENDOR_RX_BUFSIZE=128 \

ports/espressif/common-hal/wifi/Radio.c

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,44 @@ void common_hal_wifi_radio_set_tx_power(wifi_radio_obj_t *self, const mp_float_t
139139
esp_wifi_set_max_tx_power(tx_power * 4.0f);
140140
}
141141

142-
mp_int_t common_hal_wifi_radio_get_listen_interval(wifi_radio_obj_t *self) {
143-
wifi_config_t *config = &self->sta_config;
144-
return config->sta.listen_interval;
142+
wifi_power_management_t common_hal_wifi_radio_get_power_management(wifi_radio_obj_t *self) {
143+
wifi_ps_type_t ps;
144+
esp_err_t ret = esp_wifi_get_ps(&ps);
145+
if (ret == ESP_OK) {
146+
switch (ps) {
147+
case WIFI_PS_MIN_MODEM:
148+
return POWER_MANAGEMENT_MIN;
149+
case WIFI_PS_MAX_MODEM:
150+
return POWER_MANAGEMENT_MAX;
151+
case WIFI_PS_NONE:
152+
return POWER_MANAGEMENT_NONE;
153+
}
154+
}
155+
return POWER_MANAGEMENT_MIN;
145156
}
146157

147-
void common_hal_wifi_radio_set_listen_interval(wifi_radio_obj_t *self, const mp_int_t listen_interval) {
148-
wifi_config_t *config = &self->sta_config;
149-
config->sta.listen_interval = listen_interval;
150-
if (listen_interval == 1) {
151-
esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
152-
} else if (listen_interval > 1) {
153-
esp_wifi_set_ps(WIFI_PS_MAX_MODEM);
154-
} else {
155-
esp_wifi_set_ps(WIFI_PS_NONE);
156-
}
157158

158-
esp_wifi_set_config(ESP_IF_WIFI_STA, config);
159+
void common_hal_wifi_radio_set_power_management(wifi_radio_obj_t *self, wifi_power_management_t power_management) {
160+
switch (power_management) {
161+
case POWER_MANAGEMENT_MIN:
162+
esp_wifi_set_ps(WIFI_PS_MIN_MODEM);
163+
break;
164+
case POWER_MANAGEMENT_MAX: {
165+
// listen_interval is only used in this case.
166+
wifi_config_t *config = &self->sta_config;
167+
// This is a typical value seen in various examples.
168+
config->sta.listen_interval = 3;
169+
esp_wifi_set_ps(WIFI_PS_MAX_MODEM);
170+
esp_wifi_set_config(ESP_IF_WIFI_STA, config);
171+
}
172+
break;
173+
case POWER_MANAGEMENT_NONE:
174+
esp_wifi_set_ps(WIFI_PS_NONE);
175+
break;
176+
case POWER_MANAGEMENT_UNKNOWN:
177+
// This should be prevented in shared-bindings.
178+
break;
179+
}
159180
}
160181

161182
mp_obj_t common_hal_wifi_radio_get_mac_address_ap(wifi_radio_obj_t *self) {

ports/espressif/mpconfigport.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ CIRCUITPY_FULL_BUILD ?= 1
4040
# If SSL is enabled, it's mbedtls
4141
CIRCUITPY_SSL_MBEDTLS = 1
4242

43-
# Wifi Power Save
44-
CIRCUITPY_WIFI_RADIO_SETTABLE_LISTEN_INTERVAL = 1
45-
4643
# Never use our copy of MBEDTLS
4744
CIRCUITPY_HASHLIB_MBEDTLS_ONLY = 0
4845

ports/raspberrypi/audio_dma.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,13 @@ static void audio_dma_load_next_block(audio_dma_t *dma, size_t buffer_idx) {
159159
!dma_channel_is_busy(dma->channel[1])) {
160160
// No data has been read, and both DMA channels have now finished, so it's safe to stop.
161161
audio_dma_stop(dma);
162+
dma->dma_result = AUDIO_DMA_OK;
163+
return;
162164
}
163165
}
164166
}
167+
// Enable the channel so that it can be played.
168+
dma_hw->ch[dma_channel].al1_ctrl |= DMA_CH1_CTRL_TRIG_EN_BITS;
165169
dma->dma_result = AUDIO_DMA_OK;
166170
}
167171

@@ -227,15 +231,31 @@ audio_dma_result audio_dma_setup_playback(
227231
max_buffer_length /= dma->sample_spacing;
228232
}
229233

234+
#ifdef PICO_RP2350
230235
dma->buffer[0] = (uint8_t *)port_realloc(dma->buffer[0], max_buffer_length, true);
236+
#else
237+
dma->buffer[0] = (uint8_t *)m_realloc(dma->buffer[0],
238+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
239+
dma->buffer_length[0], // Old size
240+
#endif
241+
max_buffer_length);
242+
#endif
231243
dma->buffer_length[0] = max_buffer_length;
232244

233245
if (dma->buffer[0] == NULL) {
234246
return AUDIO_DMA_MEMORY_ERROR;
235247
}
236248

237249
if (!single_buffer) {
250+
#ifdef PICO_RP2350
238251
dma->buffer[1] = (uint8_t *)port_realloc(dma->buffer[1], max_buffer_length, true);
252+
#else
253+
dma->buffer[1] = (uint8_t *)m_realloc(dma->buffer[1],
254+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
255+
dma->buffer_length[1], // Old size
256+
#endif
257+
max_buffer_length);
258+
#endif
239259
dma->buffer_length[1] = max_buffer_length;
240260

241261
if (dma->buffer[1] == NULL) {
@@ -429,11 +449,27 @@ void audio_dma_init(audio_dma_t *dma) {
429449
}
430450

431451
void audio_dma_deinit(audio_dma_t *dma) {
452+
#ifdef PICO_RP2350
432453
port_free(dma->buffer[0]);
454+
#else
455+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
456+
m_free(dma->buffer[0], dma->buffer_length[0]);
457+
#else
458+
m_free(dma->buffer[0]);
459+
#endif
460+
#endif
433461
dma->buffer[0] = NULL;
434462
dma->buffer_length[0] = 0;
435463

464+
#ifdef PICO_RP2350
436465
port_free(dma->buffer[1]);
466+
#else
467+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
468+
m_free(dma->buffer[1], dma->buffer_length[1]);
469+
#else
470+
m_free(dma->buffer[1]);
471+
#endif
472+
#endif
437473
dma->buffer[1] = NULL;
438474
dma->buffer_length[1] = 0;
439475
}
@@ -462,18 +498,26 @@ static void dma_callback_fun(void *arg) {
462498

463499
// Load the blocks for the requested channels.
464500
uint32_t channel = 0;
501+
size_t filled_count = 0;
465502
while (channels_to_load_mask) {
466503
if (channels_to_load_mask & 1) {
467504
if (dma->channel[0] == channel) {
468505
audio_dma_load_next_block(dma, 0);
506+
filled_count++;
469507
}
470508
if (dma->channel[1] == channel) {
471509
audio_dma_load_next_block(dma, 1);
510+
filled_count++;
472511
}
473512
}
474513
channels_to_load_mask >>= 1;
475514
channel++;
476515
}
516+
// If we had to fill both buffers, then we missed the trigger from the other
517+
// buffer. So restart the DMA.
518+
if (filled_count == 2) {
519+
dma_channel_start(dma->channel[0]);
520+
}
477521
}
478522

479523
void __not_in_flash_func(isr_dma_0)(void) {
@@ -491,6 +535,8 @@ void __not_in_flash_func(isr_dma_0)(void) {
491535
audio_dma_t *dma = MP_STATE_PORT(playing_audio)[i];
492536
// Record all channels whose DMA has completed; they need loading.
493537
dma->channels_to_load_mask |= mask;
538+
// Disable the channel so that we don't play it without filling it.
539+
dma_hw->ch[i].al1_ctrl &= ~DMA_CH0_CTRL_TRIG_EN_BITS;
494540
background_callback_add(&dma->callback, dma_callback_fun, (void *)dma);
495541
}
496542
if (MP_STATE_PORT(background_pio_read)[i] != NULL) {

ports/raspberrypi/audio_dma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ typedef enum {
2020

2121
typedef struct {
2222
mp_obj_t sample;
23-
uint8_t *buffer[2]; // Allocated through port_malloc so they are dma-able
23+
uint8_t *buffer[2]; // Allocated through port_malloc on RP2350 so they are dma-able
2424
size_t buffer_length[2];
2525
uint32_t channels_to_load_mask;
2626
uint32_t output_register_address;

0 commit comments

Comments
 (0)