Skip to content
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

Reduce resulting code size #82

Open
jeroentaverne opened this issue Dec 12, 2024 · 2 comments
Open

Reduce resulting code size #82

jeroentaverne opened this issue Dec 12, 2024 · 2 comments

Comments

@jeroentaverne
Copy link

Hi! Thanks for the great work! I switched to the latest version of your code, but the resulting binary is getting too big for my project. If possible could you add a configuration header file to enable/disable support for SDIO / SPI / RTC / file stream / crash / debug and perhaps other options? I removed some code by hand now which seems to work, but a cleaner way would be great!

@carlk3
Copy link
Owner

carlk3 commented Dec 12, 2024

How are you using the library? I can't see how you are picking up filestream, unless you are running the stdio_buffering example or something like it. Similarly, how are you picking up the crash handling unless you are running the command_line example or something like it?

To minimize the size of this library, you can set these C preprocessor macros to 0:

  • USE_PRINTF
  • USE_DBG_PRINTF
  • SD_CRC_ENABLED

and set this to 1:

  • NDEBUG

Ensure that you are using compile options -ffunction-sections -fdata-sections and link option --gc-sections. Consider compile options -Os or -Oz.

I need to look at the initialization code; I think a recent change might have it accidentally picking up about 412 Bytes of unnecessary code if SDIO is not used.

@jeroentaverne
Copy link
Author

Thanks for the guide to get the size down. I will check it out. For my project I have multiple smaller firmware images inside the 2MB FLASH, so size reduction of a few 100/1000 bytes can make a difference. Off topic, if interested: my firmware selection example code, which is also used in the PicoGUS project can be found here: https://github.com/jeroentaverne/pico_multi_firmware

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

No branches or pull requests

2 participants