Thanks for the reply. Yes, your suggestion is better. I will do that.
But I still have a problem with linker script and it does not work properly. For some reason for linker flag (-T) platformio prepends ‘-Wl,’ so the result is that I have error :
d:/users/michael/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/ar
m-none-eabi/4.8.4/../../../../arm-none-eabi/lib/armv7e-m/fpu\libc_s.a(lib_a-sbrk
r.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
collect2.exe: error: ld returned 1 exit status
ldscripts are defined in variant folder “variants\DISCOVERY_F407VG” so I am using that for path.
Full linker command for platformio is:
arm-none-eabi-g++
-o
.pioenvs\disco_f407vg_halmx\firmware.elf
-Wl,-T"ldscript.ld" <---------------
.pioenvs\disco_f407vg_halmx\src\blink.o
-LD:\Users\michael\.platformio\packages\framework-arduinoSTM32GENERIC\STM32\variants\DISCOVERY_F407VG
-L.pioenvs\disco_f407vg_halmx
-Wl,--start-group
.pioenvs\disco_f407vg_halmx\libFrameworkArduinoVariant.a
.pioenvs\disco_f407vg_halmx\libFrameworkArduino.a
-lc
-lgcc
-lm
-lc
.pioenvs\disco_f407vg_halmx\lib\libFreeRTOS.a
-Wl,--end-group
If I change the offending line on the commandline manually from
-Wl,-T"ldscript.ld"
to
-T"ldscript.ld"
Then it links okay. I tried to add -Tldscript.ld into LINKFLAGS but then there is two linker scripts defined and there is an error in linking.
If I compare to what Arduino IDE builds, there is only -T used for linker script file. It does not use -Wl,-T
"D:\Users\michael\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1/bin/arm-none-eabi-gcc" -mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
-mthumb
-Os
-Wl,--cref
-Wl,--check-sections
-Wl,--gc-sections
-Wl,--entry=Reset_Handler
-Wl,--unresolved-symbols=report-all
-Wl,--warn-common
-Wl,--warn-section-align
"-TD:\Users\michael\Documents\Arduino\hardware\STM32GENERIC\STM32\variants\DISCOVERY_F407VG/ldscript.ld" <------------------------------
"-Wl,-Map,D:\Users\michael\AppData\Local\Temp\arduino_build_498965/BlinkLeds.ino.map"
-o
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965/BlinkLeds.ino.elf"
"-LD:\Users\michael\AppData\Local\Temp\arduino_build_498965"
-Wl,--start-group
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\sketch\BlinkLeds.ino.cpp.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\Arduino_FreeRTOS.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\croutine.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\event_groups.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\heap_3.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\list.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\port_CM0.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\port_CM3.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\port_CM4F.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\port_CM7.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\queue.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\tasks.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\libraries\FreeRTOS\timers.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\core\systemclock_config.c.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965\core\variant.cpp.o"
"D:\Users\michael\AppData\Local\Temp\arduino_build_498965/core\core.a"
-lc
-Wl,--end-group
-lm
-lgcc
--specs=nano.specs
So how can I tell to linker that remove -Wl, from the from so that option becomes -Tldscript.ld and not -Wl,-Tldscript.ld
-Tldscript.ld → works
-Wl,-Tldscript.ld → does NOT work
P.S. Platformio is awesome tool !
EDIT: Looks like -Wl,-T is added in platformio.py
#append specified LD_SCRIPT
if ("LDSCRIPT_PATH" in env and
not any(["-Wl,-T" in f for f in env['LINKFLAGS']])):
env.Append(LINKFLAGS=['-Wl,-T"$LDSCRIPT_PATH"'])
In my case this becomes a problem. Is there a way to remove LDSCRIPT_PATH from env ?
Thanks,
Michael