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
353 stars 76 forks source link

Unable to update Prusa MK3S over UART serial connection. #306

Closed WhiterRice closed 2 years ago

WhiterRice commented 2 years ago

Hardware Setup Raspberry Pi Zero 2 W w/ Octoprint connected via UART Pins (5V, GND, TXD, RXD) for serial communication to Einsy Rambo on Prusa MK3S

Raspberry pi zero 2 w has serial connection enabled without shell login.

Source: https://help.prusa3d.com/en/article/prusaprint-rpi-zero-and-octoprint_2180/

Describe the problem When attempting to update firmware timeout communicating with programmer occurs. Is this a limitation of the uart serial connection? Is there a way to configure it to work?

Log Files octoprint.log 2022-03-05 14:48:29,421 - octoprint.plugins.tracking - INFO - Sent tracking event webui_load, payload: {'browser_name': 'Firefox', 'browser_version': '97.0', 'os_name': 'Windows', 'os_version': '10'} 2022-03-05 14:48:34,299 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Detecting serial connection" 2022-03-05 14:48:34,339 - octoprint.util.comm - INFO - Serial detection: Performing autodetection with 7 port/baudrate candidates: /dev/ttyS0@115200, /dev/ttyS0@250000, /dev/ttyS0@230400, /dev/ttyS0@57600, /dev/ttyS0@38400, /dev/ttyS0@19200, /dev/ttyS0@9600 2022-03-05 14:48:34,339 - octoprint.util.comm - INFO - Serial detection: Trying port /dev/ttyS0, baudrate 115200 2022-03-05 14:48:34,340 - octoprint.util.comm - INFO - Connecting to port /dev/ttyS0, baudrate 115200 2022-03-05 14:48:34,360 - octoprint.util.comm - INFO - Serial detection: Handshake attempt #1 with timeout 2.0s 2022-03-05 14:48:34,364 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0 2022-03-05 14:48:34,376 - octoprint.util.comm - INFO - Changing monitoring state from "Detecting serial connection" to "Operational" 2022-03-05 14:48:34,386 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0 2022-03-05 14:48:34,390 - octoprint.plugins.firmwareupdater - INFO - Got CONNECTED event 2022-03-05 14:48:34,402 - octoprint.plugins.firmwareupdater - INFO - Run postflash flag is not set 2022-03-05 14:48:34,500 - octoprint.util.comm - INFO - Printer reports firmware name "Prusa-Firmware 3.10.0 based on Marlin" 2022-03-05 14:48:34,501 - octoprint.util.comm - INFO - Detected Prusa firmware, enabling relevant features for issue free communication 2022-03-05 14:48:34,503 - octoprint.util.comm - INFO - Firmware states that it supports temperature autoreporting 2022-03-05 14:48:35,043 - octoprint.plugins.tracking - INFO - Sent tracking event printer_connected, payload: {'firmware_name': 'Prusa-Firmware 3.10.0 based on Marlin', 'printer_port': 'AUTO', 'printer_baudrate': 0} 2022-03-05 14:48:36,608 - octoprint.util.comm - INFO - Externally triggered heatup detected 2022-03-05 14:48:36,612 - octoprint.util.comm - INFO - Printer seems to support the busy protocol, will adjust timeouts and set busy interval accordingly 2022-03-05 14:48:38,842 - octoprint.util.comm - INFO - Telling the printer to set the busy interval to our "communicationBusy" timeout - 1s = 2s 2022-03-05 14:49:22,972 - octoprint.plugins.firmwareupdater - INFO - Firmware update profile index: 0 2022-03-05 14:49:22,978 - octoprint.plugins.firmwareupdater - INFO - Firmware update profile name: Default 2022-03-05 14:49:22,979 - octoprint.plugins.firmwareupdater - INFO - Printer port: /dev/ttyS0 2022-03-05 14:49:22,985 - octoprint.plugins.firmwareupdater - INFO - Flash method: avrdude 2022-03-05 14:49:23,012 - octoprint.plugins.firmwareupdater - INFO - Firmware update started 2022-03-05 14:49:23,013 - octoprint.plugins.firmwareupdater - INFO - Disconnecting from printer 2022-03-05 14:49:23,073 - octoprint.util.comm - INFO - Changing monitoring state from "Operational" to "Offline" 2022-03-05 14:49:23,082 - octoprint.plugins.action_command_notification - INFO - Notifications cleared 2022-03-05 14:49:23,117 - octoprint.plugins.firmwareupdater - INFO - Running '/usr/bin/avrdude -v -q -p m2560 -c wiring -P /dev/ttyS0 -D -U flash:w:/tmp/tmpu9nshe3s:i' in /usr/bin 2022-03-05 14:49:46,214 - octoprint.plugins.firmwareupdater - ERROR - Flashing failed. Timeout communicating with programmer. 2022-03-05 14:49:46,225 - octoprint.plugins.firmwareupdater - INFO - Reconnecting to printer: port=/dev/ttyS0, baudrate=115200, profile={'axes': {'e': {'inverted': False, 'speed': 300}, 'x': {'inverted': False, 'speed': 6000}, 'y': {'inverted': False, 'speed': 6000}, 'z': {'inverted': False, 'speed': 200}}, 'color': 'default', 'extruder': {'count': 1, 'nozzleDiameter': 0.4, 'offsets': [(0.0, 0.0)], 'sharedNozzle': False}, 'heatedBed': True, 'heatedChamber': False, 'id': '_default', 'model': 'Prusa MK3S', 'name': 'MK3S', 'volume': {'custom_box': {'x_max': 250.0, 'x_min': 0.0, 'y_max': 210.0, 'y_min': -4.0, 'z_max': 210.0, 'z_min': 0.0}, 'depth': 210.0, 'formFactor': 'rectangular', 'height': 210.0, 'origin': 'lowerleft', 'width': 250.0}} 2022-03-05 14:49:46,330 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Opening serial connection" 2022-03-05 14:49:46,332 - octoprint.util.comm - INFO - Connecting to port /dev/ttyS0, baudrate 115200 2022-03-05 14:49:46,350 - octoprint.util.comm - INFO - Changing monitoring state from "Opening serial connection" to "Connecting"

~/.octoprint/logs/plugin_firmwareupdater_console.log 2022-03-05 14:49:23,122 /usr/bin/avrdude -v -q -p m2560 -c wiring -P /dev/ttyS0 -D -U flash:w:/tmp/tmpu9nshe3s:i 2022-03-05 14:49:23,752 > 2022-03-05 14:49:23,753 > avrdude: Version 6.3-20171130 2022-03-05 14:49:23,753 > Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ 2022-03-05 14:49:23,754 > Copyright (c) 2007-2014 Joerg Wunsch 2022-03-05 14:49:23,754 > 2022-03-05 14:49:23,755 > System wide configuration file is "/etc/avrdude.conf" 2022-03-05 14:49:23,755 > User configuration file is "/home/pi/.avrduderc" 2022-03-05 14:49:23,756 > User configuration file does not exist or is not a regular file, skipping 2022-03-05 14:49:23,756 > 2022-03-05 14:49:23,757 > Using Port : /dev/ttyS0 2022-03-05 14:49:23,757 > Using Programmer : wiring 2022-03-05 14:49:23,758 > 2022-03-05 14:49:27,285 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:27,287 > 2022-03-05 14:49:31,480 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:31,481 > 2022-03-05 14:49:33,577 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:33,578 > 2022-03-05 14:49:37,772 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:37,773 > 2022-03-05 14:49:42,012 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:42,014 > 2022-03-05 14:49:46,207 > avrdude: stk500v2_ReceiveMessage(): timeout 2022-03-05 14:49:46,209 > avrdude: stk500v2_getsync(): timeout communicating with programmer 2022-03-05 14:49:46,210 > 2022-03-05 14:49:46,211 > avrdude done. Thank you.

Additional context I migrated my microsd card from the pi zero 2 W to a pi 3 and connected to the printer of USB. After changing the serial connection from /dev/ttyS0 to /dev/ttyACM0 I was able to flash the firmware. So the avrdude setup and firmware are valid.

~/.octoprint/logs/plugin_firmwareupdater_console.log 2022-03-05 17:20:45,345 /usr/bin/avrdude -v -q -p m2560 -c wiring -P /dev/ttyACM0 -D -U flash:w:/tmp/tmp8t0g_qkk:i 2022-03-05 17:20:46,459 > 2022-03-05 17:20:46,460 > avrdude: Version 6.3-20171130 2022-03-05 17:20:46,461 > Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ 2022-03-05 17:20:46,462 > Copyright (c) 2007-2014 Joerg Wunsch 2022-03-05 17:20:46,463 > 2022-03-05 17:20:46,464 > System wide configuration file is "/etc/avrdude.conf" 2022-03-05 17:20:46,465 > User configuration file is "/home/pi/.avrduderc" 2022-03-05 17:20:46,465 > User configuration file does not exist or is not a regular file, skipping 2022-03-05 17:20:46,466 > 2022-03-05 17:20:46,468 > Using Port : /dev/ttyACM0 2022-03-05 17:20:46,468 > Using Programmer : wiring 2022-03-05 17:20:46,469 > AVR Part : ATmega2560 2022-03-05 17:20:46,470 > Chip Erase delay : 9000 us 2022-03-05 17:20:46,471 > PAGEL : PD7 2022-03-05 17:20:46,472 > BS2 : PA0 2022-03-05 17:20:46,473 > RESET disposition : dedicated 2022-03-05 17:20:46,474 > RETRY pulse : SCK 2022-03-05 17:20:46,474 > serial program mode : yes 2022-03-05 17:20:46,475 > parallel program mode : yes 2022-03-05 17:20:46,476 > Timeout : 200 2022-03-05 17:20:46,477 > StabDelay : 100 2022-03-05 17:20:46,478 > CmdexeDelay : 25 2022-03-05 17:20:46,479 > SyncLoops : 32 2022-03-05 17:20:46,480 > ByteDelay : 0 2022-03-05 17:20:46,481 > PollIndex : 3 2022-03-05 17:20:46,482 > PollValue : 0x53 2022-03-05 17:20:46,483 > Memory Detail : 2022-03-05 17:20:46,483 > 2022-03-05 17:20:46,484 > Block Poll Page Polled 2022-03-05 17:20:46,485 > Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack 2022-03-05 17:20:46,486 > ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- 2022-03-05 17:20:46,487 > eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00 2022-03-05 17:20:46,488 > flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00 2022-03-05 17:20:46,489 > lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 2022-03-05 17:20:46,490 > hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 2022-03-05 17:20:46,491 > efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 2022-03-05 17:20:46,491 > lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00 2022-03-05 17:20:46,492 > calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00 2022-03-05 17:20:46,493 > signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00 2022-03-05 17:20:46,494 > 2022-03-05 17:20:46,495 > Programmer Type : Wiring 2022-03-05 17:20:46,496 > Description : Wiring 2022-03-05 17:20:46,497 > Programmer Model: AVRISP 2022-03-05 17:20:46,497 > Hardware Version: 15 2022-03-05 17:20:46,499 > Firmware Version Master : 2.10 2022-03-05 17:20:46,500 > Vtarget : 0.0 V 2022-03-05 17:20:46,500 > SCK period : 0.1 us 2022-03-05 17:20:46,501 > 2022-03-05 17:20:46,502 > avrdude: AVR device initialized and ready to accept instructions 2022-03-05 17:20:46,503 > avrdude: Device signature = 0x1e9801 (probably m2560) 2022-03-05 17:20:46,504 > avrdude: reading input file "/tmp/tmp8t0g_qkk" 2022-03-05 17:20:46,505 > avrdude: writing flash (251278 bytes): 2022-03-05 17:20:46,506 > 2022-03-05 17:21:30,838 > avrdude: 251278 bytes of flash written 2022-03-05 17:21:30,838 > avrdude: verifying flash memory against /tmp/tmp8t0g_qkk: 2022-03-05 17:21:30,839 > avrdude: load data flash data from input file /tmp/tmp8t0g_qkk: 2022-03-05 17:21:30,839 > avrdude: input file /tmp/tmp8t0g_qkk contains 251278 bytes 2022-03-05 17:21:30,840 > avrdude: reading on-chip flash data: 2022-03-05 17:21:30,840 > 2022-03-05 17:22:03,046 > avrdude: verifying ... 2022-03-05 17:22:03,048 > avrdude: 251278 bytes of flash verified 2022-03-05 17:22:03,049 > 2022-03-05 17:22:03,050 > avrdude done. Thank you. 2022-03-05 17:22:03,051 > 2022-03-05 17:22:03,052 > 2022-03-05 17:22:03,058 Flashing successful.

WhiterRice commented 2 years ago

Seems that uart cannot enter the bootloader without triggering a reset manually; or wiring a gpio pin to reset and scripting it when avrdude starts..

https://old.reddit.com/r/prusa3d/comments/gnn3ng/can_rambo_board_firmware_be_updated_via_the_uart/

WhiterRice commented 2 years ago

Re-opening as I'm in the process of discovering how to reset the board using the rpi. It seems that I may be able to leverage this script to reset the board using gpio22 from the rpi, https://github.com/deanmao/avrdude-rpi

https://forum.prusaprinters.org/wp-content/uploads/2019/11/Einsy_Rambo_J19_Header-2.png

https://learn.sparkfun.com/tutorials/raspberry-gpio/gpio-pinout

WhiterRice commented 2 years ago

I have been able to reset the printer with https://github.com/deanmao/avrdude-rpi

In autoreset[15] set, pin = 15

I am still receiving timeouts, as if the bootloader is not ready.

As this is not related to firmware updater. I will close this issue and comment my updates.

github-actions[bot] commented 2 years 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.