diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 58d93a700bb90..fa9bd923fdc4d 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -117,7 +117,7 @@ CFLAGS += \ -msoft-float \ -mfloat-abi=soft \ -DSAMD21 -LIBS := libs/libgcc-12.1.0-Os-v6-m-nofp.a -lc +LIBS := libs/libgcc-14.2.0-Os-v6-m-nofp.a -lc else LIBS := -lgcc -lc endif diff --git a/ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h b/ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h index 8e53129679f2a..7b206ddaf548a 100644 --- a/ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h +++ b/ports/atmel-samd/boards/adafruit_trrs_trinkey_m0/mpconfigboard.h @@ -40,3 +40,6 @@ // no PA29 #define IGNORE_PIN_PA30 1 #define IGNORE_PIN_PA31 1 + +// A couple Learn examples do `array.array('d', ...)` so enable it. +#define MICROPY_PY_DOUBLE_TYPECODE 1 diff --git a/ports/atmel-samd/libs/libgcc-12.1.0-Os-v6-m-nofp.a b/ports/atmel-samd/libs/libgcc-12.1.0-Os-v6-m-nofp.a deleted file mode 100644 index 56692d5d05632..0000000000000 Binary files a/ports/atmel-samd/libs/libgcc-12.1.0-Os-v6-m-nofp.a and /dev/null differ diff --git a/ports/atmel-samd/libs/libgcc-14.2.0-Os-v6-m-nofp.a b/ports/atmel-samd/libs/libgcc-14.2.0-Os-v6-m-nofp.a new file mode 100644 index 0000000000000..6a708c1ffaa3c Binary files /dev/null and b/ports/atmel-samd/libs/libgcc-14.2.0-Os-v6-m-nofp.a differ diff --git a/py/binary.c b/py/binary.c index 75dfc19925fec..2167d38023eb6 100644 --- a/py/binary.c +++ b/py/binary.c @@ -289,8 +289,10 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) { #if MICROPY_PY_BUILTINS_FLOAT case 'f': return mp_obj_new_float_from_f(((float *)p)[index]); + #if MICROPY_PY_DOUBLE_TYPECODE case 'd': return mp_obj_new_float_from_d(((double *)p)[index]); + #endif #endif // CIRCUITPY-CHANGE: non-standard typecodes can be turned off #if MICROPY_NONSTANDARD_TYPECODES @@ -367,6 +369,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte * float f; } fpu = {val}; return mp_obj_new_float_from_f(fpu.f); + #if MICROPY_PY_DOUBLE_TYPECODE } else if (val_type == 'd') { union { uint64_t i; @@ -374,6 +377,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte * } fpu = {val}; return mp_obj_new_float_from_d(fpu.f); #endif + #endif } else if (is_signed(val_type)) { if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) { return mp_obj_new_int((mp_int_t)val); @@ -445,6 +449,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p val = fp_sp.i; break; } + #if MICROPY_PY_DOUBLE_TYPECODE case 'd': { union { uint64_t i64; @@ -463,6 +468,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p break; } #endif + #endif default: { // CIRCUITPY-CHANGE: add overflow checks bool signed_type = is_signed(val_type); @@ -501,10 +507,12 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_ case 'f': ((float *)p)[index] = mp_obj_get_float_to_f(val_in); break; + #if MICROPY_PY_DOUBLE_TYPECODE case 'd': ((double *)p)[index] = mp_obj_get_float_to_d(val_in); break; #endif + #endif // CIRCUITPY-CHANGE: non-standard typecodes can be turned off #if MICROPY_NONSTANDARD_TYPECODES // Extension to CPython: array of objects @@ -574,9 +582,11 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, size_t index, mp_i case 'f': ((float *)p)[index] = (float)val; break; + #if MICROPY_PY_DOUBLE_TYPECODE case 'd': ((double *)p)[index] = (double)val; break; + #endif #endif // CIRCUITPY-CHANGE: non-standard typecodes can be turned off #if MICROPY_NONSTANDARD_TYPECODES diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index e52a68982aa70..7dd2b4a3c609a 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -141,7 +141,11 @@ extern void common_hal_mcu_enable_interrupts(void); #define MICROPY_PY_UCTYPES (0) #define MICROPY_PY___FILE__ (1) +#if CIRCUITPY_FULL_BUILD #define MICROPY_QSTR_BYTES_IN_HASH (1) +#else +#define MICROPY_QSTR_BYTES_IN_HASH (0) +#endif #define MICROPY_REPL_AUTO_INDENT (1) #define MICROPY_REPL_EVENT_DRIVEN (0) #define MICROPY_STACK_CHECK (1) @@ -257,6 +261,10 @@ typedef long mp_off_t; #define MICROPY_PY_COLLECTIONS_DEQUE_SUBSCR (CIRCUITPY_FULL_BUILD) #endif +#ifndef MICROPY_PY_DOUBLE_TYPECODE +#define MICROPY_PY_DOUBLE_TYPECODE (CIRCUITPY_FULL_BUILD ? 1 : 0) +#endif + #ifndef MICROPY_PY_FUNCTION_ATTRS #define MICROPY_PY_FUNCTION_ATTRS (CIRCUITPY_FULL_BUILD) #endif diff --git a/py/mpconfig.h b/py/mpconfig.h index 60e7afe52f953..1570265c1999c 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -881,6 +881,10 @@ typedef double mp_float_t; #define MICROPY_PY_BUILTINS_COMPLEX (MICROPY_PY_BUILTINS_FLOAT) #endif +#ifndef MICROPY_PY_DOUBLE_TYPECODE +#define MICROPY_PY_DOUBLE_TYPECODE (MICROPY_PY_BUILTINS_FLOAT) +#endif + // Whether to use the native _Float16 for 16-bit float support #ifndef MICROPY_FLOAT_USE_NATIVE_FLT16 #ifdef __FLT16_MAX__