[env:program_via_USBasp]
platform = atmelavr
framework = arduino
board = uno
build_flags = -I include ; This is required for my file organization.
upload_protocol = custom
upload_port = usb
upload_flags =
-C
; use "tool-avrdude-megaavr" for the atmelmegaavr platform
${platformio.packages_dir}/tool-avrdude/avrdude.conf
-p
$BOARD_MCU
-P
$UPLOAD_PORT
-c
usbasp
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
lib_deps =
sui77/rc-switch@^2.6.4
It works fine. But no I can’t flush that controller via USB port:
Uploading .pio/build/uno/firmware.hex
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
…
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6b
I’m not sure, but you could possibly have overwritten bootloader with your custom firmware. The bootloader and firmware are flashed to the same memory region, only memory addresses are different. Usually PlatformIO handles that for you, but I see you supplied a custom upload_command – please check which address does it flash the firmware to.
I think you’re close to the truth. I did not find any ways to specify memory addresses for writing firmware, but I found something in the official documentation. This command:
upload_command = ... -U flash:w:$SOURCE:i
And documetation explanation:
-U memtype:op:filename[:format]
… memtype
… flash
The flash ROM of the device.
I suppose, it is starting to write from the first address in flash. But there was bootloader.
There are other options for memtype:
application
The application flash area of ATxmega devices.
apptable
The application table flash area of ATxmega devices.
I don’t know what this means in the context of avrdude.
When you use an ICSP device like your USBasp or my USBtiny, to upload a sketch, you overwrite the Uno bootloader.
In order to get the bootloader back, you have to rewrite it using the ICSP device. After that operation, you can then upload over USB without using the ICSP device, if you wish.
Yes, I understood. But it looks like shooting in the leg from the official documentation. There are no warnings or so. Just “take this config and be happy”. Even it is highly recommended to use the upload_command option to avoid damaging the controller. It’s pitty.
Anyway, this case can be closed. Thanks for replies.
These seem to reference ATxmega devices, which is a different chip family, not the one Arduino Uno is built on. Maybe they have different flash memory regions.