Flashing klipper via /scripts/flash-sdcard.sh

I am trying to flash klipper to my Tevo Tornado (gold) with a mks genl v1.0 board.
I have klipper running on a raspberry pi and the pi is connected to the mks genl v1.0 directly (not via usb) and I can connect to the board this way via /dev/ttyS0.
I have pulled the latest klipper from GitHub
I did a make menuconfig and set mcu to atmega 2560
I then ran make which gave me a klipper.elf.hex firmware file
Then I would like to use the flash-sdcard.sh script to flash the firmware, so I ran:
./scripts/flash-sdcard.sh -f out/klipper.elf.hex /dev/ttyS0 mks-sgenl-v1
But I get this error:
SD Card Flash Error: MCU Type mismatch: Build MCU = lpc1768, Connected MCU = atmega2560

I tried to re-run menuconfig with the same result.
I tried to compile for several random mcu’s in menuconfig but I get the same error stating that it has been build for a lpc1768 mcu.

Every iteration of reconfig was done with:

make clean
make menuconfig
./scripts/flash-sdcard.sh -f out/klipper.elf.hex /dev/ttyS0 mks-sgenl-v1

It seems that no matter what mcu I build for, the script will see it as build for a lpc1768

Or am I missing the purpose of the flash-sdcard.sh script?

Best regards Jeppe

Here is the full error message:

SD Card Flash Error: MCU Type mismatch: Build MCU = lpc1768, Connected MCU = atmega2560
Traceback (most recent call last):
  File "/home/jeppe/klipper/scripts/spi_flash/spi_flash.py", line 1647, in main
  File "/home/jeppe/klipper/scripts/spi_flash/spi_flash.py", line 1584, in run
  File "/home/jeppe/klipper/scripts/spi_flash/spi_flash.py", line 1570, in run_reactor_task
  File "/home/jeppe/klipper/klippy/reactor.py", line 292, in run
  File "/home/jeppe/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
  File "/home/jeppe/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
  File "/home/jeppe/klipper/klippy/reactor.py", line 48, in invoke
    res = self.callback(eventtime)
  File "/home/jeppe/klipper/scripts/spi_flash/spi_flash.py", line 1518, in run_reset_upload
  File "/home/jeppe/klipper/scripts/spi_flash/spi_flash.py", line 1210, in connect
    % (build_mcu_type, mcu_type))
SPIFlashError: MCU Type mismatch: Build MCU = lpc1768, Connected MCU = atmega2560
  1. It appears that you have built your code for an LPC, but AFAIK the MKS-GEN_L is an ATMEGA2560
  2. You need to specify the .bin file and not the .hex, i.e. ~/klipper/out/klipper.bin
  3. You need to specify the board. List available boards with ./scripts/flash-sdcard.sh -l

Generally speaking, it makes sense to refer to the documentation: SDCard updates - Klipper documentation

Edit: It would also be very much appreciated if you read the information on the correct category before posting.

Hi Sineos

Thank you for your reply.
I am afraid I did not fully explain the steps I have tried. English is not my native language but I try to be as precise as I can :slight_smile:

Obviously I have set the board to atmega2560 in the make menuconfig menu. (As I described in my first post)
I did read the SDCard updates Klipper documentation. That was where I found out about the flash-sdcard.sh script in the first place and where I got the correct parameters to pass to it.
But the issue is that no matter what type of board (including the correct one - atmega2560) that I build for, I get the same error stating that it is build for an LPC mcu.
So it seems that something is not working as intended?

Also there is no klipper.bin after build is finished.
Here is the dump of the build process:

Creating symbolic link out/board
  Building out/autoconf.h
  Compiling out/src/sched.o
  Compiling out/src/command.o
  Compiling out/src/basecmd.o
  Compiling out/src/debugcmds.o
  Compiling out/src/initial_pins.o
  Compiling out/src/gpiocmds.o
  Compiling out/src/stepper.o
  Compiling out/src/endstop.o
  Compiling out/src/trsync.o
  Compiling out/src/adccmds.o
  Compiling out/src/spicmds.o
  Compiling out/src/i2ccmds.o
  Compiling out/src/pwmcmds.o
  Compiling out/src/buttons.o
  Compiling out/src/tmcuart.o
  Compiling out/src/neopixel.o
  Compiling out/src/pulse_counter.o
  Compiling out/src/lcd_st7920.o
  Compiling out/src/lcd_hd44780.o
  Compiling out/src/spi_software.o
  Compiling out/src/i2c_software.o
  Compiling out/src/thermocouple.o
  Compiling out/src/sensor_adxl345.o
  Compiling out/src/sensor_angle.o
  Compiling out/src/sensor_mpu9250.o
  Compiling out/src/avr/main.o
  Compiling out/src/avr/timer.o
  Compiling out/src/avr/gpio.o
  Compiling out/src/avr/adc.o
  Compiling out/src/avr/spi.o
  Compiling out/src/avr/i2c.o
  Compiling out/src/avr/hard_pwm.o
  Compiling out/src/avr/watchdog.o
  Compiling out/src/avr/serial.o
  Compiling out/src/generic/serial_irq.o
  Building out/compile_time_request.o
Version: v0.11.0-221-g6ce2bd61
  Linking out/klipper.elf
  Creating hex file out/klipper.elf.hex

cat out/autoconf.h | grep CONFIG_MCU
#define CONFIG_MCU "atmega2560"

Best regards
Jeppe Sohn

This is still applicable.

Further ./scripts/flash-sdcard.sh -l does not list MKS GEN_L (ATMEGA2560) as applicable board. The MKS SGEN_L is a different board (LPC1768).
I do not use the flash-sdcard.sh but it simply seems that the ATMEGA is not supported by this mechanism

Ahh. Sorry. I did not see the S part of the board name “mks-sgenl-v1”.
Thank you for your time.