Skip to content

Instantly share code, notes, and snippets.

@TiNredmc
Last active February 2, 2022 07:27
Show Gist options
  • Save TiNredmc/a31cd8c79aeb0ec603c0e5275fac7e7d to your computer and use it in GitHub Desktop.
Save TiNredmc/a31cd8c79aeb0ec603c0e5275fac7e7d to your computer and use it in GitHub Desktop.
Unseal the Fuel gauge protection of BQ27541/BQ27542 via i2ctransfer on Linux
#!/bin/bash
# Simple Script to Fully Unseal the BQ27541 or BQ27542
# Coded by TinLethax 2021/06/02 +7
# structure [Control_command0x00][lower byte][higher byte]
# Unseal first by writing 0x0414 (Sending Big endian )
i2ctransfer -y -f -a 0 w3@0x55 0x00 0x14 0x04
# Then writing 0x3672 (again, Big endian first)
i2ctransfer -y -f -a 0 w3@0x55 0x00 0x72 0x36
sleep 1
#We successfully unseal but we haven't clear FAS bit yet (Full access Sealed)
#We need to TOTALLY UNSEAL the chip by
i2ctransfer -y -f -a 0 w3@0x55 0x00 0xFF 0xFF
i2ctransfer -y -f -a 0 w3@0x55 0x00 0xFF 0xFF
sleep 1
#ensure that our higher byte of control status indicate that Seal and FAS is disabled
#By sending control status subcommand
i2ctransfer -y -f 0 w3@0x55 0x00 0x00 0x00
i2ctransfer -y -f 0 w1@0x55 0x00 r2
echo "on higher byte (second printed byte) must have bit 6 and 5 set at 0"
echo "mine i2ctransfer output read as 0xXX and 0x00 which is fully unsealed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment