platformio / platform-espressif8266

Espressif 8266: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/espressif8266
Apache License 2.0
320 stars 218 forks source link

Error: pio run -t nobuild -t upload #286

Open Bighoneypot opened 1 year ago

Bighoneypot commented 1 year ago

What kind of issue is this?

You can erase any parts of this template not applicable to your Issue.


Configuration

Windows 10 PRO 22H2 build 19045.2251 :

PlatformIO Version (6.1.5):

Description of problem

In my case is impossible command pio run -t nobuild -t upload image

Error: Could not find LD Script

Daiki51 commented 1 year ago

I am also encountering the same error. I would like to add that the same thing happens when the host/remote is Ubuntu 22.

mcspr commented 1 year ago

Also looks like https://github.com/platformio/platform-espressif32/issues/861

We try to call env.GetActualLDScript() to retrieve our flash size info https://github.com/platformio/platformio-core/blob/48655ad728c25c6af67da913c36651e27fdd05ad/platformio/builder/tools/piomisc.py#L42-L84

Which is broken in nobuild case, since there is no env.BuildProgram() and LINKFLAGS is empty. As a workaround, one could do the same thing as suggested in the esp32 issue - populate it manually with the -Wl,-T...ld entry from the currently used board .json https://github.com/platformio/platform-espressif8266/blob/46d25a4f41791cce1b9269da99b7e71e05aa6ba4/builder/main.py#L86 https://github.com/platformio/platform-espressif8266/blob/46d25a4f41791cce1b9269da99b7e71e05aa6ba4/builder/main.py#L93 https://github.com/platformio/platform-espressif8266/blob/46d25a4f41791cce1b9269da99b7e71e05aa6ba4/builder/main.py#L124

Not really sure if nobuild is implemented correctly, though. Perhaps it should still invoke pre-requisite actions but somehow inhibit the PROGRAM .bin regeneration when scons thinks any of the targets need to be built i.e. somehow tell it that all of our dependencies for .bin are up-to-date

Jason2866 commented 1 year ago

This one worked in my test for pio run -t nobuild -t upload

#
# The script sets the missing "LDSCRIPT_PATH" when using the command `pio run -t nobuild`
# Adopted from https://github.com/platformio/platform-espressif32/issues/861#issuecomment-1241871437
# Possible now to upload the firmware or the filesystem with (when builded already!):
#
# `pio run -t nobuild -t upload` and `pio run -t nobuild -t uploadfs`
#

Import("env")

import os
from SCons.Script import COMMAND_LINE_TARGETS

board_config = env.BoardConfig()
framework_dir = env.PioPlatform().get_package_dir("framework-arduinoespressif8266")
assert os.path.isdir(framework_dir)

if "nobuild" in COMMAND_LINE_TARGETS:
    env.Replace(
        LDSCRIPT_PATH=os.path.join(
            framework_dir,
            "tools",
            "sdk",
            "ld",
            board_config.get("build.arduino.ldscript"),
        )
    )
#    print("Set LDSCRIPT_PATH to: ", os.path.join(framework_dir,"tools","sdk","ld",board_config.get("build.arduino.ldscript")))