Closed zserge closed 8 years ago
You can specify full path in board's definition ("ldscript": "/full/path/to/script.ld"
,). Have you tried it?
Hmm... I guess I could, but it's kinda not portable, if other developers have fetched the same sources to a different path that will break the build. Can it be relative instead? Or can I use variable interpolation in that path string? On Jan 26, 2016 5:48 PM, "Ivan Kravets" notifications@github.com wrote:
You can specify full path in board's definition ("ldscript": "/full/path/to/script.ld",). Have you tried it?
— Reply to this email directly or view it on GitHub https://github.com/platformio/platformio/issues/474#issuecomment-174932204 .
ld
looks for scripts in LIBPATH
. You can dump PlatformIO build environment using platformio run -t envdump
and find LIBPATH
. As you can see, ~/.platformio/packages/ldscripts
is added to this list. See https://github.com/platformio/platformio/blob/develop/platformio/builder/main.py#L99
To make portable project you need to take a look at extra_script. You can prepend here "current project directory" to LIBPATH
and keep your specific LDScript in the root of the project.
Also, don't forget that you can change build environment on-the-fly using extra_script
, including pre-defined board settings. See BOARD_OPTIONS
environment variable.
Ok, extra_script can become a solution, but it looks like my extra script is evaluated after libopencm3.py fails at find_ldscript(path).. So I get a crash before I'm able to "patch" my environment.
On Tue, Jan 26, 2016 at 6:37 PM, Ivan Kravets notifications@github.com wrote:
Also, don't forget that you can change build environment on-the-fly using extra_script, including pre-defined board settings. See BOARD_OPTIONS environment variable.
— Reply to this email directly or view it on GitHub https://github.com/platformio/platformio/issues/474#issuecomment-174949886 .
"One must have a chaos inside oneself to give birth to a dancing star." - Thus Spoke Zarathustra
@valeros please remove assertion https://github.com/platformio/platformio/blob/develop/platformio/builder/scripts/frameworks/libopencm3.py#L59 and allow to specify own LD Script using extra_script
.
Ok, just removing assert doesn't help it - the same exception appears later, in merge_ld_scripts
.
But a solution to my problem seems to be as simple as build_flags = -Wl,-T${PROJECTSRC_DIR}/stm32f401.ld
in platformio.ini. Do you see any potential pitfalls with this?
Also, since now my custom build flag works, I wonder how can I trick the platformio to ignore the ldscript specified in board JSON configuration? Currently I specify a "common" linker script or any other ld script that exists in opencm3 sources, but it seems really ugly. Also, I can't just ignore the ldscript because JSON parser checks for this field.
build_flags = -Wl,-T${PROJECTSRC_DIR}/stm32f401.ld
This is GOOD approach. It should work in any case. @valeros will fix libopencm3
framework.
Also, since now my custom build flag works, I wonder how can I trick the platformio to ignore the ldscript specified in board JSON configuration? Currently I specify a "common" linker script or any other ld script that exists in opencm3 sources, but it seems really ugly. Also, I can't just ignore the ldscript because JSON parser checks for this field.
I've changed this issue to bug
, we will fix all these things.
P.S: Have you tried Ukrainian PlatformIO IDE? :)
Круто, дякую! Доречі, такий сценарій як в мене мабуть буде дуже типовий, бо мало хто в продакшені використовує всякі ардуїни, здебільшого кастомні чіпи з малою пам’яттю, бо ціна і всяке таке. То може б детальніше в доках розписати що до чого...
With regards to the IDE - I'm a religious vim user, but Atom seems to be on the rise these days, so I'll definitely give it a try and spread the word about it in my team!
Hi @zserge! Please try development version with build_flags = -Wl,-T${PROJECTSRC_DIR}/stm32f401.ld
Yes, I confirm that this works. Thanks for such a quick fix!
@zserge
I'm a religious vim user,
I'm too :blush: I have opened issue to make project generator for VIM which will generate configs for YouCompleteMe, syntastic and etc. https://github.com/platformio/platformio/issues/467
I'll definitely give it a try and spread the word about it in my team!
Thanks a lot! :)
I'm trying to use platformio with custom boards (specifically, stm32f401rb).
I've created a JSON file describing my board like this:
I use libopencm3 framework, it contains a "common" stm32f4 linker script which is supposed to be included like this (this is my
stm32f401.ld
from the config above):So the question is - where should I put my custom ldscript for my custom board? I would prefer it to be next to my sources, in my project directory.
Currently the only working location was
~/.platformio/packages/frameworks/libopencm3/lib/stm32/f4/
. Neither project root, norsrc
directory worked and printed the following error:And in fact during the first build my linker script in opencm3 source tree has been expanded and my include statement has been replaced by full contents of the
libopencm32_stm32f4.ld
.