Hi,
I have BTT SKR2 board and I’d like to have working SD flash for firmware update.
As board_defs.py doesn’t contain settings for SKR-2, I added this (based on schema of this board):
diff --git a/scripts/spi_flash/board_defs.py b/scripts/spi_flash/board_defs.py
index 68385f04..ab16c437 100644
--- a/scripts/spi_flash/board_defs.py
+++ b/scripts/spi_flash/board_defs.py
@@ -55,6 +55,12 @@ BOARD_DEFS = {
'spi_bus': "spi1",
"cs_pin": "PA4",
"current_firmware_path": "OLD.BIN"
+ },
+ 'btt-skr-2': {
+ 'mcu': "stm32f407xx",
+ 'spi_bus': "swspi",
+ 'spi_pins': "PC8,PD2,PC12",
+ 'cs_pin': "PC11"
}
}
Which makes working at least to this state:
pi@fluiddpi:~/klipper $ ./scripts/flash-sdcard.sh /dev/serial/by-id/usb-Klipper_stm32f407xx_2B0023000247393439313338-if00 btt-skr-2
Flashing /home/pi/klipper/out/klipper.bin to /dev/serial/by-id/usb-Klipper_stm32f407xx_2B0023000247393439313338-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: 62333952
manufacturer_id: 3
oem_id: SD
product_name: SL32G
product_revision: 8.128
serial_number: ECAEE005
manufacturing_date: 1/2019
capacity: 29.7 GiB
fs_type: FAT32
volume_label: ENDER
volume_serial: 1081870871
Uploading Klipper Firmware to SD Card...Done
Validating Upload...Done
Firmware Upload Complete: firmware.bin, Size: 22328, Checksum (SHA1): 34545302815A304DC43B8A1AFE60146C95E9E0EB
Attempting MCU Reset...Done
Waiting for device to reconnect....Done
Connecting to MCU...Connected
Verifying Flash...
SD Card Flash Error: Version Mismatch: Got 'v0.9.1-628-gb4fec850-dirty-20210724_232904-fluiddpi...', expected 'v0.9.1-629-g0075b290-dirty-20210724_233606-fluiddpi...'
Traceback (most recent call last):
File "/home/pi/klipper/scripts/spi_flash/spi_flash.py", line 1159, in main
spiflash.run()
File "/home/pi/klipper/scripts/spi_flash/spi_flash.py", line 1113, in run
self.run_reactor_task(self.run_verify)
File "/home/pi/klipper/scripts/spi_flash/spi_flash.py", line 1095, in run_reactor_task
k_reactor.run()
File "/home/pi/klipper/klippy/reactor.py", line 269, in run
g_next.switch()
File "/home/pi/klipper/klippy/reactor.py", line 310, in _dispatch_loop
timeout = self._check_timers(eventtime, busy)
File "/home/pi/klipper/klippy/reactor.py", line 156, in _check_timers
t.waketime = waketime = t.callback(eventtime)
File "/home/pi/klipper/klippy/reactor.py", line 48, in invoke
res = self.callback(eventtime)
File "/home/pi/klipper/scripts/spi_flash/spi_flash.py", line 1084, in run_verify
self.new_dictionary)
File "/home/pi/klipper/scripts/spi_flash/spi_flash.py", line 966, in verify_flash
json.loads(req_dictionary)['version']))
SPIFlashError: Version Mismatch: Got 'v0.9.1-628-gb4fec850-dirty-20210724_232904-fluiddpi...', expected 'v0.9.1-629-g0075b290-dirty-20210724_233606-fluiddpi...'
Uploaded firmware.bin is OK (md5sums matches), the only thing which didn’t happened is … actual board reset .
When I reset the board manually (or even by “FIRMWARE_RESTART”, I think), FW is flashed (and renamed fo “firmware.cur”).
So, there must be something wrong with reset function in flash-sdcard.sh ( spi_flash.py).
But this is beyond my ability and because of that I’m not even sure whether I shoud place pull request with SKR2 definition for board_defs.py (because without working reset, it is useless).
I write it here, because I’m really not sure whether spi_flash.py “reset” doesn’t work for any board (it worked in time when I had SKR Mini E3 v2.0, few(?) months ago) or just SKR-2.