Comments (5)
Well, i recently got one of those cheap 8 channel logic analyzers...turns out, they are based on the fx2...the i2c pins are not broken out, but that eeprom is a nice place to solder wires to:
so thanks to smbusb_bootstrap i finally managed to get dumps of the firmware and the eeprom and could compare them to the results of some scripts i had written some time ago, and i could fix some errors.
I think i managed to dump both firmware and eeprom now via /dev/i2c
`#!/bin/bash
max=18416
for ((i=16384;i<=max;))
do
y=$(printf "%#.4x\n" $i)
let "i+=32"
sudo i2cset -y 1 0x0b 0x09 $y w
sleep 0.01
r=$(sudo i2ctransfer -y 1 w1@0x0b 0x0c r33)
echo $r | cut -c6-
sleep 0.01
done`
(edit: not sure what i smoked yesterday, but it took me way to long to realize that 20 actually means 0x20, aka 32...worked anyway, but i fixed this now and it reads the 32 bytes it should)
this for example should dump the content of the eeprom.
The output format is obviously different from what your tools produce, but i guess when doing the writes with i2ctransfer we'll need the data like that anyway.
I think i'll try these days if i first can finally fix my battery using your tools and then maybe try to write to the chip with /dev/i2c.
By the way, has anybody tried single block writes instead of writing the whole thing? iirc, the datasheet suggests that this should be possible? Oh, and for those who don't want to use the display data channel, but own a raspberry pi, this should work on a pi too.
from smbusb.
Responding more to the title of the issue than the actual discussion - it so happens that I made a tool which uses /dev/i2c.
It actually uses 'smbus2' Python module, and that Python module opens the device and does ioctl calls on it.
The tool:
https://github.com/o-gs/dji-firmware-tools#comm_sbs_bqctrlpy
Usage example:
https://www.youtube.com/watch?v=P5PNOO2GebY
from smbusb.
Your description of the erase->write->exit process is correct.
https://www.ti.com/lit/ug/sluu187/sluu187.pdf might help with commands.
Someone wrote tools for /dev/i2c here: https://github.com/noolex/lenovo_battery_repair
Multi interface support would be good to have but I won't be able to work on it any time soon unfortunately.
from smbusb.
Ah, that's nice, that bat_hack script even does the math. :) I guess we can call this issue resolved then.
Unfortunately my battery stopped talking to me, so i can't test right now. (thought about buying a chip on aliexpress to keep playing, this broken battery has had a huge educational value for me so far...)
Another interesting project i stumbled upon these days was this: https://github.com/iam4722202468/ThinkpadBattery which is basically a smart battery emulator for arduino platforms. He simply uses an attiny85 to tell the laptop what it wants to hear. Tried this with an arduino nano clone, works like a charm, and also might be pretty practical for testing real batteries i guess.
And last but not least, for those of you who are interested in the firmware, there is this guy from australia who wrote a ghidra plugin: https://github.com/pelrun/ghidra-cr816
which is still way above my capabilities, but i hope to make use of it one day.
Anyway, thank you very much for you work, i have learned a thing or two from reading your code, and finally got a backup of both firmware and eeprom data.
from smbusb.
that looks like a lot of work, really nice!
i like that sbs_read_firmware_version_bq_sealed function! :)
from smbusb.
Related Issues (20)
- writing program to bq8030 doesn't work HOT 9
- Add support for CP2112 development board HOT 2
- Error Opening SMBusb: libusb error -11 HOT 8
- Eeprom verification bypassed? HOT 3
- Firmware seems unstable, help? HOT 6
- I am using degilent jtag usb cable,can it be supportted? HOT 7
- armv7l/gcc - Build failed HOT 2
- connection issue - smbusb firmware error HOT 2
- Can we use this solution to reset a laptop battery? HOT 3
- TODO: Support for newer sdcc versions HOT 3
- Add xxdi as an alternative to xxd
- Python bindings compatible with 'smbus' module HOT 1
- Can't complete make command HOT 4
- Test command write
- can this be used with ch341a chip i2c mode to read smbus on battery? thx
- possible virus attack?
- Can't compile from sources
- PLEASE RELEASE
- Fix for SDCC 4.2.3 (makes the firmware compile with SDCC at least up to current SDCC 4.4.0)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smbusb.