Re: Flashing Senoko PVT board

pelrun wrote:

The charger IC is U200, which is the one you soldered backwards initially, isn't it? Perhaps it's damaged and needs replacing.

That's probably it... I  just touched up the soldering so it looks perfect, and still no dice. Shame... I just got my battery pack spot-welded together.

Fortunately Digikey usually gets things here pretty fast.

The funny thing is that I was looking at the schematic, and thought that couldn't possibly be the chip, since I didn't see I2C pins. Turns out I was looking at U301.

Thanks for the quick response!

Re: Flashing Senoko PVT board

Yes.

There is a bug in the I2C code somewhere that I never managed to track down.  It manifests itself as a system lockup, and if I had SWD I probably could track it down easier.  The problem happens when the bus is in use and doesn't come ready after several seconds.

Under normal circumstances this never happens.  But in your case, the charger IC never responds, which is the same as the bus never coming ready.  You can tell this is the case because the manufacturer is all zeroes.

It also looks like you're running off battery, as the current draw is negative.  That's why charging isn't allowed, and why the target current is zero.

Still, it must've worked at some point, since your gas gauge woke up.  It's probably a cold solder connection somewhere along the I2C lines.

Re: Flashing Senoko PVT board

OK, I'm back at my own place and ready to work on this again.
I get the following with four (real, ish) cells wired up, the TX pins on U302 shorted appropriately, and in general things wired up "properly" so the chip should be happy:-

ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         off
Discharge FET:      off
State:              normal discharge
Time until full:    65535 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             69%
Max capacity:       2866 mAh
Design capacity:    4400 mAh
Temperature:        25.24455 C
Voltage:            15482 mV
Current:            -4 mA
Average current:    -1 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    4 cells
Cell 1 voltage:     3819 mV
Cell 2 voltage:     3875 mV
Cell 3 voltage:     3993 mV
Cell 4 voltage:     3796 mV
Charge status:      0x0
    Charging allowed?   yes
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    no
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     no
    Pulse charging?     no
    Pulse disable CHG?  no
    Cell balancing?     no
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      no
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE CHARGE ALARM
    TERMINATE DISCHARGE ALARM
Charge state:
    Battery initialized
    Battery discharging/relaxing
No errors detected
No safety alerts
No safety status messages


No amount of "gg cells 3", "gg capacity 3 5000" will make it write to the chip well enough to update the output of the stats command. Also, setting the charger directly doesn't seem to work very well either:-

ch> chg
Charger information:
        Charge thread:    running
        Manufacturer ID:  0x0040
        Device ID:        0x0007
        Current:          0 mA
        Voltage:          0 mV
        Input:            3840 mA
ch> chg set 1000 16000 4000
Setting charger: 1000mA @ 16000mV (input: 4000mA)... Ok
ch> chg
Charger information:
        Charge thread:    running
        Manufacturer ID:  0x0040
        Device ID:        0x0007
        Current:          896 mA
        Voltage:          16000 mV
        Input:            3840 mA


---I wait 10 seconds here---

ch> chg
Charger information:
        Charge thread:    running
        Manufacturer ID:  0x0040
        Device ID:        0x0007
        Current:          0 mA
        Voltage:          0 mV
        Input:            3840 mA

At the end of the process the stats output is the same as at the start. The only thing I see of note is the stuff under "Alarms" in the gg status. I can't seem to find a way to reset those, even though the battery status is otherwise fine. gg pfreset and reboot doesn't help either. Forcing the charger output on the gg on (with gg chg +) doesn't seem to affect anything either.

Any ideas?

Re: Flashing Senoko PVT board

Shortly I should have a known-good firmware image and the ability to reflash the gas gauge with it, so hopefully that will fix the issue.

Re: Flashing Senoko PVT board

xobs wrote:

Under normal circumstances this never happens.  But in your case, the charger IC never responds, which is the same as the bus never coming ready.  You can tell this is the case because the manufacturer is all zeroes.

Well, now it's got a 4 in it consistently (0x80000040, I think)...

xobs wrote:

It also looks like you're running off battery, as the current draw is negative.  That's why charging isn't allowed, and why the target current is zero.

Still, it must've worked at some point, since your gas gauge woke up.  It's probably a cold solder connection somewhere along the I2C lines.

The I2C pins are pulled up to 3V3, so I think the connections are just fine. Not sure about the connections to the chip, but they good to me, as do the ARM. Given that it WAS soldered in backwards for a while, I wouldn't be surprised if it had died. Regardless, I've got a new one on the way. I'll try sticking it on (the right way!) and see if that works. If not, back to debugging.

Re: Flashing Senoko PVT board

Hi guys,

sorry to read that my board does so much trouble. (not that I understand all I read here).
So just a short note about these issue (and why I'm not in it so far): Bunnie flashed my board at 31c3 (also eightdots and jet another) and mentioned everything went without issue. So I just settled with that and hadn't the time to build my novena so far (didn't even manage to THINK which batteries to use).

Would it help if I send one of the boards I still have here to xobs/bunnie to verify we don't have an issue with my boards (hardware/production related)?

Re: Flashing Senoko PVT board

I don't think there's any hardware problem with the board from your end, mclien. The gas gauge is notorious for doing this; the TI forum for them is full of developers hit with the same issue of read-only dataflash, and they get the same unsatisfactory answers about it from TI. Reflashing seems to be the best way to unlock the chip, which is what I'm working on.

I think the bug is triggered by some subtle difference in initialisation; possibly the order in which power, battery and senoko first execution is applied.

xobs, do you know when you'll get a chance to dump your board?

Re: Flashing Senoko PVT board

I managed to dump the flash today:

http://bunniefoo.com/xobs/xobs-gg.ifi

http://bunniefoo.com/xobs/xobs-gg.dfi

Re: Flashing Senoko PVT board

Thanks! I'll have a look at them this evening.

Re: Flashing Senoko PVT board

Just about to flash this thing, wish me luck...

Re: Flashing Senoko PVT board

Haha, that could have gone very, very badly.

My chip's awake!

37

Re: Flashing Senoko PVT board

Pelrun: gg commands are working correctly?

Re: Flashing Senoko PVT board

...and unplugging the AC power made everything go off. Whoops!

Either the forced reboot or the "gg auto 1" I ran afterwards seems to have fixed it, and now the power button works, and battery power works, and I can hot-plug the AC power with no apparent ill effect. Woohoo!

Now I just have to get this code to the point where someone else can (kinda) safely run it.

Re: Flashing Senoko PVT board

fun: yes, the chip is responding as it should. I haven't been game to set the cells count - that way lies madness - but the cell capacity and other fields aren't locked anymore. Also, the statuses actually make sense for my battery state.

ch>  [AC unplugged] 
ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         on
Discharge FET:      on
State:              normal discharge
Time until full:    65535 minutes
Time until empty:   517 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             99%
Max capacity:       2165 mAh
Design capacity:    2200 mAh
Temperature:        25.-249 C
Voltage:            12561 mV
Current:            -788 mA
Average current:    -248 mA
Target voltage:     12600 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     4185 mV
Cell 2 voltage:     4186 mV
Cell 3 voltage:     4190 mV
Cell 4 voltage:     0 mV
Charge status:      0x1000
    Charging allowed?   yes
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    yes
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     no
    Pulse charging?     no
    Pulse disable CHG?  no
    Cell balancing?     no
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      no
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE CHARGE ALARM
Charge state:
    Battery initialized
    Battery discharging/relaxing
    Battery fully charged
No errors detected
No safety alerts
No safety status messages

Re: Flashing Senoko PVT board

Excellent work!  Looking forward to the code, I guess very shortly I will no longer have an excuse to not finish my case.

Re: Flashing Senoko PVT board

pelrun wrote:

My chip's awake!

dID You use the firmware from xobs, or your own? I assume the former, but then this implies a difference between what you compiled from the sources and xobs image.

Well, at least this proves that the hardware is functioning OK.

42 (edited by pelrun 2015-03-28 22:07:42)

Re: Flashing Senoko PVT board

It's not the senoko firmware that needs to be reflashed, but the data in the gas gauge IC. Flashing a known-working dump from xobs' gas gauge fixes the bad state that causes the gauge to be stuck in read-only mode.

I've finished putting verification code into the flashing tool; I don't think there's anything else I can do to make it safer to run than it is now. So if someone with a locked chip wants to give it a go?

https://github.com/pelrun/novena-gg-tools

Re: Flashing Senoko PVT board

That's good news indeed!  Great job.  Did you flash the firmware or the data?

44 (edited by GregRob 2015-03-29 04:26:46)

Re: Flashing Senoko PVT board

Looking good so far.  I had to try the flash command quite a few times to get it to work, but eventually it did.

gg commands appear to be working.

About to try a battery....

Re: Flashing Senoko PVT board

Not able to charge yet, but have to run off now for "other" work.

Re: Flashing Senoko PVT board

xobs: It's just flashing the data; your firmware dump was identical to mine. (thankfully the firmware isn't storing extra data into the instruction flash, which was a possibility I needed to rule out.)

GregRob: Did it fail at the beginning of the flash process or during the verify step? I'm hoping it's just that the gauge wasn't communicating at all (i.e. like when a battery isn't connected) instead of getting partway through the flash then dying.

Re: Flashing Senoko PVT board

Just replaced U200... same thing as before. Since I'm pretty sure I didn't fry this one, try putting a sniffer on the I2C lines? Any other suggestions?

Re: Flashing Senoko PVT board

There's not too much actually on the i2c lines between the stm32 and the charger IC, at most a resistor? So the I2C lines are probably ok (but check continuity anyway). Is power getting to the charger IC?

49 (edited by dbtayl 2015-03-29 10:29:51)

Re: Flashing Senoko PVT board

The rail is at 3V3 and has good continuity to to the via by the chip. so I think it's fine. I'll check out the I2C lines' continuity next, then maybe sniff traffic on them.

The error code returned by the polling is now "0x80000004", if that helps.

EDIT: I2C continuity looks fine. Resistance between the SDA and SCL lines is 20k, as expected. Still need to see what traffic I can sniff, if any.

50 (edited by dbtayl 2015-03-29 12:46:30)

Re: Flashing Senoko PVT board

OK, weirdness ensues.

I hooked up my Bus Pirate to the I2C lines, and disconnected the Senoko from the Novena. With this setup, I can read the manufacturer ID and device ID registers just fine (getting 0x0040 and 0x0007, respectively).

But when I plug it in to the actual Novena, it's no good- the "chg" command doesn't work, and trying to read the registers via the Bus Pirate also NACKs.

...

And a little more exploration as I write this... Powering the Novena through the Senoko seems to let me read the registers. So that's all good. Moral of the story: Don't expect the Senoko to work entirely when you're plugging the adapter straight into the Novena board. I'm not sure WHY, mind you, since at least the 3V3 rail checked out...

Now onto investigating why my charge status shows 0x8000...


EDIT: Outputs

ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         on
Discharge FET:      on
State:              normal discharge
Time until full:    65535 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             5%
Max capacity:       5985 mAh
Design capacity:    6000 mAh
Temperature:        16.-31 C
Voltage:            10681 mV
Current:            0 mA
Average current:    0 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     3561 mV
Cell 2 voltage:     3561 mV
Cell 3 voltage:     3559 mV
Cell 4 voltage:     0 mV
Charge status:      0x8000
    Charging allowed?   no
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    no
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     no
    Pulse charging?     no
    Pulse disable CHG?  no
    Cell balancing?     no
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      no
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE DISCHARGE ALARM
    REMAINING CAPACITY ALARM
Charge state:
    Battery initialized
    Battery discharging/relaxing
No errors detected
No safety alerts
No safety status messages
ch> chg
Charger information:
        Charge thread:    running
        Manufacturer ID:  0x0040
        Device ID:        0x0007
        Current:          0 mA
        Voltage:          0 mV
        Input:            1792 mA
Command usage:
  chg set [c] [v] [[i]]  Set charge current to c mA @ v mV
  chg input [i]          Set max input AC current to [i] mA
  chg pause              Pause charge control
  chg resume             Resume charge control
ch>