Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Could not find LD script when uploading remotely #165

Closed
vrabcak opened this issue Jul 10, 2019 · 8 comments
Closed

Error: Could not find LD script when uploading remotely #165

vrabcak opened this issue Jul 10, 2019 · 8 comments
Labels

Comments

@vrabcak
Copy link

vrabcak commented Jul 10, 2019

I have following setup: Platformio installed on Raspberry Pi and gen4iod board connected to the Raspberry via USB. I run remote agent on the Raspberry.

When I try to upload firmware remotely from my PC, it ends with the error:

================================================================== [SUCCESS] Took 6.25 seconds ==================================================================
Uploading firmware remotely
Processing gen4iod (platform: espressif8266; board: gen4iod; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Error: Could not find LD script
=================================================================== [ERROR] Took 1.79 seconds ===================================================================
The terminal process terminated with exit code: 1

When I compile exactly the same project locally on the Raspberry and upload it locally (with pio run --target upload), it uploads the firmware to the board without any problems.

I'm using PlatformIO, version 4.0.0 and espressif8266 @ 2.2.2

@mcspr
Copy link
Contributor

mcspr commented Jul 11, 2019

I'm seeing the same error when specifying pio run -e env -t nobuild -t upload

After some tracing, I noticed that the error message comes from platformio-core:
https://github.com/platformio/platformio-core/blob/5e73348263ef10458a950a0022dabaec803f46a6/platformio/builder/tools/piomisc.py#L235-L277

But LINKFLAGS is missing. Only place that I've noticed it may come from is target elf generation, but it will only trigger on building:
https://github.com/platformio/platformio-core/blob/5e73348263ef10458a950a0022dabaec803f46a6/platformio/builder/tools/platformio.py#L109

if "nobuild" in COMMAND_LINE_TARGETS:
target_elf = join("$BUILD_DIR", "${PROGNAME}.elf")

Adding the env.ProcessFlags(env.get("BUILD_FLAGS")) fixes the LD script detection.
edit: ...and also this part of BuildProgram, if build_flags is empty / without -Wl,-T ...:
https://github.com/platformio/platformio-core/blob/5e73348263ef10458a950a0022dabaec803f46a6/platformio/builder/tools/platformio.py#L127-L129

if (env.get("LDSCRIPT_PATH")
            and not any("-Wl,-T" in f for f in env['LINKFLAGS'])):
        env.Prepend(LINKFLAGS=["-T", "$LDSCRIPT_PATH"])

But it looks like that the platformio-core must always parse build flags and not the platform code?

@mariusstaicu
Copy link

Same problem using espressif8266@2.2.2 with platformio 3.6.7.
However, quick workaround suggested here https://community.platformio.org/t/esp8266-error-on-remote-uploading/4618 works. Adding --force-remote solves the problem by building on the remote agent.

@liebman
Copy link

liebman commented Jul 17, 2019

The workaround is not working for me with pio v4.0.0.

@lakidd
Copy link

lakidd commented Jul 21, 2019

For me, the workaround leads to

/home/lakidd/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/d1_mini_pro/libFrameworkArduino.a(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x4): undefined reference to `setup'
/home/lakidd/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/d1_mini_pro/libFrameworkArduino.a(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x8): undefined reference to `loop'
/home/lakidd/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pio/build/d1_mini_pro/libFrameworkArduino.a(core_esp8266_main.cpp.o): in function `loop_wrapper()':
core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x21): undefined reference to `setup'
/home/lakidd/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x2d): undefined reference to `loop'
collect2: error: ld returned 1 exit status
*** [.pio/build/d1_mini_pro/firmware.elf] Error 1

[EDIT]
Ok the above seems to be caused by --force-remote putting the *.cpp file into /include on the remote system, not /src . When I manually move it there and build locally on the remote RPi, it works.

@mariusstaicu
Copy link

mariusstaicu commented Jul 30, 2019

for me is not an option to use --force-remote, I need to build on CI server.
Also, downgrading platform to 2.2.1 worked, so the problem seems to have been introduced int the latest espressif8266@2.2.2 release

@ivankravets
Copy link
Member

Please re-run pio remote update or pio update on the remote device. Fixed in https://github.com/platformio/platform-espressif8266/releases/tag/v2.2.3

@lakidd
Copy link

lakidd commented Sep 3, 2019

Yep, that fixed it ! Thanks

@mariusstaicu
Copy link

fixed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants