New problem with upload to 4809 using pyupdi


The last time I did a code upload to my 4809 was a few weeks ago. I came back to it today having fixed a bug and now get the error below when trying to upload. Any help much appreciated:

Processing ATmega4809 (board: ATmega4809; platform: atmelmegaavr; framework: arduino)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
PLATFORM: Atmel megaAVR (1.4.0) > ATmega4809   
 - framework-arduino-megaavr-megacorex 1.0.9   
 - tool-avrdude-megaavr 2.60300.210128 (6.3.0) 
 - toolchain-atmelavr 2.70300.201015 (7.3.0)   
LDF: Library Dependency Finder ->
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 12 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SoftwareReset> 3.0.0
|-- <SPI> 1.0
Building in release mode
Checking size .pio\build\ATmega4809\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   9.8% (used 602 bytes from 6144 bytes)
Flash: [==        ]  23.8% (used 11689 bytes from 49152 bytes)
Configuring upload protocol...
CURRENT: upload_protocol = custom
Uploading .pio\build\ATmega4809\firmware.hex
'pyupdi' is not recognized as an internal or external command,
operable program or batch file.
*** [upload] Error 1
====================================================================================== [FAILED] Took 1.09 seconds ===

my PIO.ini is unchanged and is below

; PlatformIO Project Configuration File
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
; Please visit documentation for the other options and examples

board = ATmega4809
platform = atmelmegaavr
framework = arduino
board_build.variant = 40pin-standard
board_build.f_cpu = 20000000L
monitor_flags = 
upload_protocol = custom
upload_speed = 115200
upload_port = COM6
upload_flags = 
upload_command = pyupdi $UPLOAD_FLAGS -f $SOURCE
monitor_port = COM6
monitor_speed = 19200
lib_deps = qub1750ul/SoftwareReset@^3.0.0

description = The integrated Azimuth Encoder

Is pyupdi either installed globally (check with Windows + R → cmd.exepyupdi --help) or installed in PlatformIO’s python environment (check with CLIpio system info<python executable path> -m pip list)?

this is what windows says:


sorry couldn’t work out anything from pio cli, how do I find the python executable path? I seemt o have python 2 and python 3.9

thanks for help.

In the output

>pio system info
--------------------------  --------------------------------------------------------------------------
PlatformIO Core             5.3.0a3
Python                      3.8.6-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp65001
PlatformIO Core Directory   C:\Users\Max\.platformio
PlatformIO Core Executable  C:\Users\Max\AppData\Local\Programs\Python\Python38\Scripts\platformio.exe
Python Executable           c:\users\max\appdata\local\programs\python\python38\python.exe
Global Libraries            0
Development Platforms       62
Tools & Toolchains          214
--------------------------  --------------------------------------------------------------------------

“Python Executable”

In my case to install it I would execute in a commandline / CLI

c:\users\max\appdata\local\programs\python\python38\python.exe -m pip install

thanks, all I get if I try in a cli is this:

PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-code-blinkled> pio system info
pio : The term 'pio' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct 
and try again.
At line:1 char:1
+ pio system info
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pio:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-code-blinkled> 


Are you sure you’re using the PlatformIO CLI as in PlatformIO IDE for VSCode — PlatformIO latest documentation? It should always have PIO commands available.

To make PIO accessible globally (which is always very usefull), you can also follow Redirecting....

ah, right I was using terminal from the vscode menu.

so if I now use the pio CLI, I get this:

PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-code-blinkled> pio system info C:\Users\Paul\.platformio\penv\Scripts\ -m pip list
Usage: pio system info [OPTIONS]
Try 'pio system info -h' for help.

Error: No such option: -m
PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-code-blinkled> 

No that’s not a valid command. First pio system info, then use that Python executable path and append -m pip install to install pyupdi in PlatformIO’s environment.

thanks it has installed successfully and I have just uploaded some code to my avr4809 using it. Great, I have no idea how it disappeared in the first place.

Whilst it wasn’t working, I tried uploading code using pymcuprog from the command line like this:

pymcuprog write -d atmega4809 -t uart -u COM6 -c 250k -f .pio\build\ATmega4809\firmware.hex

which seemed to work, but probably didn’t as my blinkled sketch didn’t blink ( it now does when uploaded by pyupdi)

I won’t go into all the detail, but it looked from the info provided at the CLI that pymcuprog uploads were successful, but my projects just didn’t work and that’s why I’ve tried to upload the blinkled sketch. Using pymcuprog that didn’t work either. So something strange going on.

i have just uploaded my projects now that pyupdi is working again and both projects work as expected.

So I am a bit concerned that pymcuprog went through all the upload process and completed successfully,(apparently), but whatever happened it didn’t upload either a) any code (even though it completed successfully) or b) the expected code (the avr has a custom led on pin 12 which blinks 5 times in the setup() routine.) and that didn’t blink.

Obviously its a concern as I like to rely on the fact that if a system says it’s done something, it has actually done it. Not sure where it’s gone wrong.