hexeguitar / CH55x_python_flasher

Python based flash/verify tool for the CH55x MCUs
GNU General Public License v3.0
15 stars 3 forks source link

Fail to write larger files #3

Closed toyoshim closed 3 years ago

toyoshim commented 3 years ago

It worked really fine, but once the file size gets over around 30kB, it starts failing on verification step. I confirmed that the official tool can write the same binary without any error. Also, the verification error is real. When I see this error, the device doesn't run correctly.

Here is a log.

Found CH559
Bootloader version: 2.31
Flash Erased
Filesize: 31278 bytes
[====================] 100% Writing success
[=================== ] 95% ---------------------------------------------------------------------------------
Error: Verify Failed at address 29736
---------------------------------------------------------------------------------
toyoshim commented 3 years ago

I'm quickly looking the source, and find that device_erase_size is set to 0x1d for CH559. Is this the block count to erase flash ROM before writing new firmware?

Block size is 1024, and 1024 * 0x1d = 29696.

So, it can explain why writing starts failing when file size gets over around 30kB.

toyoshim commented 3 years ago

OK, I can fix the issue by setting it to 60 for CH559. I can send a pull request.

toyoshim commented 3 years ago

https://github.com/hexeguitar/CH55x_python_flasher/pull/4

hexeguitar commented 3 years ago

I have put all the flash related definitions into a dictionary, will be much easier to make changes and add more supported MCUs. Tested the code with: CH551, bt. v1.1 CH552, bt. v2.4 CH552, bt. v2.3 CH559, bt. v2.3 All passed using various bin file lengths. Also added a script installing the udev rules on linux. Hope everything works fine. Closing the issue.