From c5ed805a284e1b146bb2a038241f8939db8e5b7e Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Mon, 7 Jan 2019 16:05:00 +0100 Subject: [PATCH 1/2] Add preprocessing of linker script This allow to use switch in ldscript.ld file. Signed-off-by: Frederic.Pillon --- platform.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index aef2883560..bb9d1eff67 100644 --- a/platform.txt +++ b/platform.txt @@ -93,6 +93,11 @@ recipe.hooks.prebuild.1.pattern.windows=cmd /c if not exist "{build.opt.sourcepa recipe.hooks.prebuild.1.pattern.linux=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})" recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || (mkdir -p {build.path}/sketch && touch {build.opt.path})" +# preprocess linker file +preprocld.name=preproc.ld +preprocld.filepath={build.path}/{preprocld.name} +recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -x c -E -P {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "{build.variant.path}/{build.ldscript}" -o "{preprocld.filepath}" + # compile patterns # --------------------- @@ -109,7 +114,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} {build.i recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}" ## Combine gc-sections, archives, and objects -recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{build.variant.path}/{build.ldscript}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++ +recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} "-T{preprocld.filepath}" "-Wl,-Map,{build.path}/{build.project_name}.map" {compiler.c.elf.extra_flags} {compiler.ldflags} {compiler.arm.cmsis.ldflags} -o "{build.path}/{build.project_name}.elf" "-L{build.path}" -Wl,--start-group {object_files} -Wl,--whole-archive "{archive_file_path}" -Wl,--no-whole-archive -lc -Wl,--end-group -lm -lgcc -lstdc++ ## Create output (.bin file) recipe.objcopy.bin.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.elf2bin.flags} {compiler.elf2bin.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin" From 176ebbfbc0fd49030ea2eeaf879e3646211ad6d1 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Tue, 15 Jan 2019 15:37:32 +0100 Subject: [PATCH 2/2] Add flags to prelink recipe for linker script preprocessing By default, add define for RAM and FLASH max size -DLD_MAX_SIZE={upload.maximum_size} -DLD_MAX_DATA_SIZE={upload.maximum_data_size} Signed-off-by: Frederic.Pillon --- platform.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform.txt b/platform.txt index bb9d1eff67..0c859f36c7 100644 --- a/platform.txt +++ b/platform.txt @@ -96,7 +96,8 @@ recipe.hooks.prebuild.1.pattern.macosx=bash -c "[ -f {build.opt.sourcepath} ] || # preprocess linker file preprocld.name=preproc.ld preprocld.filepath={build.path}/{preprocld.name} -recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -x c -E -P {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "{build.variant.path}/{build.ldscript}" -o "{preprocld.filepath}" +preprocld.flags=-DLD_MAX_SIZE={upload.maximum_size} -DLD_MAX_DATA_SIZE={upload.maximum_data_size} +recipe.hooks.linking.prelink.1.pattern="{compiler.path}{compiler.c.cmd}" -x c -E -P {preprocld.flags} {compiler.c.flags} {build.info.flags} {compiler.c.extra_flags} {build.extra_flags} {compiler.arm.cmsis.c.flags} "{build.variant.path}/{build.ldscript}" -o "{preprocld.filepath}" # compile patterns # ---------------------