Flash erase may time out
Mark-81 opened this issue · 5 comments
dsPIC33CK512MP608
- create sample bootloader and host application
- burn bootloader
- using Microchip Unified Bootloader Host Application download the firmware
- reset the MCU and download again: all works as expected
By the way, the first time it does not erase the flash since there no valid image is found.
Instead:
- create sample bootloader and host application
- burn bootloader
- using mcbootflash download the firmware
- reset the MCU and download again:
Connecting to bootloader...
Connected
Erasing flash...
Traceback (most recent call last):
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/protocol.py", line 87, in from_bytes
return cls(*struct.unpack(cls.FORMAT, data))
struct.error: unpack requires a buffer of 12 bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/flashing.py", line 115, in flash
boot.flash(hexfile=parsed_args.file, quiet=parsed_args.quiet)
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/connection.py", line 106, in flash
self.erase_flash(self._memory_range)
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/connection.py", line 286, in erase_flash
self._erase_flash(start, end)
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/connection.py", line 300, in _erase_flash
self._send_and_receive(
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/connection.py", line 187, in _send_and_receive
response = _RESPONSE_TYPE_MAP[command.command].from_serial(self.interface)
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/protocol.py", line 96, in from_serial
return cls.from_bytes(interface.read(cls.get_size()))
File "/home/mark/.local/lib/python3.10/site-packages/mcbootflash/protocol.py", line 89, in from_bytes
raise struct.error(
struct.error: <class 'mcbootflash.protocol.Response'> expected 12 bytes, got 0.
This is reproducible on my system every time.
Found the problem: it does not suspend the timeout during flash erase! It could take some time.
Thanks for the bug report! So, if you set the timeout to a sufficiently large value it works as expected? Probably a good idea to increase the timeout during certain operations, as you suggest.
(Note to self: Could also add special exception handling when receiving b''
, since that usually indicates timeout. The current error message is not very helpful in this case.)
@Mark-81 I've released a new version, 5.1.1, which should fix this bug. Let me know if it doesn't, or if you run into any other issues!