From 2f4cd7497de9b06f505df53d7f818f6fa9f242f2 Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 18 Mar 2025 06:32:32 -0700 Subject: [PATCH 01/13] Use MICROPY_HW_MCU_NAME for sysname and nodename for all ports. --- ports/analog/common-hal/os/__init__.c | 4 ++-- ports/atmel-samd/common-hal/os/__init__.c | 10 ++-------- ports/cxd56/common-hal/os/__init__.c | 4 ++-- ports/litex/common-hal/os/__init__.c | 4 ++-- ports/mimxrt10xx/common-hal/os/__init__.c | 4 ++-- ports/nordic/common-hal/os/__init__.c | 4 ++-- ports/renode/common-hal/os/__init__.c | 4 ++-- ports/silabs/common-hal/os/__init__.c | 4 ++-- ports/stm/common-hal/os/__init__.c | 4 ++-- ports/zephyr-cp/common-hal/os/__init__.c | 4 ++-- 10 files changed, 20 insertions(+), 26 deletions(-) diff --git a/ports/analog/common-hal/os/__init__.c b/ports/analog/common-hal/os/__init__.c index 1f89300c4c182..a32947cb8b054 100644 --- a/ports/analog/common-hal/os/__init__.c +++ b/ports/analog/common-hal/os/__init__.c @@ -19,8 +19,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "max32"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "max32"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/atmel-samd/common-hal/os/__init__.c b/ports/atmel-samd/common-hal/os/__init__.c index 2c1de431c6635..1926fdc73e3d8 100644 --- a/ports/atmel-samd/common-hal/os/__init__.c +++ b/ports/atmel-samd/common-hal/os/__init__.c @@ -20,14 +20,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -#ifdef SAMD21 -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "samd21"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "samd21"); -#endif -#ifdef SAM_D5X_E5X -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "samd51"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "samd51"); -#endif +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/cxd56/common-hal/os/__init__.c b/ports/cxd56/common-hal/os/__init__.c index 7d211b3a79d06..3d06d524fd36b 100644 --- a/ports/cxd56/common-hal/os/__init__.c +++ b/ports/cxd56/common-hal/os/__init__.c @@ -15,8 +15,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "spresense"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "spresense"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/litex/common-hal/os/__init__.c b/ports/litex/common-hal/os/__init__.c index e6da1904da522..4595ae4804bfb 100644 --- a/ports/litex/common-hal/os/__init__.c +++ b/ports/litex/common-hal/os/__init__.c @@ -16,8 +16,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "litex"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "litex"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c index 79ae228dc4240..6c19ff997967e 100644 --- a/ports/mimxrt10xx/common-hal/os/__init__.c +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -21,8 +21,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "mimxrt10xx"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "mimxrt10xx"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/nordic/common-hal/os/__init__.c b/ports/nordic/common-hal/os/__init__.c index 78aa1e040cf8e..a835be1504fa8 100644 --- a/ports/nordic/common-hal/os/__init__.c +++ b/ports/nordic/common-hal/os/__init__.c @@ -21,8 +21,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "nrf52"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "nrf52"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/renode/common-hal/os/__init__.c b/ports/renode/common-hal/os/__init__.c index 334742bb594e3..e9f555d7d561c 100644 --- a/ports/renode/common-hal/os/__init__.c +++ b/ports/renode/common-hal/os/__init__.c @@ -16,8 +16,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "renode"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "renode"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/silabs/common-hal/os/__init__.c b/ports/silabs/common-hal/os/__init__.c index 42036536e4ff6..d7a54429f4bde 100644 --- a/ports/silabs/common-hal/os/__init__.c +++ b/ports/silabs/common-hal/os/__init__.c @@ -39,8 +39,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, EFR32_SERIES_LOWER); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, EFR32_SERIES_LOWER); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/stm/common-hal/os/__init__.c b/ports/stm/common-hal/os/__init__.c index b3d9e67d98893..beeb66f7cd556 100644 --- a/ports/stm/common-hal/os/__init__.c +++ b/ports/stm/common-hal/os/__init__.c @@ -19,8 +19,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, STM32_SERIES_LOWER); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, STM32_SERIES_LOWER); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/zephyr-cp/common-hal/os/__init__.c b/ports/zephyr-cp/common-hal/os/__init__.c index 58e6674cb1157..d173f43312355 100644 --- a/ports/zephyr-cp/common-hal/os/__init__.c +++ b/ports/zephyr-cp/common-hal/os/__init__.c @@ -17,8 +17,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "nrf52"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "nrf52"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); From 9b3731c694cedbb86eb9ae2d8a98d43b1f118d09 Mon Sep 17 00:00:00 2001 From: eightycc Date: Wed, 19 Mar 2025 09:10:10 -0700 Subject: [PATCH 02/13] Remove watchdog.deinit() for 10.0.0. --- shared-bindings/watchdog/WatchDogTimer.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 19e931d0dcc4d..dbb91311345f2 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -48,24 +48,6 @@ static mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watchdogtimer_feed); -//| def deinit(self) -> None: -//| """Stop the watchdog timer. -//| -//| :raises RuntimeError: if the watchdog timer cannot be disabled on this platform. -//| -//| .. note:: This is deprecated in ``9.0.0`` and will be removed in ``10.0.0``. -//| Set watchdog `mode` to `None` instead. -//| -//| """ -//| ... -//| -static mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) { - watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_watchdog_deinit(self); - return mp_const_none; -} -static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_deinit_obj, watchdog_watchdogtimer_deinit); - //| timeout: float //| """The maximum number of seconds that can elapse between calls //| to `feed()`. Setting the timeout will also feed the watchdog.""" @@ -126,7 +108,6 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_mode_obj, static const mp_rom_map_elem_t watchdog_watchdogtimer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_feed), MP_ROM_PTR(&watchdog_watchdogtimer_feed_obj) }, - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&watchdog_watchdogtimer_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_timeout), MP_ROM_PTR(&watchdog_watchdogtimer_timeout_obj) }, { MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&watchdog_watchdogtimer_mode_obj) }, }; From 8afdccc2cffcf7c95a4c77520fb690c366b8f0e9 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 19 Mar 2025 15:59:32 -0500 Subject: [PATCH 03/13] check if pins exist before using --- tests/circuitpython-manual/usb/device_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/circuitpython-manual/usb/device_info.py b/tests/circuitpython-manual/usb/device_info.py index 7b8631a8f865a..3481707055507 100644 --- a/tests/circuitpython-manual/usb/device_info.py +++ b/tests/circuitpython-manual/usb/device_info.py @@ -9,7 +9,8 @@ d.switch_to_output(value=True) print("USB power on") -h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM) +if hasattr(board, "USB_HOST_DP") and hasattr(board, "USB_HOST_DM"): + h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM) while True: for device in usb.core.find(find_all=True): From 7c0fa46cf8e8bef94606c0f894e0beb38c27d3cd Mon Sep 17 00:00:00 2001 From: page200 <69221289+page200@users.noreply.github.com> Date: Wed, 19 Mar 2025 22:47:34 +0100 Subject: [PATCH 04/13] Suspected typo: last "S" in "STM32F412xGS" Because https://www.st.com/resource/en/data_brief/32f412gdiscovery.pdf says "STM32F412ZGT6" --- ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h index e771532437f6b..b068b8e2d517c 100644 --- a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h @@ -9,7 +9,7 @@ // Micropython setup #define MICROPY_HW_BOARD_NAME "STM32F412G_DISCO" -#define MICROPY_HW_MCU_NAME "STM32F412xGS" +#define MICROPY_HW_MCU_NAME "STM32F412xG" #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) From df3327179d1516dfc6e38792bcc847aa20a9c649 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 19 Mar 2025 20:45:35 -0400 Subject: [PATCH 05/13] CIRCUITPY_FULL_BUILD now controls a few more features --- ports/analog/mpconfigport.h | 3 --- ports/atmel-samd/mpconfigport.h | 3 +-- ports/broadcom/mpconfigport.h | 4 +--- ports/cxd56/boards/spresense/mpconfigboard.h | 2 -- ports/cxd56/mpconfigport.h | 3 --- ports/espressif/mpconfigport.h | 3 --- ports/litex/mpconfigport.h | 2 -- ports/mimxrt10xx/mpconfigport.h | 4 ---- ports/nordic/mpconfigport.h | 2 -- ports/raspberrypi/mpconfigport.h | 3 --- ports/renode/mpconfigport.h | 3 --- ports/silabs/mpconfigport.h | 3 --- ports/stm/mpconfigport.h | 3 --- py/circuitpy_mpconfig.h | 22 ++++++++++++++++++++ 14 files changed, 24 insertions(+), 36 deletions(-) diff --git a/ports/analog/mpconfigport.h b/ports/analog/mpconfigport.h index cadfbddbc55bb..c4b3ee031cacf 100644 --- a/ports/analog/mpconfigport.h +++ b/ports/analog/mpconfigport.h @@ -9,9 +9,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 24KiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index f02f3d595d9b4..eca28dbd9be00 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -68,8 +68,7 @@ #define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54" #endif #define SPI_FLASH_MAX_BAUDRATE 24000000 -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) + // MICROPY_PY_ERRNO_LIST - Use the default #endif // SAM_D5X_E5X diff --git a/ports/broadcom/mpconfigport.h b/ports/broadcom/mpconfigport.h index 648259720f800..8b749ca03100a 100644 --- a/ports/broadcom/mpconfigport.h +++ b/ports/broadcom/mpconfigport.h @@ -13,9 +13,7 @@ #define CIRCUITPY_MCU_FAMILY broadcom #define MICROPY_PY_SYS_PLATFORM "BROADCOM" -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) + #if BCM_VERSION == 2837 || BCM_VERSION == 2711 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) #elif BCM_VERSION == 2835 diff --git a/ports/cxd56/boards/spresense/mpconfigboard.h b/ports/cxd56/boards/spresense/mpconfigboard.h index 2d334ef29b301..c9510771b1855 100644 --- a/ports/cxd56/boards/spresense/mpconfigboard.h +++ b/ports/cxd56/boards/spresense/mpconfigboard.h @@ -18,5 +18,3 @@ #define DEFAULT_UART_BUS_RX (&pin_UART2_RXD) #define DEFAULT_UART_BUS_TX (&pin_UART2_TXD) - -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) diff --git a/ports/cxd56/mpconfigport.h b/ports/cxd56/mpconfigport.h index b779b521ddaf9..3bcb252868786 100644 --- a/ports/cxd56/mpconfigport.h +++ b/ports/cxd56/mpconfigport.h @@ -8,9 +8,6 @@ #define MICROPY_PY_SYS_PLATFORM "CXD56" -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 64kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE (0x10000) diff --git a/ports/espressif/mpconfigport.h b/ports/espressif/mpconfigport.h index 443a59b0474bd..98c1986240b73 100644 --- a/ports/espressif/mpconfigport.h +++ b/ports/espressif/mpconfigport.h @@ -17,9 +17,6 @@ #define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #include "py/circuitpy_mpconfig.h" #define MICROPY_NLR_SETJMP (1) diff --git a/ports/litex/mpconfigport.h b/ports/litex/mpconfigport.h index 50986d16026c2..7ac34a44336cf 100644 --- a/ports/litex/mpconfigport.h +++ b/ports/litex/mpconfigport.h @@ -9,8 +9,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (0) #define MICROPY_NLR_THUMB (0) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) #include "py/circuitpy_mpconfig.h" diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h index 4f9acd7a9fd30..4d5e4e59700bd 100644 --- a/ports/mimxrt10xx/mpconfigport.h +++ b/ports/mimxrt10xx/mpconfigport.h @@ -17,10 +17,6 @@ extern uint8_t _ld_filesystem_end; extern uint8_t _ld_default_stack_size; #define CIRCUITPY_DEFAULT_STACK_SIZE ((uint32_t)&_ld_default_stack_size) -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) -#define MICROPY_PY_FUNCTION_ATTRS (0) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR ((uint32_t)&_ld_filesystem_start) #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE ((uint32_t)(&_ld_filesystem_end - &_ld_filesystem_start)) diff --git a/ports/nordic/mpconfigport.h b/ports/nordic/mpconfigport.h index ed6c2827000ca..33fcfa371e0bd 100644 --- a/ports/nordic/mpconfigport.h +++ b/ports/nordic/mpconfigport.h @@ -13,8 +13,6 @@ #include "nrf_sdm.h" // for SD_FLASH_SIZE #include "peripherals/nrf/nvm.h" // for FLASH_PAGE_SIZE -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) #define MICROPY_PY_SYS_STDIO_BUFFER (1) // 24kiB stack diff --git a/ports/raspberrypi/mpconfigport.h b/ports/raspberrypi/mpconfigport.h index 00dcafe10fe11..1181517fdf9a0 100644 --- a/ports/raspberrypi/mpconfigport.h +++ b/ports/raspberrypi/mpconfigport.h @@ -16,9 +16,6 @@ #define MICROPY_PY_SYS_PLATFORM "RP2350" #endif -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // Setting a non-default value also requires a non-default link.ld #ifndef CIRCUITPY_FIRMWARE_SIZE #define CIRCUITPY_FIRMWARE_SIZE (1020 * 1024) diff --git a/ports/renode/mpconfigport.h b/ports/renode/mpconfigport.h index 19937d749d47b..185a884ed313e 100644 --- a/ports/renode/mpconfigport.h +++ b/ports/renode/mpconfigport.h @@ -8,9 +8,6 @@ #define MICROPY_PY_SYS_PLATFORM "Renode" -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #define MICROPY_USE_INTERNAL_PRINTF (1) // This also includes mpconfigboard.h. diff --git a/ports/silabs/mpconfigport.h b/ports/silabs/mpconfigport.h index ce7739cccaea4..26fe7dfc2f0b5 100644 --- a/ports/silabs/mpconfigport.h +++ b/ports/silabs/mpconfigport.h @@ -29,9 +29,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 diff --git a/ports/stm/mpconfigport.h b/ports/stm/mpconfigport.h index ed36b49ffb92f..afa9aa3685c9a 100644 --- a/ports/stm/mpconfigport.h +++ b/ports/stm/mpconfigport.h @@ -9,9 +9,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - extern uint8_t _ld_default_stack_size; // 24kiB stack diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 0121144f8ced6..0168b0f4d8254 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -93,6 +93,7 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) #define MICROPY_OPT_LOAD_ATTR_FAST_PATH (CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) #define MICROPY_OPT_MAP_LOOKUP_CACHE (CIRCUITPY_OPT_MAP_LOOKUP_CACHE) +#define MICROPY_OPT_MPZ_BITWISE (0) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) @@ -224,31 +225,52 @@ typedef long mp_off_t; // Turning off FULL_BUILD removes some functionality to reduce flash size on tiny SAMD21s #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_CPYTHON_COMPAT #define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) #endif + #ifndef MICROPY_CPYTHON_EXCEPTION_CHAIN #define MICROPY_CPYTHON_EXCEPTION_CHAIN (CIRCUITPY_FULL_BUILD) #endif + #define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_BUILTINS_POW3) #define MICROPY_PY_FSTRINGS (1) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_PY_BUILTINS_COMPLEX #define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD) #endif + #define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD) + +#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (CIRCUITPY_FULL_BUILD) +#endif + #define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif + #ifndef MICROPY_PY_COLLECTIONS_DEQUE #define MICROPY_PY_COLLECTIONS_DEQUE (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_COLLECTIONS_DEQUE_ITER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (CIRCUITPY_FULL_BUILD) #endif + +#ifndef MICROPY_PY_FUNCTION_ATTRS +#define MICROPY_PY_FUNCTION_ATTRS (CIRCUITPY_FULL_BUILD) +#endif + +#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) +#endif + #define MICROPY_PY_RE_MATCH_GROUPS (CIRCUITPY_RE) #define MICROPY_PY_RE_MATCH_SPAN_START_END (CIRCUITPY_RE) #define MICROPY_PY_RE_SUB (CIRCUITPY_RE) From 214c2f6dd8278118d19eba8c5e41ee0e57db6e40 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 20 Mar 2025 06:25:46 -0700 Subject: [PATCH 06/13] Factor common_hal_os_uname into os_uname() and remove common_hal_os_uname. --- ports/analog/common-hal/os/__init__.c | 26 --------------------- ports/atmel-samd/common-hal/os/__init__.c | 26 --------------------- ports/broadcom/common-hal/os/__init__.c | 27 ---------------------- ports/cxd56/common-hal/os/__init__.c | 26 --------------------- ports/espressif/common-hal/os/__init__.c | 26 --------------------- ports/litex/common-hal/os/__init__.c | 26 --------------------- ports/mimxrt10xx/common-hal/os/__init__.c | 25 -------------------- ports/nordic/common-hal/os/__init__.c | 26 --------------------- ports/raspberrypi/common-hal/os/__init__.c | 26 --------------------- ports/renode/common-hal/os/__init__.c | 26 --------------------- ports/silabs/common-hal/os/__init__.c | 25 -------------------- ports/stm/common-hal/os/__init__.c | 26 --------------------- ports/zephyr-cp/common-hal/os/__init__.c | 26 --------------------- shared-bindings/os/__init__.c | 24 ++++++++++++++++++- shared-bindings/os/__init__.h | 3 --- shared-module/os/__init__.c | 2 +- 16 files changed, 24 insertions(+), 342 deletions(-) diff --git a/ports/analog/common-hal/os/__init__.c b/ports/analog/common-hal/os/__init__.c index a32947cb8b054..7b607cf6b3c4b 100644 --- a/ports/analog/common-hal/os/__init__.c +++ b/ports/analog/common-hal/os/__init__.c @@ -15,32 +15,6 @@ // #include "peripherals/periph.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { #if (HAS_TRNG) // todo (low prior): implement diff --git a/ports/atmel-samd/common-hal/os/__init__.c b/ports/atmel-samd/common-hal/os/__init__.c index 1926fdc73e3d8..89b5e85135d87 100644 --- a/ports/atmel-samd/common-hal/os/__init__.c +++ b/ports/atmel-samd/common-hal/os/__init__.c @@ -16,32 +16,6 @@ #include "hal/include/hal_rand_sync.h" #endif -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef SAM_D5X_E5X hri_mclk_set_APBCMASK_TRNG_bit(MCLK); diff --git a/ports/broadcom/common-hal/os/__init__.c b/ports/broadcom/common-hal/os/__init__.c index 72a9a07e9077e..c1c50234451ef 100644 --- a/ports/broadcom/common-hal/os/__init__.c +++ b/ports/broadcom/common-hal/os/__init__.c @@ -10,33 +10,6 @@ #include "py/objtuple.h" #include "py/qstr.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; - -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { return false; } diff --git a/ports/cxd56/common-hal/os/__init__.c b/ports/cxd56/common-hal/os/__init__.c index 3d06d524fd36b..e1024108b07dc 100644 --- a/ports/cxd56/common-hal/os/__init__.c +++ b/ports/cxd56/common-hal/os/__init__.c @@ -10,32 +10,6 @@ #include "py/objstr.h" #include "py/objtuple.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; - -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { uint32_t i = 0; diff --git a/ports/espressif/common-hal/os/__init__.c b/ports/espressif/common-hal/os/__init__.c index 4063090fe1f96..fff89c8476d8d 100644 --- a/ports/espressif/common-hal/os/__init__.c +++ b/ports/espressif/common-hal/os/__init__.c @@ -15,32 +15,6 @@ #include "esp_system.h" #include "esp_random.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { uint32_t i = 0; while (i < length) { diff --git a/ports/litex/common-hal/os/__init__.c b/ports/litex/common-hal/os/__init__.c index 4595ae4804bfb..659411187fafb 100644 --- a/ports/litex/common-hal/os/__init__.c +++ b/ports/litex/common-hal/os/__init__.c @@ -12,32 +12,6 @@ #include "shared-bindings/os/__init__.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { return false; } diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c index 6c19ff997967e..ac168f2ed09b3 100644 --- a/ports/mimxrt10xx/common-hal/os/__init__.c +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -17,31 +17,6 @@ #include "sdk/drivers/trng/fsl_trng.h" #endif -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #if CIRCUITPY_RANDOM trng_config_t trngConfig; diff --git a/ports/nordic/common-hal/os/__init__.c b/ports/nordic/common-hal/os/__init__.c index a835be1504fa8..54b8ad026a7de 100644 --- a/ports/nordic/common-hal/os/__init__.c +++ b/ports/nordic/common-hal/os/__init__.c @@ -17,32 +17,6 @@ #include "nrf_rng.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef BLUETOOTH_SD uint8_t sd_en = 0; diff --git a/ports/raspberrypi/common-hal/os/__init__.c b/ports/raspberrypi/common-hal/os/__init__.c index d9ad1c238ff34..616bb8d8c7929 100644 --- a/ports/raspberrypi/common-hal/os/__init__.c +++ b/ports/raspberrypi/common-hal/os/__init__.c @@ -18,32 +18,6 @@ #include -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - // NIST Special Publication 800-90B (draft) recommends several extractors, // including the SHA hash family and states that if the amount of entropy input // is twice the number of bits output from them, that output can be considered diff --git a/ports/renode/common-hal/os/__init__.c b/ports/renode/common-hal/os/__init__.c index e9f555d7d561c..14e22960469fa 100644 --- a/ports/renode/common-hal/os/__init__.c +++ b/ports/renode/common-hal/os/__init__.c @@ -12,32 +12,6 @@ #include "shared-bindings/os/__init__.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { return false; } diff --git a/ports/silabs/common-hal/os/__init__.c b/ports/silabs/common-hal/os/__init__.c index d7a54429f4bde..79e79875fd541 100644 --- a/ports/silabs/common-hal/os/__init__.c +++ b/ports/silabs/common-hal/os/__init__.c @@ -35,31 +35,6 @@ #include "peripherals/periph.h" #define RNG_TIMEOUT 5 -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { return false; diff --git a/ports/stm/common-hal/os/__init__.c b/ports/stm/common-hal/os/__init__.c index beeb66f7cd556..d654f844b1767 100644 --- a/ports/stm/common-hal/os/__init__.c +++ b/ports/stm/common-hal/os/__init__.c @@ -15,32 +15,6 @@ #include STM32_HAL_H #include "peripherals/periph.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - #define RNG_TIMEOUT 5 bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { diff --git a/ports/zephyr-cp/common-hal/os/__init__.c b/ports/zephyr-cp/common-hal/os/__init__.c index d173f43312355..2f37ba40f47a6 100644 --- a/ports/zephyr-cp/common-hal/os/__init__.c +++ b/ports/zephyr-cp/common-hal/os/__init__.c @@ -13,32 +13,6 @@ #include -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #if !DT_HAS_CHOSEN(zephyr_entropy) return false; diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index e6f6d4896dc3d..5e28c02452d05 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -44,8 +44,30 @@ //| machine: str //| //| +static const qstr os_uname_info_fields[] = { + MP_QSTR_sysname, MP_QSTR_nodename, + MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine +}; +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); +static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); +static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); + + +static MP_DEFINE_ATTRTUPLE( + os_uname_info_obj, + os_uname_info_fields, + 5, + (mp_obj_t)&os_uname_info_sysname_obj, + (mp_obj_t)&os_uname_info_nodename_obj, + (mp_obj_t)&os_uname_info_release_obj, + (mp_obj_t)&os_uname_info_version_obj, + (mp_obj_t)&os_uname_info_machine_obj + ); + static mp_obj_t os_uname(void) { - return common_hal_os_uname(); + return (mp_obj_t)&os_uname_info_obj; } static MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); diff --git a/shared-bindings/os/__init__.h b/shared-bindings/os/__init__.h index f273708cf4ed9..56b643e2edfbe 100644 --- a/shared-bindings/os/__init__.h +++ b/shared-bindings/os/__init__.h @@ -11,9 +11,6 @@ #include "py/objtuple.h" -extern const mp_rom_obj_tuple_t common_hal_os_uname_info_obj; - -mp_obj_t common_hal_os_uname(void); void common_hal_os_chdir(const char *path); mp_obj_t common_hal_os_getcwd(void); mp_obj_t common_hal_os_getenv(const char *key, mp_obj_t default_); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 81296db854cd3..6afe64dd62d5b 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -17,7 +17,7 @@ #include "shared-bindings/os/__init__.h" // This provides all VFS related OS functions so that ports can share the code -// as needed. It does not provide uname. +// as needed. // Version of mp_vfs_lookup_path that takes and returns uPy string objects. static mp_vfs_mount_t *lookup_path(const char *path, mp_obj_t *path_out) { From 1f0b234d33a401448acf77b2aee79d306334a01a Mon Sep 17 00:00:00 2001 From: eightycc Date: Wed, 19 Mar 2025 09:10:10 -0700 Subject: [PATCH 07/13] Remove watchdog.deinit() for 10.0.0. --- shared-bindings/watchdog/WatchDogTimer.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 19e931d0dcc4d..dbb91311345f2 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -48,24 +48,6 @@ static mp_obj_t watchdog_watchdogtimer_feed(mp_obj_t self_in) { } static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_feed_obj, watchdog_watchdogtimer_feed); -//| def deinit(self) -> None: -//| """Stop the watchdog timer. -//| -//| :raises RuntimeError: if the watchdog timer cannot be disabled on this platform. -//| -//| .. note:: This is deprecated in ``9.0.0`` and will be removed in ``10.0.0``. -//| Set watchdog `mode` to `None` instead. -//| -//| """ -//| ... -//| -static mp_obj_t watchdog_watchdogtimer_deinit(mp_obj_t self_in) { - watchdog_watchdogtimer_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_watchdog_deinit(self); - return mp_const_none; -} -static MP_DEFINE_CONST_FUN_OBJ_1(watchdog_watchdogtimer_deinit_obj, watchdog_watchdogtimer_deinit); - //| timeout: float //| """The maximum number of seconds that can elapse between calls //| to `feed()`. Setting the timeout will also feed the watchdog.""" @@ -126,7 +108,6 @@ MP_PROPERTY_GETSET(watchdog_watchdogtimer_mode_obj, static const mp_rom_map_elem_t watchdog_watchdogtimer_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_feed), MP_ROM_PTR(&watchdog_watchdogtimer_feed_obj) }, - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&watchdog_watchdogtimer_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_timeout), MP_ROM_PTR(&watchdog_watchdogtimer_timeout_obj) }, { MP_ROM_QSTR(MP_QSTR_mode), MP_ROM_PTR(&watchdog_watchdogtimer_mode_obj) }, }; From 20e584f3f365d0b4bb47b0ff60dd7a85ade49fe2 Mon Sep 17 00:00:00 2001 From: page200 <69221289+page200@users.noreply.github.com> Date: Wed, 19 Mar 2025 22:47:34 +0100 Subject: [PATCH 08/13] Suspected typo: last "S" in "STM32F412xGS" Because https://www.st.com/resource/en/data_brief/32f412gdiscovery.pdf says "STM32F412ZGT6" --- ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h index e771532437f6b..b068b8e2d517c 100644 --- a/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h +++ b/ports/stm/boards/stm32f412zg_discovery/mpconfigboard.h @@ -9,7 +9,7 @@ // Micropython setup #define MICROPY_HW_BOARD_NAME "STM32F412G_DISCO" -#define MICROPY_HW_MCU_NAME "STM32F412xGS" +#define MICROPY_HW_MCU_NAME "STM32F412xG" #define FLASH_SIZE (0x100000) #define FLASH_PAGE_SIZE (0x4000) From 47eeb93e6bfa3854905cc41f3c7f0d6bf19217e9 Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 18 Mar 2025 06:32:32 -0700 Subject: [PATCH 09/13] Use MICROPY_HW_MCU_NAME for sysname and nodename for all ports. --- ports/analog/common-hal/os/__init__.c | 4 ++-- ports/atmel-samd/common-hal/os/__init__.c | 10 ++-------- ports/cxd56/common-hal/os/__init__.c | 4 ++-- ports/litex/common-hal/os/__init__.c | 4 ++-- ports/mimxrt10xx/common-hal/os/__init__.c | 4 ++-- ports/nordic/common-hal/os/__init__.c | 4 ++-- ports/renode/common-hal/os/__init__.c | 4 ++-- ports/silabs/common-hal/os/__init__.c | 4 ++-- ports/stm/common-hal/os/__init__.c | 4 ++-- ports/zephyr-cp/common-hal/os/__init__.c | 4 ++-- 10 files changed, 20 insertions(+), 26 deletions(-) diff --git a/ports/analog/common-hal/os/__init__.c b/ports/analog/common-hal/os/__init__.c index 1f89300c4c182..a32947cb8b054 100644 --- a/ports/analog/common-hal/os/__init__.c +++ b/ports/analog/common-hal/os/__init__.c @@ -19,8 +19,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "max32"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "max32"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/atmel-samd/common-hal/os/__init__.c b/ports/atmel-samd/common-hal/os/__init__.c index 2c1de431c6635..1926fdc73e3d8 100644 --- a/ports/atmel-samd/common-hal/os/__init__.c +++ b/ports/atmel-samd/common-hal/os/__init__.c @@ -20,14 +20,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -#ifdef SAMD21 -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "samd21"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "samd21"); -#endif -#ifdef SAM_D5X_E5X -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "samd51"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "samd51"); -#endif +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/cxd56/common-hal/os/__init__.c b/ports/cxd56/common-hal/os/__init__.c index 7d211b3a79d06..3d06d524fd36b 100644 --- a/ports/cxd56/common-hal/os/__init__.c +++ b/ports/cxd56/common-hal/os/__init__.c @@ -15,8 +15,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "spresense"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "spresense"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/litex/common-hal/os/__init__.c b/ports/litex/common-hal/os/__init__.c index e6da1904da522..4595ae4804bfb 100644 --- a/ports/litex/common-hal/os/__init__.c +++ b/ports/litex/common-hal/os/__init__.c @@ -16,8 +16,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "litex"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "litex"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c index 79ae228dc4240..6c19ff997967e 100644 --- a/ports/mimxrt10xx/common-hal/os/__init__.c +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -21,8 +21,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "mimxrt10xx"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "mimxrt10xx"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/nordic/common-hal/os/__init__.c b/ports/nordic/common-hal/os/__init__.c index 78aa1e040cf8e..a835be1504fa8 100644 --- a/ports/nordic/common-hal/os/__init__.c +++ b/ports/nordic/common-hal/os/__init__.c @@ -21,8 +21,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "nrf52"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "nrf52"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/renode/common-hal/os/__init__.c b/ports/renode/common-hal/os/__init__.c index 334742bb594e3..e9f555d7d561c 100644 --- a/ports/renode/common-hal/os/__init__.c +++ b/ports/renode/common-hal/os/__init__.c @@ -16,8 +16,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "renode"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "renode"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); diff --git a/ports/silabs/common-hal/os/__init__.c b/ports/silabs/common-hal/os/__init__.c index 42036536e4ff6..d7a54429f4bde 100644 --- a/ports/silabs/common-hal/os/__init__.c +++ b/ports/silabs/common-hal/os/__init__.c @@ -39,8 +39,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, EFR32_SERIES_LOWER); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, EFR32_SERIES_LOWER); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/stm/common-hal/os/__init__.c b/ports/stm/common-hal/os/__init__.c index b3d9e67d98893..beeb66f7cd556 100644 --- a/ports/stm/common-hal/os/__init__.c +++ b/ports/stm/common-hal/os/__init__.c @@ -19,8 +19,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, STM32_SERIES_LOWER); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, STM32_SERIES_LOWER); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); diff --git a/ports/zephyr-cp/common-hal/os/__init__.c b/ports/zephyr-cp/common-hal/os/__init__.c index 58e6674cb1157..d173f43312355 100644 --- a/ports/zephyr-cp/common-hal/os/__init__.c +++ b/ports/zephyr-cp/common-hal/os/__init__.c @@ -17,8 +17,8 @@ static const qstr os_uname_info_fields[] = { MP_QSTR_sysname, MP_QSTR_nodename, MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine }; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, "nrf52"); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, "nrf52"); +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); From b7aa2cca914d6cb4d4ca65eab367352d95ef94e9 Mon Sep 17 00:00:00 2001 From: eightycc Date: Thu, 20 Mar 2025 06:25:46 -0700 Subject: [PATCH 10/13] Factor common_hal_os_uname into os_uname() and remove common_hal_os_uname. --- ports/analog/common-hal/os/__init__.c | 26 --------------------- ports/atmel-samd/common-hal/os/__init__.c | 26 --------------------- ports/broadcom/common-hal/os/__init__.c | 27 ---------------------- ports/cxd56/common-hal/os/__init__.c | 26 --------------------- ports/espressif/common-hal/os/__init__.c | 26 --------------------- ports/litex/common-hal/os/__init__.c | 26 --------------------- ports/mimxrt10xx/common-hal/os/__init__.c | 25 -------------------- ports/nordic/common-hal/os/__init__.c | 26 --------------------- ports/raspberrypi/common-hal/os/__init__.c | 26 --------------------- ports/renode/common-hal/os/__init__.c | 26 --------------------- ports/silabs/common-hal/os/__init__.c | 25 -------------------- ports/stm/common-hal/os/__init__.c | 26 --------------------- ports/zephyr-cp/common-hal/os/__init__.c | 26 --------------------- shared-bindings/os/__init__.c | 24 ++++++++++++++++++- shared-bindings/os/__init__.h | 3 --- shared-module/os/__init__.c | 2 +- 16 files changed, 24 insertions(+), 342 deletions(-) diff --git a/ports/analog/common-hal/os/__init__.c b/ports/analog/common-hal/os/__init__.c index a32947cb8b054..7b607cf6b3c4b 100644 --- a/ports/analog/common-hal/os/__init__.c +++ b/ports/analog/common-hal/os/__init__.c @@ -15,32 +15,6 @@ // #include "peripherals/periph.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { #if (HAS_TRNG) // todo (low prior): implement diff --git a/ports/atmel-samd/common-hal/os/__init__.c b/ports/atmel-samd/common-hal/os/__init__.c index 1926fdc73e3d8..89b5e85135d87 100644 --- a/ports/atmel-samd/common-hal/os/__init__.c +++ b/ports/atmel-samd/common-hal/os/__init__.c @@ -16,32 +16,6 @@ #include "hal/include/hal_rand_sync.h" #endif -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef SAM_D5X_E5X hri_mclk_set_APBCMASK_TRNG_bit(MCLK); diff --git a/ports/broadcom/common-hal/os/__init__.c b/ports/broadcom/common-hal/os/__init__.c index 72a9a07e9077e..c1c50234451ef 100644 --- a/ports/broadcom/common-hal/os/__init__.c +++ b/ports/broadcom/common-hal/os/__init__.c @@ -10,33 +10,6 @@ #include "py/objtuple.h" #include "py/qstr.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; - -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { return false; } diff --git a/ports/cxd56/common-hal/os/__init__.c b/ports/cxd56/common-hal/os/__init__.c index 3d06d524fd36b..e1024108b07dc 100644 --- a/ports/cxd56/common-hal/os/__init__.c +++ b/ports/cxd56/common-hal/os/__init__.c @@ -10,32 +10,6 @@ #include "py/objstr.h" #include "py/objtuple.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; - -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { uint32_t i = 0; diff --git a/ports/espressif/common-hal/os/__init__.c b/ports/espressif/common-hal/os/__init__.c index 4063090fe1f96..fff89c8476d8d 100644 --- a/ports/espressif/common-hal/os/__init__.c +++ b/ports/espressif/common-hal/os/__init__.c @@ -15,32 +15,6 @@ #include "esp_system.h" #include "esp_random.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { uint32_t i = 0; while (i < length) { diff --git a/ports/litex/common-hal/os/__init__.c b/ports/litex/common-hal/os/__init__.c index 4595ae4804bfb..659411187fafb 100644 --- a/ports/litex/common-hal/os/__init__.c +++ b/ports/litex/common-hal/os/__init__.c @@ -12,32 +12,6 @@ #include "shared-bindings/os/__init__.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { return false; } diff --git a/ports/mimxrt10xx/common-hal/os/__init__.c b/ports/mimxrt10xx/common-hal/os/__init__.c index 6c19ff997967e..ac168f2ed09b3 100644 --- a/ports/mimxrt10xx/common-hal/os/__init__.c +++ b/ports/mimxrt10xx/common-hal/os/__init__.c @@ -17,31 +17,6 @@ #include "sdk/drivers/trng/fsl_trng.h" #endif -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #if CIRCUITPY_RANDOM trng_config_t trngConfig; diff --git a/ports/nordic/common-hal/os/__init__.c b/ports/nordic/common-hal/os/__init__.c index a835be1504fa8..54b8ad026a7de 100644 --- a/ports/nordic/common-hal/os/__init__.c +++ b/ports/nordic/common-hal/os/__init__.c @@ -17,32 +17,6 @@ #include "nrf_rng.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #ifdef BLUETOOTH_SD uint8_t sd_en = 0; diff --git a/ports/raspberrypi/common-hal/os/__init__.c b/ports/raspberrypi/common-hal/os/__init__.c index d9ad1c238ff34..616bb8d8c7929 100644 --- a/ports/raspberrypi/common-hal/os/__init__.c +++ b/ports/raspberrypi/common-hal/os/__init__.c @@ -18,32 +18,6 @@ #include -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - // NIST Special Publication 800-90B (draft) recommends several extractors, // including the SHA hash family and states that if the amount of entropy input // is twice the number of bits output from them, that output can be considered diff --git a/ports/renode/common-hal/os/__init__.c b/ports/renode/common-hal/os/__init__.c index e9f555d7d561c..14e22960469fa 100644 --- a/ports/renode/common-hal/os/__init__.c +++ b/ports/renode/common-hal/os/__init__.c @@ -12,32 +12,6 @@ #include "shared-bindings/os/__init__.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { return false; } diff --git a/ports/silabs/common-hal/os/__init__.c b/ports/silabs/common-hal/os/__init__.c index d7a54429f4bde..79e79875fd541 100644 --- a/ports/silabs/common-hal/os/__init__.c +++ b/ports/silabs/common-hal/os/__init__.c @@ -35,31 +35,6 @@ #include "peripherals/periph.h" #define RNG_TIMEOUT 5 -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { return false; diff --git a/ports/stm/common-hal/os/__init__.c b/ports/stm/common-hal/os/__init__.c index beeb66f7cd556..d654f844b1767 100644 --- a/ports/stm/common-hal/os/__init__.c +++ b/ports/stm/common-hal/os/__init__.c @@ -15,32 +15,6 @@ #include STM32_HAL_H #include "peripherals/periph.h" -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - #define RNG_TIMEOUT 5 bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { diff --git a/ports/zephyr-cp/common-hal/os/__init__.c b/ports/zephyr-cp/common-hal/os/__init__.c index d173f43312355..2f37ba40f47a6 100644 --- a/ports/zephyr-cp/common-hal/os/__init__.c +++ b/ports/zephyr-cp/common-hal/os/__init__.c @@ -13,32 +13,6 @@ #include -static const qstr os_uname_info_fields[] = { - MP_QSTR_sysname, MP_QSTR_nodename, - MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine -}; -static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); -static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); - -static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); -static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); -static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); - -static MP_DEFINE_ATTRTUPLE( - os_uname_info_obj, - os_uname_info_fields, - 5, - (mp_obj_t)&os_uname_info_sysname_obj, - (mp_obj_t)&os_uname_info_nodename_obj, - (mp_obj_t)&os_uname_info_release_obj, - (mp_obj_t)&os_uname_info_version_obj, - (mp_obj_t)&os_uname_info_machine_obj - ); - -mp_obj_t common_hal_os_uname(void) { - return (mp_obj_t)&os_uname_info_obj; -} - bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length) { #if !DT_HAS_CHOSEN(zephyr_entropy) return false; diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index e6f6d4896dc3d..5e28c02452d05 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -44,8 +44,30 @@ //| machine: str //| //| +static const qstr os_uname_info_fields[] = { + MP_QSTR_sysname, MP_QSTR_nodename, + MP_QSTR_release, MP_QSTR_version, MP_QSTR_machine +}; +static const MP_DEFINE_STR_OBJ(os_uname_info_sysname_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_nodename_obj, MICROPY_HW_MCU_NAME); +static const MP_DEFINE_STR_OBJ(os_uname_info_release_obj, MICROPY_VERSION_STRING); +static const MP_DEFINE_STR_OBJ(os_uname_info_version_obj, MICROPY_GIT_TAG " on " MICROPY_BUILD_DATE); +static const MP_DEFINE_STR_OBJ(os_uname_info_machine_obj, MICROPY_HW_BOARD_NAME " with " MICROPY_HW_MCU_NAME); + + +static MP_DEFINE_ATTRTUPLE( + os_uname_info_obj, + os_uname_info_fields, + 5, + (mp_obj_t)&os_uname_info_sysname_obj, + (mp_obj_t)&os_uname_info_nodename_obj, + (mp_obj_t)&os_uname_info_release_obj, + (mp_obj_t)&os_uname_info_version_obj, + (mp_obj_t)&os_uname_info_machine_obj + ); + static mp_obj_t os_uname(void) { - return common_hal_os_uname(); + return (mp_obj_t)&os_uname_info_obj; } static MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname); diff --git a/shared-bindings/os/__init__.h b/shared-bindings/os/__init__.h index f273708cf4ed9..56b643e2edfbe 100644 --- a/shared-bindings/os/__init__.h +++ b/shared-bindings/os/__init__.h @@ -11,9 +11,6 @@ #include "py/objtuple.h" -extern const mp_rom_obj_tuple_t common_hal_os_uname_info_obj; - -mp_obj_t common_hal_os_uname(void); void common_hal_os_chdir(const char *path); mp_obj_t common_hal_os_getcwd(void); mp_obj_t common_hal_os_getenv(const char *key, mp_obj_t default_); diff --git a/shared-module/os/__init__.c b/shared-module/os/__init__.c index 81296db854cd3..6afe64dd62d5b 100644 --- a/shared-module/os/__init__.c +++ b/shared-module/os/__init__.c @@ -17,7 +17,7 @@ #include "shared-bindings/os/__init__.h" // This provides all VFS related OS functions so that ports can share the code -// as needed. It does not provide uname. +// as needed. // Version of mp_vfs_lookup_path that takes and returns uPy string objects. static mp_vfs_mount_t *lookup_path(const char *path, mp_obj_t *path_out) { From 153d7c70f3fd8b89363060d87287d8a7fff7ecc6 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Wed, 19 Mar 2025 15:59:32 -0500 Subject: [PATCH 11/13] check if pins exist before using --- tests/circuitpython-manual/usb/device_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/circuitpython-manual/usb/device_info.py b/tests/circuitpython-manual/usb/device_info.py index 7b8631a8f865a..3481707055507 100644 --- a/tests/circuitpython-manual/usb/device_info.py +++ b/tests/circuitpython-manual/usb/device_info.py @@ -9,7 +9,8 @@ d.switch_to_output(value=True) print("USB power on") -h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM) +if hasattr(board, "USB_HOST_DP") and hasattr(board, "USB_HOST_DM"): + h = usb_host.Port(board.USB_HOST_DP, board.USB_HOST_DM) while True: for device in usb.core.find(find_all=True): From e2c5cbcb24eda266d0aeea90b495117743681d2e Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 19 Mar 2025 20:45:35 -0400 Subject: [PATCH 12/13] CIRCUITPY_FULL_BUILD now controls a few more features --- ports/analog/mpconfigport.h | 3 --- ports/atmel-samd/mpconfigport.h | 3 +-- ports/broadcom/mpconfigport.h | 4 +--- ports/cxd56/boards/spresense/mpconfigboard.h | 2 -- ports/cxd56/mpconfigport.h | 3 --- ports/espressif/mpconfigport.h | 3 --- ports/litex/mpconfigport.h | 2 -- ports/mimxrt10xx/mpconfigport.h | 4 ---- ports/nordic/mpconfigport.h | 2 -- ports/raspberrypi/mpconfigport.h | 3 --- ports/renode/mpconfigport.h | 3 --- ports/silabs/mpconfigport.h | 3 --- ports/stm/mpconfigport.h | 3 --- py/circuitpy_mpconfig.h | 22 ++++++++++++++++++++ 14 files changed, 24 insertions(+), 36 deletions(-) diff --git a/ports/analog/mpconfigport.h b/ports/analog/mpconfigport.h index cadfbddbc55bb..c4b3ee031cacf 100644 --- a/ports/analog/mpconfigport.h +++ b/ports/analog/mpconfigport.h @@ -9,9 +9,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 24KiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 diff --git a/ports/atmel-samd/mpconfigport.h b/ports/atmel-samd/mpconfigport.h index f02f3d595d9b4..eca28dbd9be00 100644 --- a/ports/atmel-samd/mpconfigport.h +++ b/ports/atmel-samd/mpconfigport.h @@ -68,8 +68,7 @@ #define MICROPY_PY_SYS_PLATFORM "MicroChip SAME54" #endif #define SPI_FLASH_MAX_BAUDRATE 24000000 -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) + // MICROPY_PY_ERRNO_LIST - Use the default #endif // SAM_D5X_E5X diff --git a/ports/broadcom/mpconfigport.h b/ports/broadcom/mpconfigport.h index 648259720f800..8b749ca03100a 100644 --- a/ports/broadcom/mpconfigport.h +++ b/ports/broadcom/mpconfigport.h @@ -13,9 +13,7 @@ #define CIRCUITPY_MCU_FAMILY broadcom #define MICROPY_PY_SYS_PLATFORM "BROADCOM" -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) + #if BCM_VERSION == 2837 || BCM_VERSION == 2711 #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_A) #elif BCM_VERSION == 2835 diff --git a/ports/cxd56/boards/spresense/mpconfigboard.h b/ports/cxd56/boards/spresense/mpconfigboard.h index 2d334ef29b301..c9510771b1855 100644 --- a/ports/cxd56/boards/spresense/mpconfigboard.h +++ b/ports/cxd56/boards/spresense/mpconfigboard.h @@ -18,5 +18,3 @@ #define DEFAULT_UART_BUS_RX (&pin_UART2_RXD) #define DEFAULT_UART_BUS_TX (&pin_UART2_TXD) - -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) diff --git a/ports/cxd56/mpconfigport.h b/ports/cxd56/mpconfigport.h index b779b521ddaf9..3bcb252868786 100644 --- a/ports/cxd56/mpconfigport.h +++ b/ports/cxd56/mpconfigport.h @@ -8,9 +8,6 @@ #define MICROPY_PY_SYS_PLATFORM "CXD56" -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 64kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE (0x10000) diff --git a/ports/espressif/mpconfigport.h b/ports/espressif/mpconfigport.h index 443a59b0474bd..98c1986240b73 100644 --- a/ports/espressif/mpconfigport.h +++ b/ports/espressif/mpconfigport.h @@ -17,9 +17,6 @@ #define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (1) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #include "py/circuitpy_mpconfig.h" #define MICROPY_NLR_SETJMP (1) diff --git a/ports/litex/mpconfigport.h b/ports/litex/mpconfigport.h index 50986d16026c2..7ac34a44336cf 100644 --- a/ports/litex/mpconfigport.h +++ b/ports/litex/mpconfigport.h @@ -9,8 +9,6 @@ #define CIRCUITPY_INTERNAL_NVM_SIZE (0) #define MICROPY_NLR_THUMB (0) -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) #include "py/circuitpy_mpconfig.h" diff --git a/ports/mimxrt10xx/mpconfigport.h b/ports/mimxrt10xx/mpconfigport.h index 4f9acd7a9fd30..4d5e4e59700bd 100644 --- a/ports/mimxrt10xx/mpconfigport.h +++ b/ports/mimxrt10xx/mpconfigport.h @@ -17,10 +17,6 @@ extern uint8_t _ld_filesystem_end; extern uint8_t _ld_default_stack_size; #define CIRCUITPY_DEFAULT_STACK_SIZE ((uint32_t)&_ld_default_stack_size) -#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (0) -#define MICROPY_PY_FUNCTION_ATTRS (0) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR ((uint32_t)&_ld_filesystem_start) #define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE ((uint32_t)(&_ld_filesystem_end - &_ld_filesystem_start)) diff --git a/ports/nordic/mpconfigport.h b/ports/nordic/mpconfigport.h index ed6c2827000ca..33fcfa371e0bd 100644 --- a/ports/nordic/mpconfigport.h +++ b/ports/nordic/mpconfigport.h @@ -13,8 +13,6 @@ #include "nrf_sdm.h" // for SD_FLASH_SIZE #include "peripherals/nrf/nvm.h" // for FLASH_PAGE_SIZE -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) #define MICROPY_PY_SYS_STDIO_BUFFER (1) // 24kiB stack diff --git a/ports/raspberrypi/mpconfigport.h b/ports/raspberrypi/mpconfigport.h index 00dcafe10fe11..1181517fdf9a0 100644 --- a/ports/raspberrypi/mpconfigport.h +++ b/ports/raspberrypi/mpconfigport.h @@ -16,9 +16,6 @@ #define MICROPY_PY_SYS_PLATFORM "RP2350" #endif -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // Setting a non-default value also requires a non-default link.ld #ifndef CIRCUITPY_FIRMWARE_SIZE #define CIRCUITPY_FIRMWARE_SIZE (1020 * 1024) diff --git a/ports/renode/mpconfigport.h b/ports/renode/mpconfigport.h index 19937d749d47b..185a884ed313e 100644 --- a/ports/renode/mpconfigport.h +++ b/ports/renode/mpconfigport.h @@ -8,9 +8,6 @@ #define MICROPY_PY_SYS_PLATFORM "Renode" -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - #define MICROPY_USE_INTERNAL_PRINTF (1) // This also includes mpconfigboard.h. diff --git a/ports/silabs/mpconfigport.h b/ports/silabs/mpconfigport.h index ce7739cccaea4..26fe7dfc2f0b5 100644 --- a/ports/silabs/mpconfigport.h +++ b/ports/silabs/mpconfigport.h @@ -29,9 +29,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - // 24kiB stack #define CIRCUITPY_DEFAULT_STACK_SIZE 0x6000 diff --git a/ports/stm/mpconfigport.h b/ports/stm/mpconfigport.h index ed36b49ffb92f..afa9aa3685c9a 100644 --- a/ports/stm/mpconfigport.h +++ b/ports/stm/mpconfigport.h @@ -9,9 +9,6 @@ #include -#define MICROPY_PY_FUNCTION_ATTRS (1) -#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1) - extern uint8_t _ld_default_stack_size; // 24kiB stack diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 0121144f8ced6..0168b0f4d8254 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -93,6 +93,7 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_OPT_COMPUTED_GOTO_SAVE_SPACE (CIRCUITPY_COMPUTED_GOTO_SAVE_SPACE) #define MICROPY_OPT_LOAD_ATTR_FAST_PATH (CIRCUITPY_OPT_LOAD_ATTR_FAST_PATH) #define MICROPY_OPT_MAP_LOOKUP_CACHE (CIRCUITPY_OPT_MAP_LOOKUP_CACHE) +#define MICROPY_OPT_MPZ_BITWISE (0) #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (CIRCUITPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) #define MICROPY_PERSISTENT_CODE_LOAD (1) @@ -224,31 +225,52 @@ typedef long mp_off_t; // Turning off FULL_BUILD removes some functionality to reduce flash size on tiny SAMD21s #define MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_CPYTHON_COMPAT #define MICROPY_CPYTHON_COMPAT (CIRCUITPY_FULL_BUILD) #endif + #ifndef MICROPY_CPYTHON_EXCEPTION_CHAIN #define MICROPY_CPYTHON_EXCEPTION_CHAIN (CIRCUITPY_FULL_BUILD) #endif + #define MICROPY_PY_BUILTINS_POW3 (CIRCUITPY_BUILTINS_POW3) #define MICROPY_PY_FSTRINGS (1) #define MICROPY_MODULE_WEAK_LINKS (0) #define MICROPY_PY_ALL_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_PY_BUILTINS_COMPLEX #define MICROPY_PY_BUILTINS_COMPLEX (CIRCUITPY_FULL_BUILD) #endif + #define MICROPY_PY_BUILTINS_FROZENSET (CIRCUITPY_FULL_BUILD) + +#ifndef MICROPY_PY_BUILTINS_NOTIMPLEMENTED +#define MICROPY_PY_BUILTINS_NOTIMPLEMENTED (CIRCUITPY_FULL_BUILD) +#endif + #define MICROPY_PY_BUILTINS_STR_CENTER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_PARTITION (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_BUILTINS_STR_SPLITLINES (CIRCUITPY_FULL_BUILD) + #ifndef MICROPY_PY_COLLECTIONS_ORDEREDDICT #define MICROPY_PY_COLLECTIONS_ORDEREDDICT (CIRCUITPY_FULL_BUILD) #endif + #ifndef MICROPY_PY_COLLECTIONS_DEQUE #define MICROPY_PY_COLLECTIONS_DEQUE (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_COLLECTIONS_DEQUE_ITER (CIRCUITPY_FULL_BUILD) #define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (CIRCUITPY_FULL_BUILD) #endif + +#ifndef MICROPY_PY_FUNCTION_ATTRS +#define MICROPY_PY_FUNCTION_ATTRS (CIRCUITPY_FULL_BUILD) +#endif + +#ifndef MICROPY_PY_REVERSE_SPECIAL_METHODS +#define MICROPY_PY_REVERSE_SPECIAL_METHODS (CIRCUITPY_FULL_BUILD) +#endif + #define MICROPY_PY_RE_MATCH_GROUPS (CIRCUITPY_RE) #define MICROPY_PY_RE_MATCH_SPAN_START_END (CIRCUITPY_RE) #define MICROPY_PY_RE_SUB (CIRCUITPY_RE) From 0f315069a6ff1fd15414582f8084788d00d8db4f Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sat, 22 Mar 2025 12:51:59 +0100 Subject: [PATCH 13/13] waveshare_esp32_s3_geek: fix SPI busses and board_init() --- .../boards/waveshare_esp32_s3_geek/board.c | 9 --------- .../waveshare_esp32_s3_geek/mpconfigboard.h | 6 +++--- .../boards/waveshare_esp32_s3_geek/pins.c | 15 +++++++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/board.c b/ports/espressif/boards/waveshare_esp32_s3_geek/board.c index 71f742b51f423..414188fb46a52 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/board.c +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/board.c @@ -30,18 +30,9 @@ uint8_t display_init_sequence[] = { }; static void display_init(void) { - busio_spi_obj_t *spi = common_hal_board_create_spi(0); fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus; - common_hal_busio_spi_construct( - spi, - &pin_GPIO12, // CLK - &pin_GPIO11, // MOSI - NULL, // MISO not connected - false); // Not half-duplex - - bus->base.type = &fourwire_fourwire_type; common_hal_fourwire_fourwire_construct( diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h b/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h index 2da021447e39f..87ac391f5a0bf 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/mpconfigboard.h @@ -17,6 +17,6 @@ #define DEFAULT_I2C_BUS_SCL (&pin_GPIO17) #define DEFAULT_I2C_BUS_SDA (&pin_GPIO16) -#define DEFAULT_SPI_BUS_SCK (&pin_GPIO36) -#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO35) -#define DEFAULT_SPI_BUS_MISO (&pin_GPIO37) +#define CIRCUITPY_BOARD_SPI (2) +#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO12, .mosi = &pin_GPIO11}, \ + {.clock = &pin_GPIO36, .mosi = &pin_GPIO35, .miso = &pin_GPIO37}} diff --git a/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c b/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c index 01c3baf8c9f8f..65d391ec9ea88 100644 --- a/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c +++ b/ports/espressif/boards/waveshare_esp32_s3_geek/pins.c @@ -5,8 +5,10 @@ // SPDX-License-Identifier: MIT #include "shared-bindings/board/__init__.h" - #include "shared-module/displayio/__init__.h" + +CIRCUITPY_BOARD_BUS_SINGLETON(sd_spi, spi, 1) + static const mp_rom_map_elem_t board_module_globals_table[] = { CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS @@ -64,11 +66,11 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, // SD Card - { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36)}, - { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35)}, - { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37)}, - { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34)}, - { MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_spi_obj) }, + { MP_ROM_QSTR(MP_QSTR_SD_SCK), MP_ROM_PTR(&pin_GPIO36) }, + { MP_ROM_QSTR(MP_QSTR_SD_MOSI), MP_ROM_PTR(&pin_GPIO35) }, + { MP_ROM_QSTR(MP_QSTR_SD_MISO), MP_ROM_PTR(&pin_GPIO37) }, + { MP_ROM_QSTR(MP_QSTR_SD_CS), MP_ROM_PTR(&pin_GPIO34) }, + { MP_ROM_QSTR(MP_QSTR_SD_SPI), MP_ROM_PTR(&board_sd_spi_obj) }, // Pin 38 is for the SDIO interface, and therefore not included in the SPI object // LCD @@ -78,6 +80,7 @@ static const mp_rom_map_elem_t board_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_LCD_RST), MP_ROM_PTR(&pin_GPIO9) }, { MP_ROM_QSTR(MP_QSTR_LCD_BACKLIGHT), MP_ROM_PTR(&pin_GPIO7) }, { MP_ROM_QSTR(MP_QSTR_LCD_DC), MP_ROM_PTR(&pin_GPIO8) }, + { MP_ROM_QSTR(MP_QSTR_LCD_SPI), MP_ROM_PTR(&board_spi_obj) }, { MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) }, };