Atmel328 burning via MKII

Excuse me for this post, but I need a ready-made solution, I’m not a programmer, but I have already done my project, checked it on arduino and now I need to upload my firmware into the controller via ISP. I can do this in AVRStudio Windows, but it is inconvenient and time consuming.
I read a lot about it, but unfortunately I didn’t understand much.
I have an MKII programmer and a small PCB on which a 328 chip is soldered and pads for an ISP programmer are made.
I need a platformio.ini that will work with my configuration and allow me to load my code bypassing CH340, RX, TX, etc.

When requesting help it is still expected that one reads up on at least the documentation. The Atmel AVR documentation has the needed platformio.ini to setup the programmer. The programmer must be be connected to the ISP port (aka the SPI port) of the target microcontroller – pinouts of that programmer and the ATMega328 are available online.

With I figured out something and read a lot. MKII programmer is connected to USB, controller is connected to it on SPI pins, but I get an error. In a few hours I will be able to write what exactly.
Here is platformio.ini:

[env:program_via_AVRISP_mkII]
platform = atmelavr
framework = arduino
board = nanoatmega328
upload_protocol = avrispmkII
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    atmega328p
    -P
    $UPLOAD_PORT
    -b
    115200
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
upload_port = /dev/cu.wchusbserial1410

The documentation says to set upload_port = usb – seems like you’re still telling PlatformIO to attempt an upload via the serial bootloader. Also

is not mentioned in the documentation. Commands should be more like

upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    stk500v2
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

as copied from the documentation.

I did not mention, all this is for platformio mac OS

Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [= ] 10.0% (used 204 bytes from 2048 bytes)
Flash: [= ] 9.7% (used 2984 bytes from 30720 bytes)
Configuring upload protocol…
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/program_via_AVRISP_mkII/firmware.hex
avrdude: ser_open(): can’t open device “usb”: No such file or directory

avrdude done. Thank you.

*** [upload] Error 1

Try with a modified uplaod_flags of

upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -c
    stk500v2

and report error.

Building .pio/build/program_via_AVRISP_mkII/firmware.hex
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  10.0% (used 204 bytes from 2048 bytes)
Flash: [=         ]   9.7% (used 2984 bytes from 30720 bytes)
Configuring upload protocol...
AVAILABLE: custom
CURRENT: upload_protocol = custom
Uploading .pio/build/program_via_AVRISP_mkII/firmware.hex
avrdude: ser_open(): can't open device "unknown": No such file or directory

avrdude done.  Thank you.

*** [upload] Error 1

I use such a programmer, it works in Windows, but in MacOS I don’t see it in the list of connected devices, is this normal?

Actually I think the documentation is wrong on the command. Posts like these show a different avrdude invocation. Can you try with

[env:program_via_AVRISP_mkII]
platform = atmelavr
framework = arduino
board = nanoatmega328
upload_protocol = custom
upload_port = usb
upload_flags =
    -C
    $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -c
    avrispmkII
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

?

The USB device should be recognized however and some libusb drivers should be used. I can’t recognize in your screenshot where the USB devices are, but I would search in the control panel for USB devices instead.

I don’t know how, but it worked! Thank you very much!:man_bowing:
But the programmer never appeared in the device list

This view shows serial interface devices (the bluetooth one is emulating one), not all USB devices, that’s okay.

I am very grateful for your help!