Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pymcuprog reports upload success but is not uploading code #27

Open
paulskirk53 opened this issue Jul 4, 2022 · 10 comments
Open

pymcuprog reports upload success but is not uploading code #27

paulskirk53 opened this issue Jul 4, 2022 · 10 comments

Comments

@paulskirk53
Copy link

Hi, Apologies for a long post but the background is important.
I use a pair of AVR 4809 (40 pin variants) in a project. I use FTDI boards to facilitate code uploads and serial comms between a windows PC running my code and the AVRs. I use the Platformio IDE. When I started with the 4809s it was my first experience of UPDI and I found pyupdi, which in those days was not deprecated. It worked fine as installed in my platformio IDE. I subsequently started using pymcuprog when pyupdi became deprecated, but as it is much slower to upload code than pyupdi, I reverted to pyupdi.
So the problem is that (for a reason I am exploring with the Platformio folks), pyupdi periodically disappears from my IDE. When this happens, I use pymcuprog as follows:

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

and it reports success when uploading code.
However, I don't think the code uploads. A simple blinkled prog. used as a trial does not blink the LED. Naturally to start with I thought it was me, but today I managed to reinstall pyupdi and used that to upload the same blinkled code. It worked, so just out of curiosity, I used pymcuprog to upload the code and that seemed to work too as reported below:

PS C:\Users\Paul\Documents\PlatformIO\Projects\Arduino-code-blinkled> pymcuprog write -d atmega4809 -t uart -u COM3 -c 250k -f .pio\build\ATmega4809\firmware.hex
Pinging device...
Ping response: 1E9651
Writing from hex file...
Writing flash...
Done.

But it doesn't.

So I think all the above can be summarised as follows:
If I use pyupdi to upload code, that works.
If I use pymcuprog, it doesn't work.

It's probably a setting I have missed. Thanks for any thoughts.

@xedbg
Copy link
Contributor

xedbg commented Jul 4, 2022

Hi @paulskirk53 - pymcuprog allows for programming several segments in several sessions, and thus does not erase the device before programming.
Before release 3.13 the solution from platformio was to chain erase and program: pymcuprog erase && pymcuprog write
In 3.13 the --erase switch was added which means it can be done in one operation using pymcuprog write --erase
And if you are in doubt, use the --verify switch to check by read-back after programming.
(The --erase is not done by default - we have too many [internal] use-cases which will need to be addressed if we change this behaviour)

@paulskirk53
Copy link
Author

Ah, brill, thanks for the explanation.

@paulskirk53
Copy link
Author

Hi, I have just come back to this using the Platformio CLI, and using this command
pymcuprog write -d atmega4809 -t uart -u COM5 -c 250k -f .pio\build\ATmega4809\firmware.hex --erase
I get the error:
pymcuprog: error: unrecognized arguments: --erase

any help much appreciated.

@xedbg
Copy link
Contributor

xedbg commented Sep 22, 2022

@paulskirk53 - please verify which version of pymcuprog you are running since this --erase switch was added not long ago.
pymcuprog --version

@paulskirk53
Copy link
Author

it is 3.13.3.166
I did
pip install pymcuprog

earlier today. It did work with the --erase option after I posted in July.
thanks for help.

@mraardvark
Copy link

That version was released in May... Are you sure there is not an older version in a venv inside platformio?

@paulskirk53
Copy link
Author

sorry I wouldn't know how to check, is there a command I can use to check for a virtual env.? Perhaps I should post about that on the PIO forum?

@mraardvark
Copy link

I guess easiest would be to replace the programming flash write call in your .ini file with pymcuprog --version and check the output from that...

@paulskirk53
Copy link
Author

i was never able to get pymcuprog working via the platformio.ini file, so I use it from the CLI. So I removed --erase and used this:
pymcuprog write -d atmega4809 -t uart -u COM5 -c 250k -f .pio\build\ATmega4809\firmware.hex --version

and it reports pymcuprog version 3.13.3.166

hope that helps.

@paulskirk53
Copy link
Author

works fine this morning, no probs uploading with --erase. Only difference is the machine was restarted this morning. Version number is the same. Thanks for help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants