I am trying to program a Arduino Micro and having a problem that appears to be at least 2-3 years old with no clear resolution. There is really old threads here discussing it but it is unclear if it was ever addressed. I have spent 2-3 hours now messing around, editing pioupload.py, etc.
Is there any update on this problem? Was it fixed?
The specific issue:
When you upload it doesnt wait long enough for the software USB to re-enumerate, then it selects the wrong port. I tried a pioupload edit that looked promising, but it didnt appear to actually work, even though the code looked promising. I would add some links but I am afraid the forum will detect it as spam since I am new!
Configuring upload protocol... AVAILABLE: avr109 CURRENT: upload_protocol = avr109 Looking for upload port... Auto-detected: COM10 Forcing reset using 1200bps open/close on port COM10 Waiting for the new upload port... result: 'COM11' Uploading .pio\build\micro\firmware.hex avrdude: ser_open(): can't open device "\\.\COM11": The system cannot find the file specified.
This also didnt seem to work. The python code was running because I had to update the print statements to python 3 syntax, but the wait loop didnt appear to work.
I am afraid I am wasting time if there is a known solution somewhere.
In the meantime I guess I will try to figure out how to upload hex compiled by platform io in VS code using the arduino IDE⦠Annoying manual workflow step!
From the looks of the responsible for uploading, it really shouldnāt do that⦠it basically gets the list of ports currently present, triggers the bootloader reset, and then connects to serial port not previously present⦠so unless you have multiple boards connected, and reset the wrong one initially, or somehow manage to connect another serial type device between the reset and the rescan, it should be fine. Having said that, Iāll try again with my Micro on Windows again tomorrow if I remember.
btw, I know itās quiet on this forum at times, and it can be frustrating when you have a problem that you donāt seem to be able to solve, but using the search feature would have answered your question pretty quickly as to if anyone has ever used an Arduino Leonardo or Arduino Micro with PlatformIO!
Thank you for the report of having programmed a Micro\Leonardo!
I only have the one micro right now.
I am sure the WaitForNewSerialPort function is running because I can make it stop working with long sleep() commands, which do not help and result in a bunch of errors.
I am afraid I am not sure what you want me to infer from the linked code. My main.py does not have those lines in it. My main.py also seems to be a different file in a different folder. I do not have a /atmelavr/ folder. I do have the atmelavr platform installed though.
This was a fresh install of platform io. I just have blink code in it. I will try it on my mac or another computer. Digging around in the config\code for an IDE add-on that is supposed to just work seems like a poor use of time to me.
Sorry for putting you through that⦠have been offline the last few days.
Right, so just tried an upload with the Micro clone I have on Windows (10) and it worked fine. I see from the verbose log it initially identified COM17 and then COM16 on the reset.
In you case, what is the device itās detecting at port COM11? Or is it the correct serial/COM port, but avrdude isnāt able to actually do the upload for some reason? Do you have anything connected to that serial port like a terminal, or serial monitor?
Code (with an led + resistor attached between GND and 2):
After google searching a bit I am still uncertain how to set the verbose flag for avr_dude output. I find info on the PIO CLI in general, but nothing specific about setting the compiler output to verbose.
Anyway I am continuing to fail at getting this to work. Here is what it does now ( same as in first post).
I have the Arduino Micro detected on (in this case) COM19. My code compiles. It is simply blink.ino.
Based on the same process in Arduino IDE, it doesnt seem to be accepting the COM port once it returns to availability. In the Arduino IDE it takes 5-8 seconds total for the entire program cycle.
When I select upload it does the following. Note the program lights on the Micro blink and it appears to be being programmed, but it does not get programmed.
> Executing task in folder micro-hi: C:\Users\Robert\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing micro (platform: atmelavr; board: micro; framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/micro.html
PLATFORM: Atmel AVR 2.0.0 > Arduino Micro
HARDWARE: ATMEGA32U4 16MHz, 2.50KB RAM, 28KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduino-avr 5.0.0, tool-avrdude 1.60300.190424 (6.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio\build\micro\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 5.8% (used 149 bytes from 2560 bytes)
PROGRAM: [= ] 14.4% (used 4132 bytes from 28672 bytes)
Configuring upload protocol...
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
Looking for upload port...
Auto-detected: COM19
Forcing reset using 1200bps open/close on port COM19
Waiting for the new upload port...
result: 'COM18'
Uploading .pio\build\micro\firmware.hex
avrdude: ser_open(): can't open device "\\.\COM18": The system cannot find the file specified.
avrdude done. Thank you.
*** [upload] Error 1
===================================================== [FAILED] Took 21.91 seconds =====================================================
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
Plot thickens. I tried it on my iMac and it works. I am going to try a complete uninstall of VS Code. I guess if I cannot get it running on the PC I will try to run it in a Linux VM on the PC. Still, I am interested in trying a bit more on the PC.
Frustrating because I want to do this project on āmy main pcā. Here is the output from the working mac:
Executing task: platformio run --target upload <
Processing micro (platform: atmelavr; board: micro; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/micro.html
PLATFORM: Atmel AVR 2.0.0 > Arduino Micro
HARDWARE: ATMEGA32U4 16MHz, 2.50KB RAM, 28KB Flash
PACKAGES: framework-arduino-avr 5.0.0, toolchain-atmelavr 1.50400.190710 (5.4.0), tool-avrdude 1.60300.190628 (6.3.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Checking size .pio/build/micro/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
DATA: [= ] 5.8% (used 149 bytes from 2560 bytes)
PROGRAM: [= ] 12.6% (used 3620 bytes from 28672 bytes)
Configuring upload protocol...
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
Looking for upload port...
Auto-detected: /dev/cu.usbmodemFD141
Forcing reset using 1200bps open/close on port /dev/cu.usbmodemFD141
Waiting for the new upload port...
Uploading .pio/build/micro/firmware.hex
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file ".pio/build/micro/firmware.hex"
avrdude: writing flash (3620 bytes):
Writing | ################################################## | 100% 0.28s
avrdude: 3620 bytes of flash written
avrdude: verifying flash memory against .pio/build/micro/firmware.hex:
avrdude: load data flash data from input file .pio/build/micro/firmware.hex:
avrdude: input file .pio/build/micro/firmware.hex contains 3620 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.03s
avrdude: verifying ...
avrdude: 3620 bytes of flash verified
avrdude: safemode: Fuses OK (E:FB, H:D8, L:FF)
avrdude done. Thank you.
============================================================================ [SUCCESS] Took 4.29 seconds ============================================================================
Terminal will be reused by tasks, press any key to close it.
Total uninstall of both Code and Code Insiders, as well as manually removing the left over .VScode and .platformio stuff in AppData and user local folders, then re-installing seems to have done the trick.
Oddly after re-install, my first attempt to replace PlatformIO could not find Python, which was mysteriously no longer on my PATH. So I installed the new Python 3.8, added it to the path and then re-installed PlatformIO and now I can program my Arduino Micro from the preferred work PC.
Thanks a lot for your assistance, even though in the end I just needed a clean install. If anyone reading this knows what caused the issue, I would like to know still!
That is really weird, but at least you have it working now. Maybe someone else find what the cause is if they encounter it.
For the verbose upload (or verbose build) you either add the -v flag if running the platformio command from the terminal, or use the verbose options in the panel.
toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder ā Library Dependency Finder (LDF) ā PlatformIO latest documentation
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependenciesā¦
Dependency Graph
|-- 1.0 (C:\Users\basti.platformio\packages\framework-arduino-avr\libraries\Wire)
Building in release mode
MethodWrapper([ācheckprogsizeā], [ā.pio\build\leonardo\firmware.elfā])
Advanced Memory Usage is available via āPlatformIO Home > Project Inspectā
RAM: [= ] 12.8% (used 327 bytes from 2560 bytes)
Flash: [== ] 18.8% (used 5382 bytes from 28672 bytes)
.pio\build\leonardo\firmware.elf
section size addr
.data 56 8388864
.text 5326 0
.bss 271 8388920
.comment 48 0
.note.gnu.avr.deviceinfo 64 0
.debug_info 2548 0
.debug_abbrev 2410 0
.debug_line 26 0
.debug_str 881 0
Total 11630
([āuploadā], [ā.pio\build\leonardo\firmware.hexā])
AVAILABLE: avr109
CURRENT: upload_protocol = avr109
BeforeUpload([āuploadā], [ā.pio\build\leonardo\firmware.hexā])
Auto-detected: COM11
Forcing reset using 1200bps open/close on port COM11
Waiting for the new upload portā¦
avrdude -v -p atmega32u4 -C C:\Users\basti.platformio\packages\tool-avrdude\avrdude.conf -c avr109 -b 57600 -D -P āCOM12ā -U flash:w:.pio\build\leonardo\firmware.hex:i
avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
Copyright (c) 2000-2005 Brian Dean
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is āC:\Users\basti.platformio\packages\tool-avrdude\avrdude.confā
Using Port : COM12
Using Programmer : avr109
Overriding Baud Rate : 57600
avrdude: ser_open(): canāt open device ā\.\COM12ā: Het systeem kan het opgegeven bestand niet vinden.
I wonder if there is a timing issue here⦠possibly there is too much of a delay between the COM12 programming port becoming available and avrdude trying to use it? Do you have the Arduino IDE installed - does it have the same issue?
I am having the same issue, Arduino IDE works perfectly fine, here is the verbose upload output:
Forcing reset using 1200bps open/close on port COM3
PORTS {COM3, COM6, COM9, } / {COM6, COM9, } => {}
PORTS {COM6, COM9, } / {COM4, COM6, COM9, } => {COM4, }
Found upload port: COM4
C:\Users\Ivo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\Ivo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf -v -patmega32u4 -cavr109 -PCOM4 -b57600 -D -Uflash:w:C:\Users\Ivo\AppData\Local\Temp\arduino_build_529372/sketch_sep03a.ino.hex:i
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\Ivo\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM4
Using Programmer : avr109
Overriding Baud Rate : 57600
AVR Part : ATmega32U4
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 9000 9000 0x00 0x00
flash 65 6 128 0 yes 32768 128 256 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : butterfly
Description : Atmel AppNote AVR109 Boot Loader
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
Programmer supports auto addr increment.
Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices:
Device code: 0x44
avrdude: devcode selected: 0x44
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% -0.00s
avrdude: Device signature = 0x1e9587 (probably m32u4)
avrdude: reading input file "C:\Users\Ivo\AppData\Local\Temp\arduino_build_529372/sketch_sep03a.ino.hex"
avrdude: writing flash (3602 bytes):
Writing | ################################################## | 100% 0.28s
avrdude: 3602 bytes of flash written
avrdude: verifying flash memory against C:\Users\Ivo\AppData\Local\Temp\arduino_build_529372/sketch_sep03a.ino.hex:
avrdude: load data flash data from input file C:\Users\Ivo\AppData\Local\Temp\arduino_build_529372/sketch_sep03a.ino.hex:
avrdude: input file C:\Users\Ivo\AppData\Local\Temp\arduino_build_529372/sketch_sep03a.ino.hex contains 3602 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.03s
avrdude: verifying ...
avrdude: 3602 bytes of flash verified
avrdude done. Thank you.
The PlatformIO output is the same as robear, I also tried completely uninstalling VS Code and PlatformIO, but to no success.
I should also add that for some reason my projects seem to upload much slower compared to some of my colleagues, it takes less than 3 seconds for other PCs in comparasion to 25 for mine.
Hello Community,
I have a similar Issue.
I m trying to upload my code to an arduino leonardo using Vscode + Platformio IDE.
as I connect the mC its been detected in port COM 10. tring to upload it tries to force the port for the upload but then it rejected and the shown faillure appears on another port ( COM 11 here for the case). the weird thing is that, on some other Laptops, the upload is running normally and the mC is working. I tried in other ports on my laptop and other devices and other mCs to check if the usb is working well and its the case. I have the following error as output :
///////////////////////////////////////
avrdude: ser_open(): canāt open device ā.\COM11ā: The specified file can not be found
avrdude done. Thank you.
*** [upload] Error 1
== [FAILED] Took 23.53
////////////////////////////
I donāt know why exactly, but on SOME pcs it just waits far too long (until the Arduino goes out of the bootloader) and only THEN tries to upload it, causing it to avrdude: ser_open(): canāt open device ā.\COM5ā.
A workaround is to manually reset the Arduino multiple times when itās looking for the āNew upload portā and if you do it in the right time, it recognizes it and uploads the firmware.