Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to verify once the size is big #17

Closed
fabiodl opened this issue Apr 16, 2021 · 8 comments
Closed

Fails to verify once the size is big #17

fabiodl opened this issue Apr 16, 2021 · 8 comments

Comments

@fabiodl
Copy link

fabiodl commented Apr 16, 2021

In several projects, the tool works flawlessly for small files. Once I reach a certain size, it stars giving this kind of error

`python3 -m ch55xtool -f build/fat32.bin -r

Found CH559.

BTVER: V2.40.

Failed to verify firmware of CH55x.`

I attach a CH559 binary file that fails. In all the cases, the official programmer works.

fat32.zip

@MarsTechHAN
Copy link
Owner

Sorry I got so busy recently. I will take a look.

@fabiodl
Copy link
Author

fabiodl commented Nov 25, 2021

Thank you! let me know if you need other binaries that fail.

@frank-zago
Copy link

The problem is likely with the erase command. It only erases 8 KB. The length needs to be adjusted to the size of the firmware being flashed.

The 0x08 is the size. Change it to 0x10, and it should work.
ERASE_CHIP_CMD_V2 = [0xa4, 0x01, 0x00, 0x08]

@fabiodl
Copy link
Author

fabiodl commented Jan 7, 2022

Thanks, that seems to fix the issue!

@Pe3ucTop
Copy link
Contributor

Latest original software pass sizes in 32 bits also.
For my 192kb chip erase original soft send :
[0xA4, 0x04, 0x00, 0xC0, 0x00, 0x00, 0x00]
0xA4 - erase
0x0004 - command payload size = 4 byte = 32 bit
0x000000c0 = 192 = so 192 1k pages to erase

@frank-zago
Copy link

Indeed. I've also used 4 bytes for that command, even on a CH551 with a 2.3.1 bootloader. I think the bootloader is too small to have extra checks.

@MarsTechHAN
Copy link
Owner

The problem is likely with the erase command. It only erases 8 KB. The length needs to be adjusted to the size of the firmware being flashed.

The 0x08 is the size. Change it to 0x10, and it should work. ERASE_CHIP_CMD_V2 = [0xa4, 0x01, 0x00, 0x08]

See that... I should really fix it. Welcome PR for that :p

@Pe3ucTop
Copy link
Contributor

Sorry, your latest commit has wrong divisor for erase size calculation !

erase_size = math.ceil(binary_size/0x1000) & 0xff
but should be :
/ 1024 or / 0x400
because it is in 1k pages

karlp pushed a commit to karlp/ch552tool that referenced this issue Mar 19, 2022
…d file,

provided the `CH55X_IC_REF` entry for the device has a key: `erase_required_pages`
with the value of True

Tested-by: Karl Palsson <[email protected]>
Reviewed-by: Karl Palsson <[email protected]>

I've (karlp) actually pretty heavily modified this, to be basically equivalent
to what was already introduced in 2bd501c via MarsTechHAN#17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants