There are a few low-effort strategies for managing program size, as well as increasing how much program size can be executed that can be used with libDaisy projects
As @Takumi_Ogata mentioned, using the -Os
flag both in libDaisy, and in your main project can help reduce flash size without require any additional work. So that’s always a quick starting point if you’re trying to make a little bit more room.
Bootloader Application:
Beyond that, an application can be rebuilt to run on the daisy bootloader. This is all bundled into the libDaisy framework so that it can be easily used to any project using the Makefile
build system with libDaisy.
# Anywhere above the "include" statement at the bottom of the file:
APP_TYPE=BOOT_SRAM
# optionally provide your own linker script
# LDSCRIPT=sram_linker.ld
With this added, you can recompile your program, and it will be linked for execution from a larger region of memory.
You can flash the bootloader to your Daisy via USB DFU with
make program-boot
and then you can program your app to the Daisy as normal with:
make program-dfu
The SRAM applications will have similar (and sometimes even better) performance than the same application running from internal flash.
Debugging via JTAG is still possible, though a little less convenient.
note: there are a few weirdnesses with the default linker script that can make DMA, and SD card functionality problematic. This is easily resolved with a custom linker script, and we’re considering swapping the default linker script for bootloader apps to have more consistent usage with the internal flash version.
libDaisy feature-stripping:
If, for some reason, using the bootloader with your application is not possible there are some small modifications to the library source code that can remove a fair amount of code.
One of the biggest sources of program-size bloat is due to the global initialization for the dma-compatible peripherals (spi, i2c, uart). These being in the project contribute about 20kB of program memory, whether you’re using the peripherals or not.
If you’re not some or all of these peripherals, you can comment out the corresponding function for the peripherals you don’t need here in the system initialization. Once you recompile libDaisy, and your application you should see those reductions take effect. Just keep in mind, attempts to use the DMA for those peripherals without that call with have unexpected behavior.
If your application isn’t using audio (a much less common scenario), you can trim another ~11kB by commenting out the ConfigureAudio
line in the Daisy Seed Initialization (don’t forget to recompile libDaisy after making changes to see them take effect).
Hope that helps!