swharden / FTFlash

A tool for reading and writing data in SPI flash memory chips using a FT232H
https://swharden.com/blog/2023-08-24-ft232h-spi-flash/
MIT License
12 stars 3 forks source link

`WaitForNotBusy()` hangs forever if the chip does not respond #1

Closed alex-kerner-ext-orion closed 1 year ago

alex-kerner-ext-orion commented 1 year ago

Program freeze if: chip is connected incorrectly, chip is dead, bad contact of one of the wires.

This is due to the fact that the 0xFF value is read when polling the chip status. This value is interpreted as "the chip is busy with some operation", and the program starts waiting for the chip in an infinite loop. We need to fix the code, if 0xFF is read several times in a row, it is obvious that this is a chip fault and we need to exit with an error code (throw an exception).

Problem location: https://github.com/swharden/FTFlash/blob/fed7a653a8320a8dd21cde03c760ea92f17a90a2/src/FTFlash/ProgForm.cs#L54

swharden commented 1 year ago

Thanks for reporting this @alex-kerner-ext-orion! I'll add a feature that cancels the attempt and launches a pop-up error message if the WaitForNotBusy() takes more than 1 second to complete

swharden commented 1 year ago

The next release will do something like this

image