Uploading with stk500v2 not working with atmega

I am trying to run a project with Atmega and avrdude.
Following the code provided in the docs:
ini:

[env:program_via_AVRISP_mkII]
platform = atmelavr
board = atmega8
framework = arduino
upload_protocol = custom
upload_port = usb
upload_flags =
-C ${platformio.packages_dir}/tool-avrdude/avrdude.conf
-e
-v
-c stk500v2
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

I get the error

avrdude: can't open config file " /Users/XY/.platformio/packages/tool-    avrdude/avrdude.conf": No such file or directory

I can localize and open this file without problems.
What is going wrong?
Is there an example ini for Atmega/avrdude without arduino?

Hi,
you could try to give the path directly and complete after -C:

  • C /home/user/…
    if that works something is wrong with your path variables.

tried that, same error

Each option on their own line. -C, new line, ${platformio.packages_dir}/tool-avrdude/avrdude.conf

Thank you a lot. I changed that.
The conf-file seems to be found now. But there is a new rather strange error:

avrdude: error at /Users/ruediheimlicher/.platformio/packages/tool-           avrdude/avrdude.conf:421: syntax error
avrdude: error reading system wide configuration file "/Users/ruediheimlicher/.platformio/packages/tool-avrdude/avrdude.conf"

I can’t imagine that this is a real error.
deleting line 421 transfers the error to line 422, going down to the fist programmer.
I looked arround for other config files
MegaCore is similiar with these lines arround the default, Teensyduino which I often use too

Are there mutliple tool-avrdude folders? It might be using a v8 config file with the v7 program.

No, there is only one. Another is named as

tool-avrdude@1.60300.200527

Screenshot as attatchment.

I temporarly renamed it to ‘tool_averdude’ and the other to 'tool_averdude_a.conf,

generating a lot of errors.

There are multiple folders containing @123 in the name. No idea where I got them.

Do you have avrdude installed globally, which might be used instead? Can you use

upload_command = ${platformio.packages_dir}/tool-avrdude/avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

instead?

I did that, the syntax error is gone.
I now get a new error:

avrdude programmer_not_found() error: cannot find programmer id  stk500v2

The device is seen as

/dev/cu.usbserial-AM0190V3 	FT232R USB UART	USB VID:PID=0403:6001 SER=AM0190V3 LOCATION=1-1

I am using this programmer for AVR projects with Xcode for many years.

I also tried with a Pololu USB AVR Programmer v2.1 as you mentioned in Jul 2022 in the Community, with the same result.

Thanks for your help.

If it’s just a serial adapter, why set the upload port to “USB”? It should be COM something. Please follow the docs exactly in the AVRISP mkII section.

sorry for the time consuming task.

I am working on a Mac M1. No COM-Port on macos.
I find the port UNIX-like with ls -la /dev/cu.*

 /dev/cu.usbserial-AM0190V3

or with ls -la /dev/tty.*

/dev/tty.usbserial-AM0190V3

I also tried the ft32r programmer with same result.

As a test I tried the upload an old C-Program with this programmer. That run well:

ruediheimlicher@macbook-pro-1 AVR LED 3 % make program
avrdude -p atmega328p -P /dev/tty.usbserial-AM0190V3    -c stk500v2    -U flash:w:avrm8ledtest_B.hex 

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.10s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
     To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "avrm8ledtest_B.hex"
avrdude: input file avrm8ledtest_B.hex auto detected as Intel Hex
avrdude: writing flash (190 bytes):

Writing | ################################################## | 100% 0.12s

avrdude: 190 bytes of flash written
avrdude: verifying flash memory against avrm8ledtest_B.hex:
avrdude: input file avrm8ledtest_B.hex auto detected as Intel Hex

Reading | ################################################## | 100% 0.14s

avrdude: 190 bytes of flash verified

avrdude done.  Thank you.

I found a dirty hack to upload the hex file:
I took the path I use for my former uploads with Xcode.
First cd into the project dir and then

avrdude -p m328p -c stk500v2 -P /dev/tty.usbserial-AM0190V3 -U flash:w:.pio/build/ATmega328P/firmware.hex 

But how can I integrate that in to the .ini file?

Can’t you just do

[env:program_via_AVRISP_mkII]
platform = atmelavr
board = atmega8
framework = arduino
upload_protocol = stk500v2

Uff.
That did the trick.
At first, I had a error in the verifying. But now the hex file is uploaded correctly.
Thanks a lot for your patience. Fee for coffee is sent.