Hi!
There is this weird thing where I can successfully interface with an atmega328p on avrdude using the Atmel ICE, but not platformIO.
I already investigated how to use the atmel ICE on PIO in the past. One of the important steps was to set the drivers for the atmel ICE to libusb. However, on my new laptop, I had to set it to WinUSB. According to ChatGPT (hehe) this is because avrdude 7.x now requires WinUSB.
Anyway, since I have set my drivers to WinUSB, I can communicate with my ICE and properly detect MCUs on my new laptop. However, this only works in powershell, not it platformIO.
In powershell:
PS C:\Users\jcsb> avrdude -c atmelice_isp -p m328p -P usb -B 10 -v -n
... (skip most of the print)
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude done. Thank you.
Whereas in PIO terminal (which curiously prints PS so it looks like it uses powershell?):
PS C:\Users\jcsb\Documents\Repositories\project> avrdude -c atmelice_isp -p m328p -P usb -B 10 -v -n
...
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x000102
avrdude main() error: expected signature for ATmega328P is 1E 95 0F
double check chip or use -F to override this check
avrdude done. Thank you.
More importantly, when I try to upload, here is what I get:
PS C:\Users\jcsb\Documents\Repositories\project> pio run -e face -t upload
... (skip successful build output)
Building .pio\build\face\firmware.hex
Configuring upload protocol...
AVAILABLE: atmelice_isp
CURRENT: upload_protocol = atmelice_isp
Looking for upload port...
Using manually specified: usb
*** [upload] could not open port 'usb': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)
============================== [FAILED] Took 2.12 seconds ==============================
I use the same command, and checked in both terminals that the avrdude version is the same, i.e. avrdude version 7.2-arduino.1
Here is my platformio.ini file just in case:
[env:face]
platform = atmelavr
board = ATmega328P
framework = arduino
upload_protocol = atmelice_isp
upload_flags = -e
upload_port = usb
board_build.f_cpu = 8000000L
board_fuses.hfuse = 0xDF ;smallest flash section size 256 since not using a BSL w/ Atmel-ICE
board_fuses.lfuse = 0xE2 ;int 8MHz crystal (16MHz not working with less than 5V PSU)
board_fuses.efuse = 0xFE ;BOD at 1.8V, perfect for low power
src_filter= -<*> +<face>
build_flags = -DFACE_BUILD -Icommon
test_filter = test_common test_face
lib_deps =
paulstoffregen/OneWire@^2.3.8
This is the platformIO.ini that I have always used to use the Atmel ICE. I think the issue may relate with some environment config that is set when opening PIO, otherwise PIO ini rules have changed and I should change the upload_port value. Any idea? Thanks!