platformio / platform-atmelavr

Atmel AVR: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/atmelavr
Apache License 2.0
136 stars 104 forks source link

Simavr load failing on ATmega2560 #270

Open Con30 opened 2 years ago

Con30 commented 2 years ago

When trying to run simavr the debugger fails stating load failed and no error.

My launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug",
            "executable": "C:/Users/rconnor/OneDrive - COMP AQUATIC LIFE LTD/Documents/Firmware/.pio/build/ATmega2560/firmware.elf",
            "projectEnvName": "ATmega2560",
            "toolchainBinDir": "C:/Users/rconnor/.platformio/packages/toolchain-atmelavr/bin",
            "internalConsoleOptions": "openOnSessionStart",
            "preLaunchTask": {
                "type": "PlatformIO",
                "task": "Pre-Debug"
            }
        },
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug (skip Pre-Debug)",
            "executable": "C:/Users/rconnor/OneDrive - COMP AQUATIC LIFE LTD/Documents/Firmware/.pio/build/ATmega2560/firmware.elf",
            "projectEnvName": "ATmega2560",
            "toolchainBinDir": "C:/Users/rconnor/.platformio/packages/toolchain-atmelavr/bin",
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "type": "platformio-debug",
            "request": "launch",
            "name": "PIO Debug (without uploading)",
            "executable": "C:/Users/rconnor/OneDrive - COMP AQUATIC LIFE LTD/Documents/Firmware/.pio/build/ATmega2560/firmware.elf",
            "projectEnvName": "ATmega2560",
            "toolchainBinDir": "C:/Users/rconnor/.platformio/packages/toolchain-atmelavr/bin",
            "internalConsoleOptions": "openOnSessionStart",
            "loadMode": "manual"
        }
    ]
}

platform.ini:

[env:ATmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
lib_ldf_mode = deep+
lib_deps = arduino-libraries/SD
check_skip_packages = true
check_tool = cppcheck, clangtidy
extra_scripts = post:scripts/copy_hex.py
monitor_speed = 19200
debug_tool = simavr
debug_init_break = tbreak setup
monitor_filters = time, colorize

Debug Console:

image

The strange thing is that it works fine running simavr from power shell but for some reason platformio just doesn’t want to run it.

hypov8 commented 2 years ago

i been having the same issue on an sanguino_atmega1284p. if i look in windows task manager. its missing the .elf file added to the run command is yours missing it to?

if i look in atmelavr\platform.py it seems to be missing the .elf agument?

debug["tools"]["simavr"] = {
    "port": ":1234",
    "server": {
        "package": "tool-simavr",
        "arguments": [
            "-g",
            "-m", debug["simavr_target"],
            "-f", build.get("f_cpu", "")
        ],
        "executable": "bin/simavr"
    },
} 

to make mine run i add this to plantform.ini (it still fails at random, like it times out with a full rebuild)

[env:melzi_debug]
build_type = debug
debug_tool = simavr
debug_server =
    ${platformio.packages_dir}/tool-simavr/bin/simavr.exe
    -m
    atmega1284p
    -f
    16000000L
    -g
    1234
    ${platformio.build_dir}\melzi_debug\firmware.elf

still trying to figure out how the console works for simavr