PlatformIO Community

"*** [Upload] Assertion Error:"; Compiles Successfully, Can't Upload via USB

IDE Environment: Windows
Development board: AVR mega2560
Development Source Code: Marlin
Framework: Arduino

[platformio]
src_dir = Marlin
boards_dir = buildroot/share/PlatformIO/boards
default_envs = mega2560
include_dir = Marlin

This setup with PlatformIOI IDE previously worked until recently. Something has changed, but I don’t know what or why. I’m unable to Upload firmware to the development board via USB. Source code compiles successfully but fails to upload.

Terminal Output Errors:

Archiving .pio\build\mega2560\libFrameworkArduino.a
Indexing .pio\build\mega2560\libFrameworkArduino.a
Linking .pio\build\mega2560\firmware.elf
Checking size .pio\build\mega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [====== ] 62.5% (used 5120 bytes from 8192 bytes)
Flash: [====== ] 65.0% (used 165054 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\Dell Customer.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Action.py”, line 1318, in execute
result = self.execfunction(target=target, source=rsources, env=env)
File “C:\Users\Dell Customer.platformio\platforms\atmelavr\builder\main.py”, line 54, in BeforeUpload
env.AutodetectUploadPort()
File “C:\Users\Dell Customer.platformio\packages\tool-scons\scons-local-4.4.0\SCons\Util.py”, line 737, in call
return self.method(*nargs, **kwargs)
File “C:\Users\Dell Customer.platformio\penv\lib\site-packages\platformio\builder\tools\pioupload.py”, line 113, in AutodetectUploadPort
UPLOAD_PORT=SerialPortFinder(
File “C:\Users\Dell Customer.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 144, in find
device = self._find_known_device()
File “C:\Users\Dell Customer.platformio\penv\lib\site-packages\platformio\device\finder.py”, line 221, in _find_known_device
for board_config in p.get_boards().values():
File “C:\Users\Dell Customer.platformio\platforms\atmelsam\platform.py”, line 105, in get_boards
result[key] = self._add_default_debug_tools(result[key])
File “C:\Users\Dell Customer.platformio\platforms\atmelsam\platform.py”, line 148, in _add_default_debug_tools
assert openocd_chipname
AssertionError
============================== [FAILED] Took 104.33 seconds ==============================
Environment Status Duration


mega2560 FAILED 00:01:44.333
========================= 1 failed, 0 succeeded in 00:01:44.333 =========================

  • The terminal process “C:\Users\Dell Customer.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

What I have tried:

  • Updated Windows USB Device Driver, no change.
  • Tried rolling VS Code back to Version: 1.70.2 and reinstalling PlatformIO, no change.

What I used PlatformIO for prior to Arduino upload problem:
I loaded maxgerhardt’s github repository “T-962-improvements” which is for platform NXPlpc ( lpc2134 microcontroller ), with platformIO.ini includes these settings:

[upload_settings]
; value will be read by python script. analogous to Makefile
FLASH_BAUD = 57600
MCU_CLOCK = 11059
[env:lpc2134_01]
platform = nxplpc
; use custom board definition for NXP LPC 2134/01
board = lpc2134_01
; use same linkerscript as Makefile uses
board_build.ldscript = T-962-controller.ld
; remove default thumb mode flag
build_unflags = -mthumb
; reproduce build flags from Makefile
build_flags = -DNDEBUG -D__NEWLIB__ -fno-builtin -fmessage-length=0 -flto -ffat-lto-objects -Wl,-u_printf_float -Wl,-u_scanf_float
; add -nostdlib to linkerflags via script; cannot be done via build_flags in this case
; see Redirecting...
; also creates additional HEX file (otherwise only .elf and .bin are there, but uploader needs .hex)
; reproduce creation of version.c file, as Makefile does (could also work without, but why not…)
extra_scripts =
fix_linkflags.py
pre:create_version.py
custom_upload.py
; upload via custom lpc21isp program.
; precompiled binaries for Windows and Linux exist in this directory. Assume Windows by default
upload_protocol = custom
;if explicit upload port is needed (will be auto-detected otherwise)
;upload_port = COM1

Not sure what to try next. Any help appreciated.

I’ve seen this stacktrace pop up multime times, weird. Not sure why its trying to load all platform boards when just uploading, and it then failing…

Since you don’t need atmelsam for now, you can just delete the folder C:\Users\Dell Customer.platformio\platforms\atmelsam and retry uploading.

You can also make sure if updating PlatformIO core makes a difference. In the CLI, do pio upgrade --dev.

Thanks for the help. Your first suggestion worked, but I didn’t try your second suggestion of using the PlatformIO Core CLI to upgrade the Core with…

pio upgrade -dev

because I read in the CLI Guide for the command…

pio upgrade

that the -dev option, uses the development branch and from the documentation, it is not clear to me what the default branch is. Is that the master branch on github?

Since I just rolled back VS Code to previous version 1.70.2, I had to reinstall the platformIO extension. I assume I have the latest extension version installed.

Here’s how I got around my upload problem. I moved file folder

C:\Users\Dell Customer.platformio\platforms\atmelsam

into a new folder…

C:\Users\Dell Customer.platformio\platforms\atmelsamFolderBackup

Then restarted VS Code. Clicked on the Upload command. The monitor output produced these messages

Archiving .pio\build\mega2560\libFrameworkArduino.a
Indexing .pio\build\mega2560\libFrameworkArduino.a
Linking .pio\build\mega2560\firmware.elf
Checking size .pio\build\mega2560\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [====== ] 62.5% (used 5120 bytes from 8192 bytes)
Flash: [====== ] 65.0% (used 165054 bytes from 253952 bytes)
Building .pio\build\mega2560\firmware.hex
Configuring upload protocol…
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port…
Auto-detected: COM4
Uploading .pio\build\mega2560\firmware.hex

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9801 (probably m2560)
avrdude: reading input file “.pio\build\mega2560\firmware.hex”
avrdude: writing flash (165054 bytes):

Writing | ################################################## | 100% 24.57s

avrdude: 165054 bytes of flash written
avrdude: verifying flash memory against .pio\build\mega2560\firmware.hex:
avrdude: load data flash data from input file .pio\build\mega2560\firmware.hex:
avrdude: input file .pio\build\mega2560\firmware.hex contains 165054 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 18.84s

avrdude: verifying …
avrdude: 165054 bytes of flash verified

avrdude: safemode: Fuses OK (E:FD, H:D8, L:FF)

avrdude done. Thank you.

============================= [SUCCESS] Took 155.38 seconds =============================

Environment Status Duration


mega2560 SUCCESS 00:02:35.376
============================== 1 succeeded in 00:02:35.376 ==============================

  • Terminal will be reused by tasks, press any key to close it.

I still have some strange terminal monitor output when VS Code launches. The PowerShell seems to launch three times and History Restored appears twice. Not sure what History Restored means or how to fix or disable it. Here’s what the ouput shows…

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell

PS C:\Users\Dell Customer\Documents\Arduino\Marlin-2.0.7.2 V1V2 Printers\Marlin-2.0.7.2>

  • History restored

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell

PS C:\Users\Dell Customer\Documents\Arduino\Marlin-2.0.7.2 V1V2 Printers\Marlin-2.0.7.2>

  • History restored

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell

PS C:\Users\Dell Customer\Documents\Arduino\Marlin-2.0.7.2 V1V2 Printers\Marlin-2.0.7.2>

Your help is much appreciated.

Here’s a screenshot of my platforms folder before moving folder atmelsam to a newly created backup folder…

PlatformIO Upload Prob1

I don’t know why there are so many nxp platform folders? I remember Arduino Zero has SAMD21 processor, so those might be for that, but I did not think they were lpc176x.

Should I delete those nxplpc-arduino variety folders too?