From 6572ce84c95b72dac92cc587ca16babf92afe59e Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Fri, 14 Nov 2025 04:27:17 +0100 Subject: [PATCH] samd/pin_af: Reduce footprint of pin structures. This commit performs a few minor changes to the structures used to store board pin information, in order to reduce the impact on the .rodata section of the firmware of instances of those structures. The pin objects structure ("machine_pin_obj_t") instead has its QSTR variable holder changed from "qstr" to "qstr_short_t", and some elements of that structure have been rearranged to remove enough padding bytes inside structure elements to let the linker allocate less data for instances of that structure. Signed-off-by: Alessandro Gatti --- ports/samd/boards/pins_prefix.c | 4 ++-- ports/samd/pin_af.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ports/samd/boards/pins_prefix.c b/ports/samd/boards/pins_prefix.c index 4f0095d332..2437859339 100644 --- a/ports/samd/boards/pins_prefix.c +++ b/ports/samd/boards/pins_prefix.c @@ -11,11 +11,11 @@ #if defined(MCU_SAMD21) #define PIN(p_name, p_eic, p_adc0, p_sercom1, p_sercom2, p_tcc1, p_tcc2) \ - {{&machine_pin_type}, PIN_##p_name, MP_QSTR_##p_name, p_eic, p_adc0, p_sercom1, p_sercom2, p_tcc1, p_tcc2 } + {{&machine_pin_type}, MP_QSTR_##p_name, PIN_##p_name, p_eic, p_adc0, p_sercom1, p_sercom2, p_tcc1, p_tcc2 } #elif defined(MCU_SAMD51) #define PIN(p_name, p_eic, p_adc0, p_adc1, p_sercom1, p_sercom2, p_tc, p_tcc1, p_tcc2) \ - {{&machine_pin_type}, PIN_##p_name, MP_QSTR_##p_name, p_eic, p_adc0, p_adc1, p_sercom1, p_sercom2, p_tc, p_tcc1, p_tcc2 } + {{&machine_pin_type}, MP_QSTR_##p_name, PIN_##p_name, p_eic, p_adc0, p_adc1, p_sercom1, p_sercom2, p_tc, p_tcc1, p_tcc2 } #endif diff --git a/ports/samd/pin_af.h b/ports/samd/pin_af.h index bc65e8ae23..11ef75c63f 100644 --- a/ports/samd/pin_af.h +++ b/ports/samd/pin_af.h @@ -32,8 +32,8 @@ typedef struct _machine_pin_obj_t { mp_obj_base_t base; + qstr_short_t name; uint8_t pin_id; - qstr name; uint8_t eic; uint8_t adc0; uint8_t sercom1; @@ -50,8 +50,8 @@ typedef struct _machine_pin_obj_t { typedef struct _machine_pin_obj_t { mp_obj_base_t base; + qstr_short_t name; uint8_t pin_id; - qstr name; uint8_t eic; uint8_t adc0; uint8_t adc1;