Trouble with flashing Marlin 2.1 on MKS board via Arduino UNO as programmer

Greetings, really hope here can help me. I’m building a 3D printer. Use board MKS Gen L v1.0 (for this board, as I understand it, a common problem is that the usb connector does not work, the same for me). So I use arduino uno as programmer. Marlin 2.1, PlatformIO, VScode, Marlin Firmware Auto Build.

So firmware is okey after “build” its success. But after upload its says that and no flashing :confused:

Configuring upload protocol…
AVAILABLE: wiring
CURRENT: upload_protocol = wiring
Looking for upload port…
Auto-detected: COM4
Uploading .pio\build\mega2560\firmware.hex
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done. Thank you.

*** [upload] Error 1

How can i fix it ? Thanks in advance for your help !

Meaning you flashed the “Arduino as ISP” sketch on the Arduino Uno and connected it to the ISP port of the Mega?

If your target is the Mega2560 then it should be working out of the box (but very apparently it doesn’t).

Can you double check the main microcontroller on your printer board is an Atmel ATMega2560?

Thanks for answering
Yes arduino as ISP but i dont use Arduino IDE. Arduino IDE just for upload programmer sketch on arduino UNO, then i use in VScode > PlatformIO > Marlin auto build
Yes it is Mega2560

Find the ini/avr.ini file in your Marlin project at these lines

and then after those lines you should add to it the instructions to flash via “Arduino as ISP” method as documented (Atmel AVR — PlatformIO v6.1 documentation), so,

upload_protocol = custom
upload_port = COM4
upload_speed = 19200
upload_flags =
    -C
    ${platformio.packages_dir}/tool-avrdude/avrdude.conf
    -p
    $BOARD_MCU
    -P
    $UPLOAD_PORT
    -b
    $UPLOAD_SPEED
    -c
    stk500v1
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i

then retry uploading.

1 Like

omg man, thank u so much its finally working