@@ -19,7 +19,7 @@ compiler.path={build.compiler_path}
19
19
compiler.c.cmd={build.crossprefix}gcc
20
20
compiler.c.flags=-g -c {compiler.warning_flags} {compiler.zephyr.macros} "@{compiler.zephyr.cflags_file}" -MMD -mcpu={build.mcu} {build.float-abi} {build.fpu}
21
21
compiler.c.elf.cmd={build.crossprefix}g++
22
- compiler.c.elf.flags={build.llext_link_flags} -Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=gnu++17
22
+ compiler.c.elf.flags=-Wl,--gc-sections -mcpu={build.mcu} {build.float-abi} {build.fpu} -std=gnu++17
23
23
compiler.S.cmd={build.crossprefix}g++
24
24
compiler.S.flags=-c -x assembler-with-cpp -mcpu={build.mcu} {build.fpu}
25
25
compiler.cpp.cmd={build.crossprefix}g++
@@ -46,15 +46,28 @@ compiler.zephyr.common_ldflags=-fno-exceptions -fno-rtti -fno-threadsafe-statics
46
46
compiler.zephyr.extra_cxxflags=
47
47
compiler.zephyr.extra_ldflags=-lstdc++ -lsupc++
48
48
49
- # this can be overriden in boards.txt
49
+ # these can be overriden in boards.txt
50
50
build.extra_flags=
51
51
build.extra_ldflags=
52
-
53
- build.ldscript={runtime.platform.path}/variants/_llext/linker_script.ld
54
- build.llext_link_flags=-r -e main
52
+ build.link_mode=dynamic
55
53
upload.extension=elf-zsk.bin
56
- postbuild_debug=
57
- postbuild_mode=
54
+
55
+ build.ldscript.path={runtime.platform.path}/variants/_ldscripts
56
+ build.link_command="{compiler.path}{compiler.c.elf.cmd}" "-L{build.path}" "-L{build.variant.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} {build.extra_flags} {build.extra_ldflags} {compiler.zephyr.common_ldflags} --specs=picolibc.specs --specs=nosys.specs {compiler.ldflags} {object_files} -Wl,--start-group "{build.path}/{archive_file}" {compiler.zephyr.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group {build.link_args.{build.link_mode}}
57
+
58
+ # link_args.* are included by any link_command depending on the link_mode
59
+ build.link_args.dynamic=-e main
60
+ build.link_args.static=-lc -lm -lgcc -L{build.variant.path} -Wl,--wrap=random -Wl,--wrap=calloc -Wl,--wrap=free -Wl,--wrap=malloc -Wl,--wrap=realloc
61
+
62
+ # link_args.build-* are used to create the final binary. -common are added to both static and dynamic.
63
+ build.link_args.build-dynamic="-T{build.ldscript.path}/dynamic.ld" -r
64
+ build.link_args.build-static="-T{build.variant.path}/provides.ld" "-T{build.ldscript.path}/static.ld"
65
+ build.link_args.build-common="-Wl,-Map,{build.path}/{build.project_name}.map" -o "{build.path}/{build.project_name}_debug.elf"
66
+
67
+ # zsk_args are used to create the final binary with zephyr-sketch-tool
68
+ build.zsk_args.debug=
69
+ build.zsk_args.mode-dynamic=
70
+ build.zsk_args.mode-static=-prelinked
58
71
59
72
# These can be overridden in platform.local.txt
60
73
compiler.c.extra_flags=
@@ -96,7 +109,7 @@ recipe.S.o.pattern="{compiler.path}{compiler.S.cmd}" {compiler.S.flags} -DARDUIN
96
109
recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} "{archive_file_path}" "{object_file}"
97
110
98
111
## Combine gc-sections, archives, and objects
99
- recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" "-L{ build.path}" {compiler.c.elf.flags} {compiler.c.elf.extra_flags} { build.extra_flags} {build.extra_ldflags} {compiler.zephyr.common_ldflags} "-T{ build.ldscript}" "-Wl,-Map, {build.path}/{build.project_name}.map" --specs=picolibc.specs --specs=nosys.specs {compiler.ldflags} -o "{ build.path}/{build.project_name}_debug.elf" {object_files} -Wl,--start-group "{ build.path}/{archive_file}" {compiler.zephyr.extra_ldflags} {compiler.libraries.ldflags} -Wl,--end-group
112
+ recipe.c.combine.pattern={ build.link_command} { build.link_args. build- {build.link_mode}} { build.link_args. build-common}
100
113
recipe.hooks.linking.postlink.1.pattern="{compiler.path}{build.crossprefix}strip" --strip-debug "{build.path}/{build.project_name}_debug.elf" -o "{build.path}/{build.project_name}.elf"
101
114
102
115
## Create eeprom
@@ -109,8 +122,8 @@ recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf
109
122
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
110
123
111
124
## Mangle the file
112
- recipe.hooks.objcopy.postobjcopy.1.pattern="{runtime.tools.zephyr-sketch-tool.path}/zephyr-sketch-tool" {postbuild_debug } {postbuild_mode } "{build.path}/{build.project_name}.elf"
113
- recipe.hooks.objcopy.postobjcopy.2.pattern="{runtime.tools.zephyr-sketch-tool.path}/zephyr-sketch-tool" {postbuild_debug } {postbuild_mode } "{build.path}/{build.project_name}.bin"
125
+ recipe.hooks.objcopy.postobjcopy.1.pattern="{runtime.tools.zephyr-sketch-tool.path}/zephyr-sketch-tool" {build.zsk_args.debug } {build.zsk_args.mode-{build.link_mode} } "{build.path}/{build.project_name}.elf"
126
+ recipe.hooks.objcopy.postobjcopy.2.pattern="{runtime.tools.zephyr-sketch-tool.path}/zephyr-sketch-tool" {build.zsk_args.debug } {build.zsk_args.mode-{build.link_mode} } "{build.path}/{build.project_name}.bin"
114
127
115
128
## Compute size
116
129
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
0 commit comments