From 4d3897f80e329f074ab11cd0214b559a122f9778 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 4 Mar 2023 15:27:57 +0100 Subject: [PATCH] mimxrt: Enable ROM text compression. To reduce size of firmware, by about 3k. --- ports/mimxrt/Makefile | 5 +++++ ports/mimxrt/machine_led.c | 2 +- ports/mimxrt/machine_sdcard.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index e5a14d010c..b73d3f4db9 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -40,6 +40,9 @@ include ../../py/mkenv.mk # Include micropython configuration board makefile include $(BOARD_DIR)/mpconfigboard.mk +# MicroPython feature configurations +MICROPY_ROM_TEXT_COMPRESSION ?= 1 + # File containing description of content to be frozen into firmware. FROZEN_MANIFEST ?= boards/manifest.py @@ -290,6 +293,8 @@ SRC_QSTR += $(SRC_C) $(SHARED_SRC_C) $(GEN_PINS_SRC) CFLAGS += -g # always include debug info in the ELF ifeq ($(DEBUG),1) CFLAGS += -Og +# Disable text compression in debug builds +MICROPY_ROM_TEXT_COMPRESSION = 0 else CFLAGS += -Os -DNDEBUG endif diff --git a/ports/mimxrt/machine_led.c b/ports/mimxrt/machine_led.c index 8dd74b32ba..35743697f2 100644 --- a/ports/mimxrt/machine_led.c +++ b/ports/mimxrt/machine_led.c @@ -44,7 +44,7 @@ STATIC mp_obj_t led_obj_make_new(const mp_obj_type_t *type, size_t n_args, size_ // Check led id is in range if (!(1 <= led_id && led_id <= NUM_LEDS)) { - mp_raise_msg_varg(&mp_type_ValueError, "LED(%d) doesn't exist", led_id); + mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("LED(%d) doesn't exist"), led_id); } // Return reference to static object diff --git a/ports/mimxrt/machine_sdcard.c b/ports/mimxrt/machine_sdcard.c index 35e1ef7eeb..496eb93533 100644 --- a/ports/mimxrt/machine_sdcard.c +++ b/ports/mimxrt/machine_sdcard.c @@ -67,7 +67,7 @@ STATIC mp_obj_t sdcard_obj_make_new(const mp_obj_type_t *type, size_t n_args, si mp_int_t sdcard_id = args[SDCARD_INIT_ARG_ID].u_int; if (!(1 <= sdcard_id && sdcard_id <= MP_ARRAY_SIZE(mimxrt_sdcard_objs))) { - nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "SDCard(%d) doesn't exist", sdcard_id)); + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("SDCard(%d) doesn't exist"), sdcard_id)); } mimxrt_sdcard_obj_t *self = &mimxrt_sdcard_objs[(sdcard_id - 1)];