Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: flash_can.py support for programmatically entering the bootloader via USB. #71

Closed
miklschmidt opened this issue Apr 5, 2023 · 6 comments

Comments

@miklschmidt
Copy link

In the readme.md it states:

Enter the bootloader. This will occur automatically if no program is detected. If you built CanBoot with an alternative method of entry you may use that. If upgrading from a currently flashed version of Klipper the flash_can.py script will command the device to enter the bootloader (currently for CAN devices only).

Is it possible and planned to implement this for USB as well? We've had quite a few bootloader related issues out of the box on some boards lately, so I would love to add CanBoot support to RatOS to facilitate recovery from those situations, and maybe move over to CanBoot completely depending on how that goes.

@Laikulo
Copy link

Laikulo commented Sep 7, 2023

Klipper supports this by sending the string \x1c Request Serial Bootloader!! ~ directly over serial. It actually needs to fail parsing as a command for this to work. It also needs to be it's own "block", so if the device is in use by other things, it may not be recognized. I may try to work up a PR for this later this week.

Klipper ref: https://github.com/Klipper3d/klipper/blob/5f990f93d533247d3a675e8c423280f4333ad8ce/src/generic/serial_irq.c#L83

@Laikulo
Copy link

Laikulo commented Sep 16, 2023

While testing out a PR for this, it looks like Klipper only supported this on real serial ports. I've opened a PR to add it to USB-CDC virtual serial ports.
Klipper3d/klipper#6340

@Arksine
Copy link
Owner

Arksine commented Sep 16, 2023

FWIW, Klipper already has method for requesting the bootloader over CDC-ACM connections, and it has a script, flash_usb.py, that requests the bootloader. Presumably it also has a script for requesting the bootloader over UART connections, however I'm unsure.

Application specific bootloader requests probably should not exist in flashtool.py, but rather in the application repository itself, since the application defines exactly how the bootloader should be requested. The CAN bootloader request is a bit unique considering there are relatively few CAN bootloaders available. In this case Katapult defines how the bootloader is requested and applications are expected to implement it.

@Laikulo
Copy link

Laikulo commented Sep 18, 2023

Ah, I was not aware that klipper actually implemented that in CDC, I've only had success with that method on arduino/FTDI like systems.

@miklschmidt
Copy link
Author

miklschmidt commented Apr 13, 2024

I just realized my dumbass didn't really understand how this works. Am i correct in assuming that klipper will boot into katapult (configured for USB communication) when attempting to flash with make flash FLASH_DEVICE=whatever?

In that case this issue shouldn't have been opened in the first place, just needs a small clarification in the docs, so people like me won't think it doesn't work 😂

@miklschmidt
Copy link
Author

I just verified that it does in fact work! And it was almost too easy. You may have just made my week without doing anything @Arksine. Closing! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants