Do you have equipment to analyze the signals to the flash chip? Ideally a logic analyzer, but a 20MHz scope can work too.
That's ideally. In reality, several things are absent.
There's no other way to debug this code. :\
Except to rev-eng the code, original flasher uses. But this isn't suitable for me (too much time is required for analysis).