Skip to content

save about 112 bytes #7026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 10, 2022
Merged

save about 112 bytes #7026

merged 2 commits into from
Oct 10, 2022

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Oct 9, 2022

Saves about 112 bytes on non-Express M0 builds:

  • Remove MpyError exception, which wasn't used anywhere by us (EDIT: At one time it was used to display a RGB LED status color to indicate incompatible .mpy files. However, that was removed when the RGB status indicators were simplified.)
  • Remove two redundant calls to reset_pin_number() in atmel-samd I2C. These calls are done in the deinit code, and don't need to be done before deinit is called.
  • Change a few mp_printf() calls to mp_cprintf() with a translated string. I tried this in a number of places, and the only significant difference was the on in main.c. Very surprisingly, this change in run_boot_py() saves about 60 bytes:
        mp_printf(&mp_plat_print, "%s\nBoard ID:%s\n", MICROPY_FULL_VERSION_INFO, CIRCUITPY_BOARD_ID);
        #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0
        uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH];
        common_hal_mcu_processor_get_uid(raw_id);
        mp_cprintf(&mp_plat_print, translate("UID:"));
        for (size_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) {
            mp_cprintf(&mp_plat_print, translate("%02X"), raw_id[i]);
        }
        mp_printf(&mp_plat_print, "\n");

Both "UID:" and "%02X" must be translated to get the savings. If either one is omitted, the savings is much less. I looked at the assembly output, and it might be doing a better job of optimization, but I'm not sure why. Or something in the translation table construction reaches some inflection point. It's very odd. Neither string will need to actually be translated by the translators.

This will allow most but not all boards that are failing in #6923 to fit.

Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@dhalbert dhalbert merged commit 14c9028 into adafruit:main Oct 10, 2022
@dhalbert dhalbert deleted the minor-space-savings branch October 10, 2022 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants