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

PineBuds BadChecksumErrors #19

Closed
mattchrist opened this issue Apr 2, 2024 · 8 comments · Fixed by #20
Closed

PineBuds BadChecksumErrors #19

mattchrist opened this issue Apr 2, 2024 · 8 comments · Fixed by #20

Comments

@mattchrist
Copy link
Contributor

Hi, I'm getting BadChecksumErrors when trying to take a backup of my PineBuds with a release build of bestool:

> ../bestool/bestool/target/release/bestool read-image --port /dev/ttyACM0 firmware-backups/backup0.bin.bkp
Reading binary data from /dev/ttyACM0 @ 921600
2024-04-02T23:11:22.836896Z  INFO bestool::cmds::read_image: Starting loader and checking communications
2024-04-02T23:11:22.836903Z  INFO bestool::beslink::helper_sync_and_load_programmer: Syncing into bootloader
2024-04-02T23:11:22.836920Z  INFO bestool::beslink::message: Sent message type Sync [BE, 50, 0, 1, 1, EF]
2024-04-02T23:11:22.836951Z  WARN bestool::beslink::message: Bad Checksum!! BadChecksumError { failed_packet: [190, 62, 164, 31, 108, 157, 53, 117, 190, 190, 103, 202, 5, 159, 151, 130, 214, 130, 206, 74, 52, 26, 30, 242, 215, 119, 197, 227, 205, 138, 115, 101, 138, 191, 242, 79], got: 79, wanted: 100 }
2024-04-02T23:11:22.836956Z  WARN bestool::beslink::sync: Ignoring bad checksum; you might not be in programmer mode.
2024-04-02T23:11:28.917160Z  WARN bestool::beslink::message: Bad Checksum!! BadChecksumError { failed_packet: [190, 10, 43, 58, 117, 118, 101, 242, 229, 2, 14, 247, 241, 207, 251, 250, 42, 247, 71, 250, 35, 79, 175, 180, 248, 251, 59, 30, 156, 158, 198, 44, 251, 174, 5, 143, 95, 122, 140, 26, 149, 44, 104, 162, 190, 96, 253, 82, 130, 3, 206, 207, 255, 98, 36, 243, 58, 0, 0, 190, 80, 0, 3], got: 3, wanted: 37 }
2024-04-02T23:11:28.917170Z  WARN bestool::beslink::sync: Ignoring bad checksum; you might not be in programmer mode.
2024-04-02T23:11:53.057328Z  WARN bestool::beslink::message: Bad Checksum!! BadChecksumError { failed_packet: [190, 80, 0, 3, 0, 0, 1, 237], got: 237, wanted: 190 }
2024-04-02T23:11:53.057338Z  WARN bestool::beslink::sync: Ignoring bad checksum; you might not be in programmer mode.

lsusb output:

Bus 001 Device 016: ID 1a86:55da QinHeng Electronics USB Dual_Serial

Please advise how I might get this to work, or if there's any additional information I can provide that would help us figure this out.
Thanks!

@Ralim
Copy link
Owner

Ralim commented Apr 2, 2024

Hello,
So what procedure are you using to enter flashing mode?

What device are you running this on & are you running in the OpenPineBuds container or on the host machine?

The hint you might not be in programmer mode is there for a reason. As the most likely cause of this is that the device is not in the programmer mode and instead the tool is trying to interpret the console logs from the device as the programmer which naturally does not work.

For the bes2300 it will only run bootloader if the sync message is ACK'ed rapidly at boot.
This means the bes2300 has to be restarted after the bestool is running.
For PineBuds this is done by taking bud out of the case, waiting for lights to show its on, starting bestool, then putting the bud back in the case. Putting the bud back in the case triggers a reset signal, which restarts the bud and lets the bestool ACK the boot message and keep it in the bootloader.

@shymega
Copy link
Contributor

shymega commented Apr 2, 2024

I'm wondering if we should, in the refactor, halt bestool when the checksum is incorrect, and we're not entering programming mode. Food for thought...

@mattchrist
Copy link
Contributor Author

mattchrist commented Apr 2, 2024

Thanks for the response!

I'm running this directly, not from a container, using a release build I built from the main branch today.

I've been trying to enter programmer mode by:

  1. Plugging in the PineBuds case, with buds in the case
  2. Launching bestool read-image
  3. Removing the right bud, waiting for it to power on, and putting the bud back in the case

I just tried the procedure you described, and get similar checksum errors from that procedure as well.

@shymega
Copy link
Contributor

shymega commented Apr 2, 2024

Can you please post logs from the latest attempt? We need to see the logs.

Running it directly shouldn't affect the read.

What I would like to suggest is using the container, though, just so we can be sure.

@mattchrist
Copy link
Contributor Author

Logs from the latest attempt:

> ../bestool/bestool/target/release/bestool read-image --port /dev/ttyACM0 firmware-backups/backup0.bin.bkp
Reading binary data from /dev/ttyACM0 @ 921600
2024-04-02T23:53:54.253309Z  INFO bestool::cmds::read_image: Starting loader and checking communications
2024-04-02T23:53:54.253315Z  INFO bestool::beslink::helper_sync_and_load_programmer: Syncing into bootloader
2024-04-02T23:53:54.253326Z  INFO bestool::beslink::message: Sent message type Sync [BE, 50, 0, 1, 1, EF]
2024-04-02T23:54:10.515981Z  WARN bestool::beslink::message: Bad Checksum!! BadChecksumError { failed_packet: [190, 80, 0, 3, 0, 0, 1, 237], got: 237, wanted: 190 }
2024-04-02T23:54:10.515990Z  WARN bestool::beslink::sync: Ignoring bad checksum; you might not be in programmer mode.
2024-04-02T23:54:27.403181Z  WARN bestool::beslink::message: Bad Checksum!! BadChecksumError { failed_packet: [190, 80, 0, 3, 0, 0, 1, 237], got: 237, wanted: 190 }
2024-04-02T23:54:27.403192Z  WARN bestool::beslink::sync: Ignoring bad checksum; you might not be in programmer mode.
^C

@mattchrist
Copy link
Contributor Author

I get something from a build of 3ec6244.
log.txt

It ends up hanging reading from flash at some point.

2024-04-03T00:01:46.101081Z  INFO bestool::beslink::read_flash: Read 540672 bytes out of 1048576  (51%) from flash
2024-04-03T00:01:46.101130Z  INFO bestool::beslink::message: Sent message type FlashRead [BE, 3, 5, 8, 0, 40, 18, 3C, 0, 40, 0, 0, 5D]

@Ralim
Copy link
Owner

Ralim commented Apr 3, 2024

The hang is normal and means you hit the watchdog and have to retry. (we are using a debugging backdoor to read flash, its not officially supported).
I'' have to look into #16 as that is probably somehow breaking your instance :| not suuper sure how, will try to replicate on a dev board.

@mattchrist
Copy link
Contributor Author

Using that previous commit I was able to backup and flash firmware successfully. I had to try several times to get a backup.

Let me know if you have difficulties replicating the issue - I'm happy to try stuff out on my end and report the results.

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

Successfully merging a pull request may close this issue.

3 participants