Printer Model: Sapphire Pro
MCU / Printerboard: BTT SKR Mini V3.1
Host / SBC: Orange Pi Zero 2W (Running Debian 6.1.31) klippy.log (55.6 KB)
I am trying to get Katapult to work with a serial connection and I’m getting a strange response when I run the flashtool.py application, trying to Flash Klipper into the MCU.
The steps I’m following once the Orange Pi boots and I can SSH into it are:
Enable UART0 by adding the line “overlays=uart0” to /boot/orangepiEnv.txt"
sudo reboot
Load Klipper using Kiauh: git clone https://github.com/dw-0/kiauh.git ./kiauh/kiauh.sh
Then load: Klipper/Moonraker/Mainsail
Build Katapult: make menuconfig with the parameters:
-STM32G0B1
-Serial (on USART2 PA3/PA2)
-250000 Baud Rate
Connect Orange Pi to main controller using USB
Load Katapult.bin onto an SD card as firmware.bin
Load Katapult into the BTT SKR Mini E3 V3.1:
-Power Down
-Put SD Card in the socket
-Power Up
-Wait for Firmware to Update
-Power Down & remove the SD Card
Connect the BTT SKR Mini E3 V3 “TFT” connection to the Orange Pi’s UART0 port.
Build Klipper:
-STM32G0B1
-Serial (on USART2 PA3/PA2)
-250000 Baud Rate
Try to burn Klipper into the main controller: python3 ~/Katapult/scripts/flashtool.py -d /dev/ttyS0 -b 250000
The response to the final command is:
Attempting to connect to bootloader
ERROR:root:Flash Error
Traceback (most recent call last):
File "/home/orangepi/Katapult/scripts/flashtool.py", line 554, in run
await flasher.connect_btl()
File "/home/orangepi/Katapult/scripts/flashtool.py", line 90, in connect_btl
ret = await self.send_command('CONNECT')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/orangepi/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [CONNECT] to Can Device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/orangepi/Katapult/scripts/flashtool.py", line 633, in main
loop.run_until_complete(sock.run(args.device, args.baud, fpath))
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/orangepi/Katapult/scripts/flashtool.py", line 561, in run
await flasher.finish()
File "/home/orangepi/Katapult/scripts/flashtool.py", line 275, in finish
await self.send_command("COMPLETE")
File "/home/orangepi/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [COMPLETE] to Can Device
I don’t understand why there is an attempt to communicate with a “Can Device”.
Any ideas what I’m doing wrong here? This is basically my Katapult process for a UART connection, but with using serial ports.
Doing a search, there doesn’t seem to be anybody who has tried this before - am I in uncharted territory?
One more datapoint. The instructions seem to say to use /dev/ttyS0 but I also tried /dev/tty0 but got a permissions error.
In response to that, I gave my self R/W access to /dev/tty0, ran the command with the following response:
orangepi@orangepizero2w:~$ python3 ~/Katapult/scripts/flashtool.py -d /dev/tty0 -b 250000
Attempting to connect to bootloader
ERROR:root:Flash Error
Traceback (most recent call last):
File "/home/orangepi/Katapult/scripts/flashtool.py", line 554, in run
await flasher.connect_btl()
File "/home/orangepi/Katapult/scripts/flashtool.py", line 90, in connect_btl
ret = await self.send_command('CONNECT')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/orangepi/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [CONNECT] to Can Device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/orangepi/Katapult/scripts/flashtool.py", line 633, in main
loop.run_until_complete(sock.run(args.device, args.baud, fpath))
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/orangepi/Katapult/scripts/flashtool.py", line 561, in run
await flasher.finish()
File "/home/orangepi/Katapult/scripts/flashtool.py", line 275, in finish
await self.send_command("COMPLETE")
File "/home/orangepi/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [COMPLETE] to Can Device
I suspect that the issue is that you are trying to flash Katapult with your existing bootloader. Katapult itself is a bootloader and thus needs to overwrite the existing one. You can do that with a programmer, DFU (if available), or using Katapult’s deployer. I would strongly recommend backing up the stock bootloader first.
FWIW, the mention of “CAN Device” in the error is just a stale message, as originally Katapult was exclusively a CAN bootloader. I’ll look into updating the errors based on the the interface type.
I’ve waited for a chance to fire up my ST Link and I’ll use that to clear out the old bootloader and get the board into DFU mode. I actually picked the SKR Mini E3 V3.1 because I wanted to play around with DFU on it.
I’ll let you know what happens.
If you update the error messages and have something for me to try out - let me know.
Back to the original problem but I think with getting everything working before, I’m making headway although still no joy. For some reason, Katapult is not responding to flashtool.py. Maybe you have some idea what’s happening here.
Using the same Raspberry Pi Zero 2W and OS Image that I got Klipper working in here (has Klipper installed and the sudo systemctl disable hciuart along with the sudo raspi-config operations completed):
biqu@serial-arksine:~/klipper $ python3 ~/Katapult/scripts/flashtool.py -d /dev/ttyS0 -b 250000
Attempting to connect to bootloader
ERROR:root:Flash Error
Traceback (most recent call last):
File "/home/biqu/Katapult/scripts/flashtool.py", line 554, in run
await flasher.connect_btl()
File "/home/biqu/Katapult/scripts/flashtool.py", line 90, in connect_btl
ret = await self.send_command('CONNECT')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/biqu/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [CONNECT] to Can Device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/biqu/Katapult/scripts/flashtool.py", line 633, in main
loop.run_until_complete(sock.run(args.device, args.baud, fpath))
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/biqu/Katapult/scripts/flashtool.py", line 561, in run
await flasher.finish()
File "/home/biqu/Katapult/scripts/flashtool.py", line 275, in finish
await self.send_command("COMPLETE")
File "/home/biqu/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [COMPLETE] to Can Device
As an additional datapoint, I hooked up my 'scope to the serial connection and I can see flashtool reaching out (top trace) ten times, but no response from the main controller board (next trace down):
The build looks fine, and if the status led is flashing then its running.
It looks like there are some changes to Klipper’s serial implementation for the G0 that haven’t been synced to Katapult. I’ll see if I can get them synced and create a pull request.
Pull request is here. I can’t test the changes, but hopefully they fix the issue. It also includes some changes to flashtool to make the error more generic.
If you want to download the source, you can do using with this link.
However, you can also use git if you are familiar with it. Presuming you already have the katapult repo cloned, you could do something like the following:
cd katapult
git fetch
git checkout origin/dev-sync-stm32-20240805
This will put the repo into a detached state. You can then perform your build, use flashtool, etc.
When you want to go back to the original state, you can checkout the master branch.
First off, I downloaded the original katapult.bin from Notepad++ and saved it as katapult-original.bin.
Did that and created katapult-new.bin.
Then I did a kdiff on the two files and they’re “binary equal”.
I loaded the zip file into the RPi, unzipped it into its own folder and did a make menuconfig with the same parameters as I did originally (stm32, UART1 on PA10/PA9, specified STATUS LED as PB13) and then did a build and saved the result as katapult-new-copied.bin and did a kdiff:
I would have thought something would have changed in the build if the source had been modified - even if it was functionally identical, I would expect instruction order or something else non-consequential would be change and that would show up in kDiff.
If you can’t think of anything, let me ruminate on it…
The changes specific to syncing code from Klipper can be found here.
With regard to the G0, these changes seem to impact which code is pulled in based on the variant. Most likely they didn’t impact what was pulled for your vaiant, which is why the binary did not change.
Okay, I’ve moved the ball downfield somewhat but not into the endzone.
I’ve been playing around with stm32flash, to see if I can get Katapult (or Klipper) loaded at the base of the stm32g0b1’s flash and I got a certain amount of traction by reimaging the Raspberry Pi so that UART0 comes up as ttyAMA0 rather than ttyS0. I was never able to get the MCU programmed, but I did get some communications working.
So, taking this rPi, I went through the process of loading Klipper (using dfu-util) and then tried flashtool and got this:
biqu@serial-ttyAMA0:~/klipper $ python3 ~/Katapult/scripts/flashtool.py -d /dev/ttyAMA0 -b 250000
Attempting to connect to bootloader
Katapult Connected
Protocol Version: 1.0.0
Block Size: 64 bytes
Application Start: 0x8002000
MCU type: stm32g0b1xx
Flashing '/home/biqu/klipper/out/klipper.bin'...
[ERROR:root:Flash Error
Traceback (most recent call last):
File "/home/biqu/Katapult/scripts/flashtool.py", line 555, in run
await flasher.send_file()
File "/home/biqu/Katapult/scripts/flashtool.py", line 217, in send_file
resp = await self.send_command('SEND_BLOCK', prefix + buf)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/biqu/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [SEND_BLOCK] to Can Device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/biqu/Katapult/scripts/flashtool.py", line 633, in main
loop.run_until_complete(sock.run(args.device, args.baud, fpath))
File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/biqu/Katapult/scripts/flashtool.py", line 561, in run
await flasher.finish()
File "/home/biqu/Katapult/scripts/flashtool.py", line 275, in finish
await self.send_command("COMPLETE")
File "/home/biqu/Katapult/scripts/flashtool.py", line 196, in send_command
raise FlashCanError("Error sending command [%s] to Can Device"
FlashCanError: Error sending command [COMPLETE] to Can Device
biqu@serial-ttyAMA0:~/klipper $
This is with the Git download that you gave me before. Note the “Can Device” errors seem to be still there.
Upon completion of this command the STATUS LED is still flashing (and flashes if I reset the board).