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

Fail to flash CH552 because of isp_key checksum mismatch #10

Open
elfmimi opened this issue Aug 10, 2022 · 3 comments
Open

Fail to flash CH552 because of isp_key checksum mismatch #10

elfmimi opened this issue Aug 10, 2022 · 3 comments
Assignees

Comments

@elfmimi
Copy link

elfmimi commented Aug 10, 2022

Thanks for sharing this promising work of yours.

In short, with CH551/CH552/CH554/CH559, checksum have to be calculated from the first 4 bytes of chip's UID.

it seem 'device_type == 0x11' is the condition for when it should be handled specially.

and, for just in case, modified calculation will look like this.

        let checksum = self
            .chip_uid[0..4]
            .iter()
            .fold(0_u8, |acc, &x| acc.wrapping_add(x));

I only tested with CH552 , BTVER = v2.4.0 .

@andelf
Copy link
Contributor

andelf commented Aug 10, 2022

Thanks for your report. I have a CH559. Will check this.

@elfmimi
Copy link
Author

elfmimi commented Aug 30, 2022

I tested another CH552 which has bootloader v2.31 .
This one reports its Chip UID as 7e-4a-45-43-77-7f-af-fb .
Luckily or unluckily isp_key's checksum matches whether using 4 bytes or 8 bytes for calculation.
Using all 8 bytes of UID , it will succeed to flash but it won't run correctly. because of wrongly calculated isp_key .
Using first 4 bytes of UID , it will also succeed to flash and in this case it will run correctly.

@elfmimi
Copy link
Author

elfmimi commented Aug 30, 2022

Looking at #14 ,
it seems bootloader v2.50 decided to report UID with its latter part filled with zeros.
so that isp_key won't get wrongly calculated.

@andelf andelf self-assigned this Nov 13, 2022
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

2 participants