PlatformIO Community

Error: Could not find LD script and then more issues

Hi,
So i’ve got a PIO remote environment working fine for Arduino with an ATMega328PB.
Can upload via USBASP and view the serial port output, all good.

Now, when I try the most basic code

#include <Arduino.h>
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello");
}

[env:d1_mini_pro]
platform = espressif8266
board = d1_mini_pro
framework = arduino
upload_port=/dev/ttyUSB0

for an Arduino/WEMOS D1 mini pro, I run into two different issues (it compiles and uploads locally fine).
1st issue i get is a “Could not find LD script”

> Executing task in folder d1_mini_test: platformio remote run --target upload <

PIO Plus (https://pioplus.com) v2.5.2
Building project locally
Processing d1_mini_pro (platform: espressif8266; board: d1_mini_pro; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_pro.html
PLATFORM: Espressif 8266 2.2.2 > WeMos D1 mini Pro
HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
PACKAGES: toolchain-xtensa 2.40802.190218 (4.8.2), tool-esptool 1.413.0 (4.13), tool-esptoolpy 1.20600.0 (2.6.0), framework-arduinoespressif8266 2.20502.0 (2.5.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 45 compatible libraries
Scanning dependencies...
No dependencies
Compiling .pio/build/d1_mini_pro/src/main.cpp.o
Generating LD script .pio/build/d1_mini_pro/ld/local.eagle.app.v6.common.ld
Archiving .pio/build/d1_mini_pro/libFrameworkArduinoVariant.a
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Esp-frag.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Esp-version.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Esp.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/FS.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/FunctionalInterrupt.cpp.o
Indexing .pio/build/d1_mini_pro/libFrameworkArduinoVariant.a
Compiling .pio/build/d1_mini_pro/FrameworkArduino/HardwareSerial.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/IPAddress.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/MD5Builder.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Print.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Schedule.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/ScheduledFunctions.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/StackThunk.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Stream.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/StreamString.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Tone.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/Updater.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/WMath.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/WString.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/abi.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/base64.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/cbuf.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/cont.S.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/cont_util.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_app_entry_noextra4k.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_eboot_command.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_flash_utils.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_i2s.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_main.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_noniso.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_phy.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_postmortem.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_si2c.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_sigma_delta.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_timer.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_waveform.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring_analog.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring_digital.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring_pulse.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring_pwm.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/core_esp8266_wiring_shift.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/debug.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/gdb_hooks.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/heap.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/libb64/cdecode.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/libb64/cencode.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/libc_replacements.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/sntp-lwip2.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs/spiffs_cache.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs/spiffs_check.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs/spiffs_gc.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs/spiffs_hydrogen.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs/spiffs_nucleus.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs_api.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/spiffs_hal.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/sqrt32.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/time.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/uart.cpp.o
Compiling .pio/build/d1_mini_pro/FrameworkArduino/umm_malloc/umm_malloc.cpp.o
Archiving .pio/build/d1_mini_pro/libFrameworkArduino.a
Indexing .pio/build/d1_mini_pro/libFrameworkArduino.a
Linking .pio/build/d1_mini_pro/firmware.elf
Building .pio/build/d1_mini_pro/firmware.bin
Retrieving maximum program size .pio/build/d1_mini_pro/firmware.elf
Checking size .pio/build/d1_mini_pro/firmware.elf
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [===       ]  32.5% (used 26660 bytes from 81920 bytes)
PROGRAM: [===       ]  25.1% (used 262276 bytes from 1044464 bytes)
Creating BIN file ".pio/build/d1_mini_pro/firmware.bin" using ".pio/build/d1_mini_pro/firmware.elf"
====================================================================== [SUCCESS] Took 8.33 seconds ======================================================================
Uploading firmware remotely
Processing d1_mini_pro (platform: espressif8266; board: d1_mini_pro; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Error: Could not find LD script
=================================================== [ERROR] Took 10.64 seconds ===================================================

So in my extensive googling this should be fixed by a --force-remote, but that leads to my second issue

[lakidd:...ormIO/Projects/d1_mini_test]$ pio remote run -t upload -v --force-remote
PIO Plus (https://pioplus.com) v2.5.2
Processing d1_mini_pro (platform: espressif8266; board: d1_mini_pro; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/d1_mini_pro.html
PLATFORM: Espressif 8266 2.2.2 > WeMos D1 mini Pro
HARDWARE: ESP8266 80MHz, 80KB RAM, 16MB Flash
PACKAGES: toolchain-xtensa 2.40802.190218 (4.8.2), tool-esptool 1.413.0 (4.13), tool-mkspiffs 1.200.0 (2.0), tool-esptoolpy 1.20600.0 (2.6.0), framework-arduinoespressif8266 2.20502.0 (2.5.2)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 28 compatible libraries
Scanning dependencies...
No dependencies
xtensa-lx106-elf-gcc -o .pio/build/d1_mini_pro/firmware.elf -T eagle.flash.16m14m.ld -Os -nostdlib -Wl,--no-check-sections -Wl,-static -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,spi_flash_read -u app_entry -u _printf_float -u _scanf_float -u _DebugExceptionVector -u _DoubleExceptionVector -u _KernelExceptionVector -u _NMIExceptionVector -u _UserExceptionVector -L.pio/build/d1_mini_pro -L.pio/build/d1_mini_pro/ld -L/home/lakidd/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lib -L/home/lakidd/.platformio/packages/framework-arduinoespressif8266/tools/sdk/ld -L/home/lakidd/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/lib -L/home/lakidd/.platformio/packages/framework-arduinoespressif8266/tools/sdk/lib/NONOSDK221 -Wl,--start-group .pio/build/d1_mini_pro/libFrameworkArduinoVariant.a .pio/build/d1_mini_pro/libFrameworkArduino.a -lhal -lphy -lpp -lnet80211 -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc -llwip2-536-feat -Wl,--end-group
/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
=================================================== [ERROR] Took 49.11 seconds ===================================================

Now I can find plenty of references to similar errors out there, but all have seemed to mysteriously fixed themselves with a make clean and/or re-install.
I’ve totally reinstalled PIO on the remote rasbpbi and I’ve added and removed the esp8266 platform on the local box with no joy.
This happened with Core4.0 and the previous version (3.6.7 ?)
Everything is up to date as far as I can see.

[lakidd:...ormIO/Projects/d1_mini_test]$ pio upgrade                               
You're up-to-date!
PlatformIO 4.0.0 is currently the newest version available.
[lakidd:...ormIO/Projects/d1_mini_test]$ pio update  
Updating tool-scons                      @ 2.20501.7      [Up-to-date]
Updating tool-unity                      @ 1.20403.0      [Up-to-date]
Updating contrib-pysite                  @ 2.27.190418    [Up-to-date]
Updating contrib-piohome                 @ 2.2.0          [Up-to-date]
Updating tool-pioplus                    @ 2.5.2          [Up-to-date]

Platform Manager
================
Platform Atmel AVR
--------
Updating atmelavr                        @ 1.14.0         [Up-to-date]
Updating toolchain-atmelavr              @ 1.50400.190710 [Up-to-date]
Updating framework-arduinoavr            @ 4.0.0          [Up-to-date]
Updating tool-avrdude                    @ 1.60300.190628 [Up-to-date]

Platform Espressif 32
--------
Updating espressif32                     @ 1.9.0          [Up-to-date]
Updating tool-esptoolpy                  @ 1.20600.0      [Up-to-date]
Updating toolchain-xtensa32              @ 2.50200.80     [Up-to-date]
Updating framework-arduinoespressif32    @ 2.10002.190628 [Up-to-date]
Updating framework-espidf                @ 3.30202.190627 [Up-to-date]
Updating tool-mkspiffs                   @ 2.230.0        [Up-to-date]

Platform Espressif 8266
--------
Updating espressif8266                   @ 2.2.2          [Up-to-date]
Updating tool-esptoolpy                  @ 1.20600.0      [Up-to-date]
Updating tool-mkspiffs                   @ 1.200.0        [Up-to-date]
Updating tool-esptool                    @ 1.413.0        [Up-to-date]
Updating framework-arduinoespressif8266  @ 2.20502.0      [Up-to-date]
Updating toolchain-xtensa                @ 2.40802.190218 [Up-to-date]

Platform ST STM32
--------
Updating ststm32                         @ 5.4.3          [Up-to-date]
Updating toolchain-gccarmnoneeabi        @ 1.70201.0      [Up-to-date]


Library Manager
===============
Library Storage: /Users/lakidd/.platformio/lib
Updating AWS-SDK-ESP                     @ 0.9.1-beta     [Up-to-date]
Updating Adafruit BME280 Library         @ 1.0.9          [Up-to-date]
Updating Adafruit BME680 Library         @ 1.0.7          [Up-to-date]
Updating Adafruit GFX Library            @ 1.5.6          [Up-to-date]
Updating Adafruit Unified Sensor         @ 1.0.3          [Up-to-date]
Updating ArduinoJson                     @ 6.11.2         [Up-to-date]
Updating AsyncDelay                      @ 1.1.0          [Up-to-date]
Updating ESP8266_SSD1306                 @ 4.0.0          [Up-to-date]
Updating GxEPD                           @ 3.0.7          [Up-to-date]
Updating Micro-RTSP                      @ 0.1.6          [Up-to-date]
Updating NTPClient                       @ 3.1.0          [Up-to-date]
Updating NeoPixelBus                     @ 2.5.0          [Up-to-date]
Updating OneButton                       @ f78433c209     [Up-to-date]
Updating PubSubClient                    @ 2.7            [Up-to-date]
Updating SendOnlySoftwareSerial          @ 1.0            [Detached]
Updating SoftWire                        @ 2.0.0          [Up-to-date]
Updating TinyWireSio                     @ 722ada4382     [Up-to-date]

[lakidd:...ormIO/Projects/d1_mini_test]$ pio remote update
PIO Plus (https://pioplus.com) v2.5.2
Updating tool-scons                      @ 2.20501.7      [Up-to-date]
Updating contrib-pysite                  @ 2.27.190418    [Up-to-date]
Updating tool-pioplus                    @ 2.5.2          [Up-to-date]

Platform Manager
================
Platform Espressif 8266
--------
Updating espressif8266                   @ 2.2.2          [Up-to-date]
Updating tool-esptoolpy                  @ 1.20600.0      [Up-to-date]
Updating tool-mkspiffs                   @ 1.200.0        [Up-to-date]
Updating tool-esptool                    @ 1.413.0        [Up-to-date]
Updating framework-arduinoespressif8266  @ 2.20502.0      [Up-to-date]
Updating toolchain-xtensa                @ 2.40802.190218 [Up-to-date]


Library Manager
===============
Library Storage: /home/lakidd/.platformio/lib
[lakidd:...ormIO/Projects/d1_mini_test]$ 

Love the product, any ideas or thoughts ?

I’m actually more confused as to why this is needed on the remote… my understanding was that the file was built locally, and then only the binary blob would need to be copied to the remote and then uploaded… hence the LD script should be needed on the remote? So why is it trying to link it there (without specifying --force-remote and making it so it compiles on the remote) in the first place?

The second post in the issue references a possible workaround, but I still don’t quite understand what’s going on there…

Yes, thanks but the --force-remote just leads me to issue number 2…grrrr :slight_smile:

Related issue