PlatformIO Community

Uploading Marlin 2.x to Mega2560 not working

When I compile a simple program, it uploads to mega2560 without problems;
When I compile Marlin 2.1, the build goes perfectly - uploading fails:

Linking .pio\build\mega2560\firmware.elf
Checking size .pio\build\mega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [===== ] 54.0% (used 4425 bytes from 8192 bytes)
Flash: [==== ] 43.5% (used 110404 bytes from 253952 bytes)
Building .pio\build\mega2560\firmware.hex
Configuring upload protocol…
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port…
*** [upload] AssertionError :
Traceback (most recent call last):
result = self.execfunction(target=target, source=rsources, env=env)
File “C:\Users\lucka.platformio\platforms\atmelavr\builder\main.py”, line 54, in BeforeUpload
env.AutodetectUploadPort()
File “C:\Users\lucka.platformio\packages\tool-scons\scons-local-4.3.0\SCons\Util.py”, line 742, in call
return self.method(*nargs, **kwargs)
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\builder\tools\pioupload.py”, line 115, in AutodetectUploadPort
UPLOAD_PORT=find_serial_port(
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 104, in find_serial_port
port = find_known_uart_port(ensure_ready, timeout, verbose)
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 204, in find_known_uart_port
for board_config in p.get_boards().values():
File “C:\Users\lucka.platformio\platforms\atmelsam\platform.py”, line 109, in get_boards
result[key] = self._add_default_debug_tools(result[key])
File “C:\Users\lucka.platformio\platforms\atmelsam\platform.py”, line 152, in _add_default_debug_tools
assert openocd_chipname
AssertionError

I’ve tried different Mega2560 boards - same result.

How in the world does it suddlenly jump into the atmelsam platform from a atmelavr chip o_O. Can you open a CLI and do pio upgrade --dev and retry uploading?

Thanks for the fast reply !
Did the upgrade:

pio --version
PlatformIO Core, version 6.1.4a2

Same result - also added beginning of compile:

C:\Users\lucka.platformio\penv\Scripts\platformio.exe run --target upload
Processing mega2560 (board: megaatmega2560; platform: atmelavr@~3.4; framework: arduino)
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Atmel AVR (3.4.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)
PACKAGES:

  • framework-arduino-avr @ 5.1.0
  • tool-avrdude @ 1.60300.200527 (6.3.0)
  • toolchain-atmelavr @ 1.70300.191015 (7.3.0)
    Converting Marlin.ino
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 6 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- U8glib-HAL @ 0.5.2
    | |-- Wire @ 1.0
    | |-- SPI @ 1.0
    |-- SPI @ 1.0
    |-- Wire @ 1.0
    Building in release mode

Linking .pio\build\mega2560\firmware.elf
Checking size .pio\build\mega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [===== ] 54.0% (used 4425 bytes from 8192 bytes)
Flash: [==== ] 43.5% (used 110404 bytes from 253952 bytes)
Building .pio\build\mega2560\firmware.hex
Configuring upload protocol…
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port…
*** [upload] AssertionError :
Traceback (most recent call last):
File “C:\Users\lucka.platformio\packages\tool-scons\scons-local-4.3.0\SCons\Action.py”, line 1279, in execute
result = self.execfunction(target=target, source=rsources, env=env)
File “C:\Users\lucka.platformio\platforms\atmelavr\builder\main.py”, line 54, in BeforeUpload
env.AutodetectUploadPort()
File “C:\Users\lucka.platformio\packages\tool-scons\scons-local-4.3.0\SCons\Util.py”, line 742, in call
return self.method(*nargs, **kwargs)
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\builder\tools\pioupload.py”, line 115, in AutodetectUploadPort
UPLOAD_PORT=find_serial_port(
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 104, in find_serial_port
port = find_known_uart_port(ensure_ready, timeout, verbose)
File “C:\Users\lucka.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 204, in find_known_uart_port
for board_config in p.get_boards().values():
File “C:\Users\lucka.platformio\platforms\atmelsam\platform.py”, line 109, in get_boards
result[key] = self._add_default_debug_tools(result[key])
File “C:\Users\lucka.platformio\platforms\atmelsam\platform.py”, line 152, in _add_default_debug_tools
assert openocd_chipname
AssertionError

Could it be that something is wrong with my Boards List ?
Is there a way to remove and reinstall the boards list ?
(Board Explorer seems not to load)

Can you please remove all folders in C:\Users\lucka\.platformio\platforms and the C:\Users\lucka\.platformio\.cache folder and press the upload button again?

Super ! Thanks !
Removing the folder in .platformio\platforms did the trick !