MarlinFirmware / AutoBuildMarlin

Visual Studio Code extension to more easily build Marlin Firmware
GNU General Public License v3.0
259 stars 60 forks source link

How to properly add build flags and/or custom environment for memory tuning #86

Open bengalih opened 2 months ago

bengalih commented 2 months ago

Trying to follow this: https://thborges.github.io/blog/marlin/2019/01/07/reducing-marlin-binary-size.html

which states:

If you are using PlataformIO, it is easier. Just create a new build target in platformio.ini, copying the original config for your printer board and add the new flags:

build_unflags = -g -ggdb
build_flags   = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues

I can do something like this at the bottom of platformio.ini:

[env:mega2560_memory_fix]
platform         = atmelavr
board            = megaatmega2560
framework        = arduino
extra_scripts    = ${common.extra_scripts}
build_unflags    = -g -ggdb
build_flags      = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -Wl,--relax -mcall-prologues
lib_deps         = ${common.lib_deps}
monitor_speed    = 250000
monitor_eol      = LF
monitor_echo     = yes
monitor_filters  = colorize, time, send_on_enter

But I don't know how to call upon this from AutoBuildMarlin to properly attempt a build and upload with these fixes.

bengalih commented 2 months ago

I've figured out how to do this - but probably not in the best fashion. The file to modify is not platformio.ini but buildroot > ini > avr.ini

I changed this:

build_flags       = ${common.build_flags} -std=gnu++1z -Wl,--relax
build_unflags     = -std=gnu++11

to this:

build_flags       = ${common.build_flags} -fno-tree-scev-cprop -fno-split-wide-types -std=gnu++1z -Wl,--relax -mcall-prologues
build_unflags     = -g -ggdb -std=gnu++11

by basically combining my necessary settings with what was there.

However, these seems like a sloppy way to do it. Is there a cleaner way to create a profile with the tuned memory settings and have it accessible from the ABM panel so you can manage the build and upload process?