MKS SGEN V1 LPC1679 SD firmware update troubles

Basic Information:

Printer Model: Ender 5
MCU / Printerboard: lpc1769 MKS SGEN V1, Fysetc UCAN, BTT EBB42 V1.2. [v0.12.0-468-gd679f711e]
Host / SBC: Intel Celeron all in one x86 [v0.12.0-468-gd679f711e]
klippy(62).log (7.4 MB)

Describe your issue:

LPC1769 based board from the Smoothieboard era. Checked 20 times, zoomed in with a loupe and taken photos. It IS a 1769 and not a 1768.
Tested with an 8GB card and a 2GB card. Fat32,
This happens on Raspberry Pi 3b+ and Pi 4 as well.

I’m trying to flash the klipper.bin file when updating the FW to the SD card with:

./scripts/flash-sdcard.sh /dev/serial/by-id/usb-Klipper_lpc1769_1320000C261928AF9E93995BC52000F5-if00 generic-lpc1769

The result is the following:

Already up to date.
Flashing /home/aio/klipper/out/klipper.bin to /dev/serial/by-id/usb-Klipper_lpc1769_1320000C261928AF9E93995BC52000F5-if00
Checking FatFS CFFI Build...
Connecting to MCU...Connected
Checking Current MCU Configuration...Done
MCU needs restart: is_config=1, is_shutdown=0
Attempting MCU Reset...Done
Waiting for device to reconnect...Done
Connecting to MCU...Connected
Initializing SD Card and Mounting file system...

SD Card Flash Error: Failed to Initialize SD Card. Is it inserted?
Traceback (most recent call last):
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1323, in _configure_mcu_spibus
    self.fatfs.mount(printfunc)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 326, in mount
    raise OSError("flash_sdcard: failed to mount SD Card, returned %s"
OSError: flash_sdcard: failed to mount SD Card, returned FR_NOT_READY

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1646, in main
    spiflash.run()
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1586, in run
    self.run_reactor_task(self.run_sdcard_upload)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1569, in run_reactor_task
    k_reactor.run()
  File "/home/aio/klipper/klippy/reactor.py", line 292, in run
    g_next.switch()
  File "/home/aio/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
                            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/klippy/reactor.py", line 48, in invoke
    res = self.callback(eventtime)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1541, in run_sdcard_upload
    self.mcu_conn.configure_mcu(printfunc=output_line)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1358, in configure_mcu
    self._configure_mcu_spibus(printfunc=printfunc)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1326, in _configure_mcu_spibus
    raise SPIFlashError(
SPIFlashError: Failed to Initialize SD Card. Is it inserted?

I’ve been trying a few different bootloaders and the by Smoothieware is the one I’ve been using (i’ve not found another bootloader that is for the LPC1769 and as the MKS SGE V1 is a “smoothieware” compatible board…).

Any ideas on how to get this working? Or a different bootloader to try?

Thanks as always!!!

Have you tried FAT16?

1 Like

It was years ago since I last used flash-sdcard.sh for my LPC boards, but I remember that it had mixed success. One time it worked, and the next day it failed for whatever reasons.

I finally upgraded all to the Katapult bootloader and was done with it. So if you feel like doing so, find an instruction here: CanBoot: Flash BTT SKR 1.3 / 1.4 / 1.4 Turbo

I cannot explain my inner disappointment in myself… WHY did i overlook this :sob:

@Sineos I will also definitely check this out. The bootloader I’m using is 11 years old.

Thanks!!

1 Like

Dangit! Was too good to be true!!!

Made a partition with less than 512MB, tried FAT16 [0x0e], FAT16(LBA) [0x06] and both 2GB and 8GB cards are no longer working! The error does seem to be different from before tho!

Flashing /home/aio/klipper/out/klipper.bin to /dev/serial/by-id/usb-Klipper_lpc1769_1320000C261928AF9E93995BC52000F5-if00
Checking FatFS CFFI Build...
Connecting to MCU...Connected
Checking Current MCU Configuration...Done
MCU needs restart: is_config=1, is_shutdown=0
Attempting MCU Reset...Done
Waiting for device to reconnect....Done
Connecting to MCU...Connected
Initializing SD Card and Mounting file system...

SD Card Information:
Version: 2.0
SDHC/SDXC: True
Write Protected: False
Sectors: 15564800
manufacturer_id: 2
oem_id: TM
product_name: SD08G
product_revision: 3.56
serial_number: C3564D8B
manufacturing_date: 7/2009
capacity: 7.4 GiB
fs_type: FAT16
volume_label: b'SMOOTHIE'
volume_serial: 1051792695
Uploading Klipper Firmware to SD Card...
SD Card Flash Error: Error Uploading Firmware
Traceback (most recent call last):
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1378, in sdcard_upload
    sd_f.write(buf)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 464, in write
    raise OSError("flash_sdcard: Error writing file '%s'" % (self.path))
OSError: flash_sdcard: Error writing file 'firmware.bin'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1646, in main
    spiflash.run()
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1586, in run
    self.run_reactor_task(self.run_sdcard_upload)
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1569, in run_reactor_task
    k_reactor.run()
  File "/home/aio/klipper/klippy/reactor.py", line 292, in run
    g_next.switch()
  File "/home/aio/klipper/klippy/reactor.py", line 340, in _dispatch_loop
    timeout = self._check_timers(eventtime, busy)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/klippy/reactor.py", line 158, in _check_timers
    t.waketime = waketime = t.callback(eventtime)
                            ^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/klippy/reactor.py", line 48, in invoke
    res = self.callback(eventtime)
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1548, in run_sdcard_upload
    self.firmware_checksum = self.mcu_conn.sdcard_upload()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/aio/klipper/scripts/spi_flash/spi_flash.py", line 1381, in sdcard_upload
    raise SPIFlashError("Error Uploading Firmware")
SPIFlashError: Error Uploading Firmware

Edit: This time it’s done something to the SD card and the mainboard is not recognized by Klipper. Going to look into the Klipper bootloader.

Well, we had cases where someone tried 5 different SD cards until it worked. The SD card reading capabilities of these printer boards are finicky at best.
For the long term, I can only recommend going with the Katapult bootloader.

Had some trouble with the Build Katapult deployment application.
Ended up using the 16KiB bootloader, but not using the deployer.bin instead only flashing the katapult.bin.

Finally!! A way to update all boards!

Thanks!

service klipper stop
cd ~/klipper
git pull

#UPDATE MKS SGEN V1
make clean KCONFIG_CONFIG=config.oid-mks-sgenl-v1
make menuconfig KCONFIG_CONFIG=config.oid-mks-sgenl-v1
make KCONFIG_CONFIG=config.oid-mks-sgenl-v1
make flash FLASH_DEVICE=/dev/serial/by-id/usb-Klipper_lpc1769_1320000C261928AF9E93995BC52000F5-if00

#UPDATE BTT EBB42 V1.2
make clean KCONFIG_CONFIG=config.oid-ebb42
make menuconfig KCONFIG_CONFIG=config.oid-ebb42
make KCONFIG_CONFIG=config.oid-ebb42
python3 ~/katapult/scripts/flashtool.py -i can0 -f ~/klipper/out/klipper.bin -u 76f387ebdd7f

#UPDATE FYSETC UCAN
make clean KCONFIG_CONFIG=config.oid-UCAN
make menuconfig KCONFIG_CONFIG=config.oid-UCAN
make KCONFIG_CONFIG=config.oid-UCAN
python3 ~/katapult/scripts/flashtool.py -i can0 -u 9da2407d323f -r
make KCONFIG_CONFIG=config.oid-UCAN flash FLASH_DEVICE=/dev/serial/by-id/usb-katapult_stm32f072xb_38002C001857435438353920-if00

service klipper start

1 Like