OctoPrint / OctoPrint-FirmwareUpdater

OctoPrint plugin for flashing pre-compiled firmware images to a 3D printer.
https://plugins.octoprint.org/plugins/firmwareupdater/
GNU Affero General Public License v3.0
352 stars 76 forks source link

Marlinbft not working with STM32 32-bit MCUs after first flash #352

Closed caffeineflo closed 1 year ago

caffeineflo commented 1 year ago

Hardware Setup Mechanics are essentially an Ender 3v2 w/ BTT SKR Mini E3 v3.0 board SW latest Octoprint, running Marlin with self compiled bugfix-2.1.x branch

Describe the problem Hi! I'm hoping you can provide some insight into my issue and wether or not it's configuration/user error or something that can be enhanced!

I'm trying to flash my STM32G0B1RE_btt_xfer aka SKR Mini E3 v3.0 via marlinbft to avoid having to mount the SD card and patch the USB mount through to my octoprint docker instance.

Marlin FW support has been compiled in and the marlinbft transfer seems to succeed (running the same config essentially as I do on another machine where everything works perfectly fine).

When I try to flash my binary on this machine with octoprint, I always get an error message saying "Flashing Failed: Firmware update failed".

I've checked the logs as well as the SD and after playing around with different timeout, reset and post-flash configs what I'm seeing seems to be this:

First time/empty SD When my SD card is empty, marlinbft transfers the file correctly, board gets reset and the firmware update succeeds despite the plugin reporting that it failed. The SD card now has a file named "FIRMWARE.CUR" with a creation date of 1/1/2000 00:00

Any consecutive attempts to flash the printer (SD Card still contains the FRIMWARE.CUR: Board gets successfully reset with M997, but the FW isn't being update. Plugin reports error.

Now I'm wondering wether this is a user/configuration error on my side or if this is something that could be worked around with some enhancement (happy to make a PR)? It sounds to me like the board doesn't update because of the existing FIRMWARE.CUR file, but also the plugin doesn't like reconnecting to the board and then recognize the update has succeeded.

Any way around this? Thanks!

Log Files Added mostly clean logfiles here octoprint-logs.zip

Additional context n/a

benlye commented 1 year ago

From the logs it looks like you need to increase the restart timeout option from 20s to 30s - that might stop the 'Flashing failed' message.

I can't explain why the board isn't taking the update. Don't have one of these; never seen one before. How is it supposed to be updated if you were doing it manually? Do you need to use unique filenames? Some printers will only accept a firmware update if the newer bin file has a name that is different from the previous bin file.

caffeineflo commented 1 year ago

Hey @benlye !

Thanks for your reply!

I did some more testing and digging today. Here are my answers:

How is it supposed to be updated if you were doing it manually? Do you need to use unique filenames? No special filenaming needed, just firmware.bin (no date tag either) - reset the board and once the flashing has succeeded a firmware.cur gets created with the current firmware (I guess cur stands for current).

From the logs it looks like you need to increase the restart timeout option from 20s to 30s - that might stop the 'Flashing failed' message. I thought I had tried that, but apparently not good enough. After some testing I can see that the board flashes correctly with a 30s restart time. The plugin will still say Flashing has failed though (despite successful flashing). So I guess the comparison or success/!success isn't working correctly.

I can provide more logs if needed, or if you have an idea how to fix it, I'm happy to provide a PR?

benlye commented 1 year ago

The plugin has no way to know if the update was really successful or not. It assesses two criteria:

  1. Did the file copy succeed?
  2. Did the printer reset within the configured time?

If the file copy succeeds and the printer resets, then most likely the firmware update is actually succeeding no matter what reset timeout options are set.

If you want to get rid of the flashing failed messages, you just need to find the timeout settings that are appropriate for your printer.

caffeineflo commented 1 year ago

If you want to get rid of the flashing failed messages, you just need to find the timeout settings that are appropriate for your printer.

I tried two updates just now.

  1. 300s Timeout setting -> Still getting flash failed
  2. 300s Timeout + 30s wait after connect -> Still getting flash failed

I'm happy to live with the notification, but would still be curious on how to fix this or why it's failing.

benlye commented 1 year ago

Need to see the logs...

caffeineflo commented 1 year ago

octoprint-logs (1).zip

New logs after a clean and restart. Verbose logging turned on. Manually verified FW update succeeds!

Thanks!

Edit: Here's the config:

Screenshot 2023-09-22 at 15 21 31 Screenshot 2023-09-22 at 15 21 25
benlye commented 1 year ago

What happens if you uncheck 'Use alternative reset'?

If that doesn't make any difference then 'Don't wait for reset' should solve it.

caffeineflo commented 1 year ago

If I uncheck "User alternative reset" the board won't get reset and therefore the update won't happen.

"Don't wait for reset" is obviously disabled for the same reason.

I think this is only a small inconvenience and I'm grateful for your replies. I'm going to close this issue, at least it's documented for the next person now! Thanks

github-actions[bot] commented 1 year ago

This issue has been automatically locked because there was no further activity after it was closed. Please open a new issue for any related problems.