From f882571366282a17a89aea60e58265227a248d12 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Fri, 7 Oct 2022 08:04:08 -0500 Subject: [PATCH 1/5] pico w: pins improvements Closes: #7017 * Remove the 'GP23' alias for CYW1 * Remove the 'CYW0' alias for CYW0 * Switch VBUS_SENSE to CYW2, remove 'GP24' alias Code that wants to use SMPS_MODE, VBUS_SENSE and LED while being portable to the W and non-W variants should use those names, not alias names. * Remove A3 / VOLTAGE_MONITOR Right now this cannot be used. The ability to check the voltage monitor should be added back in some fashion in the future. --- ports/raspberrypi/Makefile | 2 +- ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c | 10 ++-------- .../raspberrypi/common-hal/microcontroller/__init__.c | 3 +++ ports/raspberrypi/peripherals/pins.c | 5 +++++ ports/raspberrypi/peripherals/pins.h | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ports/raspberrypi/Makefile b/ports/raspberrypi/Makefile index bee6650577..5095c4c1f8 100644 --- a/ports/raspberrypi/Makefile +++ b/ports/raspberrypi/Makefile @@ -65,7 +65,7 @@ INC_CYW43 := \ -isystem sdk/src/rp2_common/pico_cyw43_arch/include/ \ -isystem sdk/src/rp2_common/pico_lwip/include/ \ -CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DCYW43_LOGIC_DEBUG=0 +CFLAGS_CYW43 := -DCYW43_LWIP=1 -DPICO_CYW43_ARCH_THREADSAFE_BACKGROUND=1 -DCYW43_USE_SPI -DIGNORE_GPIO25 -DIGNORE_GPIO23 -DIGNORE_GPIO24 -DCYW43_LOGIC_DEBUG=0 SRC_SDK_CYW43 := \ src/common/pico_sync/sem.c \ src/rp2_common/cyw43_driver/cyw43_bus_pio_spi.c \ diff --git a/ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c b/ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c index 86a6bacc5d..b3c3c93d57 100644 --- a/ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c +++ b/ports/raspberrypi/boards/raspberry_pi_pico_w/pins.c @@ -28,13 +28,10 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GP22), MP_ROM_PTR(&pin_GPIO22) }, { MP_ROM_QSTR(MP_QSTR_SMPS_MODE), MP_ROM_PTR(&pin_CYW1) }, - { MP_ROM_QSTR(MP_QSTR_GP23), MP_ROM_PTR(&pin_CYW1) }, - - { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_GPIO24) }, - { MP_ROM_QSTR(MP_QSTR_GP24), MP_ROM_PTR(&pin_GPIO24) }, { MP_ROM_QSTR(MP_QSTR_LED), MP_ROM_PTR(&pin_CYW0) }, - { MP_ROM_QSTR(MP_QSTR_CYW0), MP_ROM_PTR(&pin_CYW0) }, + + { MP_ROM_QSTR(MP_QSTR_VBUS_SENSE), MP_ROM_PTR(&pin_CYW2) }, { MP_ROM_QSTR(MP_QSTR_GP26_A0), MP_ROM_PTR(&pin_GPIO26) }, { MP_ROM_QSTR(MP_QSTR_GP26), MP_ROM_PTR(&pin_GPIO26) }, @@ -47,8 +44,5 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_GP28_A2), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_GP28), MP_ROM_PTR(&pin_GPIO28) }, { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_GPIO28) }, - - { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_GPIO29) }, - { MP_ROM_QSTR(MP_QSTR_VOLTAGE_MONITOR), MP_ROM_PTR(&pin_GPIO29) }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); diff --git a/ports/raspberrypi/common-hal/microcontroller/__init__.c b/ports/raspberrypi/common-hal/microcontroller/__init__.c index c957d15eac..1ccd14df1d 100644 --- a/ports/raspberrypi/common-hal/microcontroller/__init__.c +++ b/ports/raspberrypi/common-hal/microcontroller/__init__.c @@ -176,7 +176,9 @@ const mp_rom_map_elem_t mcu_pin_global_dict_table[TOTAL_GPIO_COUNT] = { #if !defined(IGNORE_GPIO23) { MP_ROM_QSTR(MP_QSTR_GPIO23), MP_ROM_PTR(&pin_GPIO23) }, #endif + #if !defined(IGNORE_GPIO24) { MP_ROM_QSTR(MP_QSTR_GPIO24), MP_ROM_PTR(&pin_GPIO24) }, + #endif #if !defined(IGNORE_GPIO25) { MP_ROM_QSTR(MP_QSTR_GPIO25), MP_ROM_PTR(&pin_GPIO25) }, #endif @@ -187,6 +189,7 @@ const mp_rom_map_elem_t mcu_pin_global_dict_table[TOTAL_GPIO_COUNT] = { #if CIRCUITPY_CYW43 { MP_ROM_QSTR(MP_QSTR_CYW0), MP_ROM_PTR(&pin_CYW0) }, { MP_ROM_QSTR(MP_QSTR_CYW1), MP_ROM_PTR(&pin_CYW1) }, + { MP_ROM_QSTR(MP_QSTR_CYW2), MP_ROM_PTR(&pin_CYW2) }, #endif }; MP_DEFINE_CONST_DICT(mcu_pin_globals, mcu_pin_global_dict_table); diff --git a/ports/raspberrypi/peripherals/pins.c b/ports/raspberrypi/peripherals/pins.c index d607add143..3b21d3f08c 100644 --- a/ports/raspberrypi/peripherals/pins.c +++ b/ports/raspberrypi/peripherals/pins.c @@ -64,8 +64,12 @@ PIN(19); PIN(20); PIN(21); PIN(22); +#if !defined(IGNORE_GPIO23) PIN(23); +#endif +#if !defined(IGNORE_GPIO24) PIN(24); +#endif #if !defined(IGNORE_GPIO25) PIN(25); #endif @@ -76,4 +80,5 @@ PIN(29); #if CIRCUITPY_CYW43 CYW_PIN(0); CYW_PIN(1); +CYW_PIN(2); #endif diff --git a/ports/raspberrypi/peripherals/pins.h b/ports/raspberrypi/peripherals/pins.h index 0c7021f808..9ec74ed262 100644 --- a/ports/raspberrypi/peripherals/pins.h +++ b/ports/raspberrypi/peripherals/pins.h @@ -73,6 +73,7 @@ extern const mcu_pin_obj_t pin_GPIO29; #if CIRCUITPY_CYW43 extern const mcu_pin_obj_t pin_CYW0; extern const mcu_pin_obj_t pin_CYW1; +extern const mcu_pin_obj_t pin_CYW2; #endif #endif // MICROPY_INCLUDED_RASPBERRYPI_PERIPHERALS_PINS_H From 21c0c4c1a6da3185e9ea94623e5dee380d8c0ff9 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 7 Oct 2022 15:29:09 -0400 Subject: [PATCH 2/5] update esp-idf; allow start/stop channels in wifi scanning --- ports/espressif/common-hal/wifi/Radio.c | 9 +++-- .../common-hal/wifi/ScannedNetworks.c | 33 ++++++++++++------- .../common-hal/wifi/ScannedNetworks.h | 2 +- ports/espressif/common-hal/wifi/__init__.c | 2 +- ports/espressif/esp-idf | 2 +- shared-bindings/wifi/Radio.c | 27 ++++++++++++--- shared-bindings/wifi/Radio.h | 2 +- 7 files changed, 54 insertions(+), 23 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 8616501ba2..27e2c8c610 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -165,7 +165,7 @@ void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint esp_wifi_set_mac(ESP_IF_WIFI_AP, mac); } -mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) { +mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel) { if (self->current_scan != NULL) { mp_raise_RuntimeError(translate("Already scanning for wifi networks")); } @@ -177,9 +177,12 @@ mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) { wifi_scannednetworks_obj_t *scan = m_new_obj(wifi_scannednetworks_obj_t); scan->base.type = &wifi_scannednetworks_type; self->current_scan = scan; - scan->start_channel = 1; - scan->end_channel = 11; + scan->current_channel_index = 0; + scan->start_channel = start_channel; + scan->end_channel = stop_channel; scan->radio_event_group = self->event_group_handle; + scan->done = false; + scan->channel_scan_in_progress = false; wifi_scannednetworks_scan_next_channel(scan); return scan; } diff --git a/ports/espressif/common-hal/wifi/ScannedNetworks.c b/ports/espressif/common-hal/wifi/ScannedNetworks.c index 25c2da0473..50df9f8c95 100644 --- a/ports/espressif/common-hal/wifi/ScannedNetworks.c +++ b/ports/espressif/common-hal/wifi/ScannedNetworks.c @@ -72,7 +72,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) return mp_const_none; } // If we are scanning, wait and then load them. - if (self->scanning) { + if (self->channel_scan_in_progress) { // We may have to scan more than one channel to get a result. while (!self->done) { if (!wifi_scannednetworks_wait_for_scan(self)) { @@ -81,7 +81,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) } esp_wifi_scan_get_ap_num(&self->total_results); - self->scanning = false; + self->channel_scan_in_progress = false; if (self->total_results > 0) { break; } @@ -112,7 +112,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) } } esp_wifi_scan_get_ap_records(&self->total_results, self->results); - self->scanning = false; + self->channel_scan_in_progress = false; } wifi_network_obj_t *entry = m_new_obj(wifi_network_obj_t); @@ -132,40 +132,49 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) } // We don't do a linear scan so that we look at a variety of spectrum up front. -static uint8_t scan_pattern[] = {6, 1, 11, 3, 9, 13, 2, 4, 8, 12, 5, 7, 10, 14}; +static uint8_t scan_pattern[] = {6, 1, 11, 3, 9, 13, 2, 4, 8, 12, 5, 7, 10, 14, 0}; void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self) { - uint8_t next_channel = sizeof(scan_pattern); + // There is no channel 0, so use that as a flag to indicate we've run out of channels to scan. + uint8_t next_channel = 0; while (self->current_channel_index < sizeof(scan_pattern)) { next_channel = scan_pattern[self->current_channel_index]; self->current_channel_index++; + // Scan only channels that are in the specified range. if (self->start_channel <= next_channel && next_channel <= self->end_channel) { break; } } wifi_scan_config_t config = { 0 }; config.channel = next_channel; - if (next_channel == sizeof(scan_pattern)) { + if (next_channel == 0) { wifi_scannednetworks_done(self); } else { esp_err_t result = esp_wifi_scan_start(&config, false); if (result != ESP_OK) { wifi_scannednetworks_done(self); } else { - self->scanning = true; + self->channel_scan_in_progress = true; } } } void wifi_scannednetworks_deinit(wifi_scannednetworks_obj_t *self) { // if a scan is active, make sure and clean up the idf's buffer of results. - if (self->scanning) { + if (self->channel_scan_in_progress) { esp_wifi_scan_stop(); if (wifi_scannednetworks_wait_for_scan(self)) { - // Ignore the number of records since we're throwing them away. - uint16_t number = 0; - esp_wifi_scan_get_ap_records(&number, NULL); - self->scanning = false; + // Discard the scanned records, one at a time, to avoid memory leaks. + uint16_t number; + do { + number = 1; + wifi_ap_record_t record; + esp_wifi_scan_get_ap_records(&number, &record); + } while (number > 0); + // TODO: available in ESP-IDF v5.0; do instead of the above. + // Discard scan results. + // esp_wifi_clear_ap_list(); + self->channel_scan_in_progress = false; } } wifi_scannednetworks_done(self); diff --git a/ports/espressif/common-hal/wifi/ScannedNetworks.h b/ports/espressif/common-hal/wifi/ScannedNetworks.h index f089f27e3f..0ad4b5e3dc 100644 --- a/ports/espressif/common-hal/wifi/ScannedNetworks.h +++ b/ports/espressif/common-hal/wifi/ScannedNetworks.h @@ -53,7 +53,7 @@ typedef struct { uint8_t end_channel; // Inclusive bool done; - bool scanning; + bool channel_scan_in_progress; } wifi_scannednetworks_obj_t; void wifi_scannednetworks_scan_next_channel(wifi_scannednetworks_obj_t *self); diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 42ea078810..cfcfaf024b 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -172,7 +172,7 @@ void common_hal_wifi_init(bool user_initiated) { // Even though we just called esp_netif_create_default_wifi_sta, // station mode isn't actually ready for use until esp_wifi_set_mode() // is called and the configuration is loaded via esp_wifi_set_config(). - // Set both convienence flags to false so it's not forgotten. + // Set both convenience flags to false so it's not forgotten. self->sta_mode = 0; self->ap_mode = 0; diff --git a/ports/espressif/esp-idf b/ports/espressif/esp-idf index d51f7d8821..716d8531d7 160000 --- a/ports/espressif/esp-idf +++ b/ports/espressif/esp-idf @@ -1 +1 @@ -Subproject commit d51f7d882187afa4b39c2613fd0fe2ac2fea1145 +Subproject commit 716d8531d71b122975e2966a24ec7613b87eb7b0 diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index abe04ce24a..1af73a1db2 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -218,12 +218,31 @@ MP_PROPERTY_GETSET(wifi_radio_mac_address_ap_obj, //| ) -> Iterable[Network]: //| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country.""" //| ... -STATIC mp_obj_t wifi_radio_start_scanning_networks(mp_obj_t self_in) { - wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t wifi_radio_start_scanning_networks(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_start_channel, ARG_stop_channel }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_start_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} }, + { MP_QSTR_stop_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 11} }, + }; - return common_hal_wifi_radio_start_scanning_networks(self); + wifi_radio_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + uint8_t start_channel = + (uint8_t)mp_arg_validate_int_range(args[ARG_start_channel].u_int, 1, 14, MP_QSTR_start_channel); + uint8_t stop_channel = + (uint8_t)mp_arg_validate_int_range(args[ARG_stop_channel].u_int, 1, 14, MP_QSTR_stop_channel); + // Swap if in reverse order, without complaining. + if (start_channel > stop_channel) { + uint8_t temp = stop_channel; + stop_channel = start_channel; + start_channel = temp; + } + + return common_hal_wifi_radio_start_scanning_networks(self, start_channel, stop_channel); } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_start_scanning_networks_obj, wifi_radio_start_scanning_networks); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_start_scanning_networks_obj, 1, wifi_radio_start_scanning_networks); //| def stop_scanning_networks(self) -> None: //| """Stop scanning for Wifi networks and free any resources used to do it.""" diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h index 479ce1a1b3..370bdbd917 100644 --- a/shared-bindings/wifi/Radio.h +++ b/shared-bindings/wifi/Radio.h @@ -85,7 +85,7 @@ extern void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, con extern mp_float_t common_hal_wifi_radio_get_tx_power(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_set_tx_power(wifi_radio_obj_t *self, const mp_float_t power); -extern mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self); +extern mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel); extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_start_station(wifi_radio_obj_t *self); From 747dc7746de5c3b0759828b5b42516c717298c94 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 7 Oct 2022 16:22:17 -0400 Subject: [PATCH 3/5] handle scan channel bounds but note they do nothing for RP2040 CYW43 --- ports/raspberrypi/common-hal/wifi/Radio.c | 3 ++- shared-bindings/wifi/Radio.c | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 23414491d6..a0654414de 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -131,7 +131,8 @@ void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint ro_attribute(MP_QSTR_mac_address_ap); } -mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self) { +mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel) { + // channel bounds are ignored; not implemented in driver if (self->current_scan) { mp_raise_RuntimeError(translate("Already scanning for wifi networks")); } diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 1af73a1db2..57e953ec68 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -216,7 +216,12 @@ MP_PROPERTY_GETSET(wifi_radio_mac_address_ap_obj, //| def start_scanning_networks( //| self, *, start_channel: int = 1, stop_channel: int = 11 //| ) -> Iterable[Network]: -//| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country.""" +//| """Scans for available wifi networks over the given channel range. Make sure the channels are allowed in your country. +//| +//| .. note:: +//| +//| In the raspberrypi port (RP2040 CYW43), ``start_channel`` and ``stop_channel`` are ignored. +//| """ //| ... STATIC mp_obj_t wifi_radio_start_scanning_networks(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_start_channel, ARG_stop_channel }; From 86a0f9a861232678df0554398d45465515de1fe1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 9 Oct 2022 19:22:39 -0400 Subject: [PATCH 4/5] save about 112 bytes --- locale/circuitpython.pot | 9 +++++++++ main.c | 6 +++--- ports/atmel-samd/common-hal/busio/I2C.c | 2 -- py/modbuiltins.c | 1 - py/obj.h | 1 - py/objexcept.c | 1 - py/persistentcode.c | 2 +- py/runtime.c | 4 ---- py/runtime.h | 1 - 9 files changed, 13 insertions(+), 14 deletions(-) diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 504e66a50d..b6e0c7468c 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -60,6 +60,11 @@ msgstr "" msgid "%%c requires int or char" msgstr "" +#: main.c +#, c-format +msgid "%02X" +msgstr "" + #: shared-bindings/rgbmatrix/RGBMatrix.c #, c-format msgid "" @@ -2077,6 +2082,10 @@ msgstr "" msgid "UART write" msgstr "" +#: main.c +msgid "UID:" +msgstr "" + #: shared-module/usb_hid/Device.c msgid "USB busy" msgstr "" diff --git a/main.c b/main.c index d8542bcb57..06ca1ba93b 100644 --- a/main.c +++ b/main.c @@ -779,9 +779,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0 uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; common_hal_mcu_processor_get_uid(raw_id); - mp_printf(&mp_plat_print, "UID:"); - for (uint8_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { - mp_printf(&mp_plat_print, "%02X", raw_id[i]); + mp_cprintf(&mp_plat_print, translate("UID:")); + for (size_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { + mp_cprintf(&mp_plat_print, translate("%02X"), raw_id[i]); } mp_printf(&mp_plat_print, "\n"); port_boot_info(); diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index d97fa227b2..902e696408 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -125,8 +125,6 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, // exact cutoff, but no frequency well under 100kHz is available) if ((frequency < 95000) || (i2c_m_sync_set_baudrate(&self->i2c_desc, 0, frequency / 1000) != ERR_NONE)) { - reset_pin_number(sda->number); - reset_pin_number(scl->number); common_hal_busio_i2c_deinit(self); mp_arg_error_invalid(MP_QSTR_frequency); } diff --git a/py/modbuiltins.c b/py/modbuiltins.c index 4e9fbfcd93..072ba8675f 100644 --- a/py/modbuiltins.c +++ b/py/modbuiltins.c @@ -759,7 +759,6 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) }, { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) }, { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) }, - { MP_ROM_QSTR(MP_QSTR_MpyError), MP_ROM_PTR(&mp_type_MpyError) }, { MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) }, { MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) }, { MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) }, diff --git a/py/obj.h b/py/obj.h index 8f38a4c7c0..7fa21f5e38 100644 --- a/py/obj.h +++ b/py/obj.h @@ -742,7 +742,6 @@ extern const mp_obj_type_t mp_type_ReloadException; extern const mp_obj_type_t mp_type_KeyError; extern const mp_obj_type_t mp_type_LookupError; extern const mp_obj_type_t mp_type_MemoryError; -extern const mp_obj_type_t mp_type_MpyError; extern const mp_obj_type_t mp_type_NameError; extern const mp_obj_type_t mp_type_NotImplementedError; extern const mp_obj_type_t mp_type_OSError; diff --git a/py/objexcept.c b/py/objexcept.c index 230f9d11ba..12408c0d1f 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -347,7 +347,6 @@ MP_DEFINE_EXCEPTION(UnicodeError, ValueError) #if CIRCUITPY_ALARM MP_DEFINE_EXCEPTION(DeepSleepRequest, BaseException) #endif -MP_DEFINE_EXCEPTION(MpyError, ValueError) /* MP_DEFINE_EXCEPTION(Warning, Exception) MP_DEFINE_EXCEPTION(DeprecationWarning, Warning) diff --git a/py/persistentcode.c b/py/persistentcode.c index 787f724bf6..0431b30a29 100644 --- a/py/persistentcode.c +++ b/py/persistentcode.c @@ -582,7 +582,7 @@ mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) { || MPY_FEATURE_DECODE_FLAGS(header[2]) != MPY_FEATURE_FLAGS || header[3] > mp_small_int_bits() || read_uint(reader, NULL) > QSTR_WINDOW_SIZE) { - mp_raise_MpyError(MP_ERROR_TEXT("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.")); + mp_raise_ValueError(MP_ERROR_TEXT("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.")); } if (MPY_FEATURE_DECODE_ARCH(header[2]) != MP_NATIVE_ARCH_NONE) { byte arch = MPY_FEATURE_DECODE_ARCH(header[2]); diff --git a/py/runtime.c b/py/runtime.c index 7fcad7366a..e5b411b0d3 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1742,10 +1742,6 @@ NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) { va_end(argptr); } -NORETURN void mp_raise_MpyError(const compressed_string_t *msg) { - mp_raise_msg(&mp_type_MpyError, msg); -} - NORETURN void mp_raise_type_arg(const mp_obj_type_t *exc_type, mp_obj_t arg) { nlr_raise(mp_obj_new_exception_arg1(exc_type, arg)); } diff --git a/py/runtime.h b/py/runtime.h index a78969780b..923071f7ca 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -225,7 +225,6 @@ NORETURN void mp_raise_BrokenPipeError(void); NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...); -NORETURN void mp_raise_MpyError(const compressed_string_t *msg); NORETURN void mp_raise_recursion_depth(void); #endif From 6dcbb6108134b88b61efae97fa98278edb62aff1 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Sun, 9 Oct 2022 20:27:39 -0400 Subject: [PATCH 5/5] fix test that used MpyError --- tests/micropython/import_mpy_invalid.py.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/micropython/import_mpy_invalid.py.exp b/tests/micropython/import_mpy_invalid.py.exp index ebf72c293c..432287028e 100644 --- a/tests/micropython/import_mpy_invalid.py.exp +++ b/tests/micropython/import_mpy_invalid.py.exp @@ -1,4 +1,4 @@ mod0 RuntimeError Corrupt .mpy file mod1 RuntimeError Corrupt .mpy file -mod2 MpyError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info. -mod3 MpyError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info. +mod2 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info. +mod3 ValueError Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.