Re: Flashing Senoko PVT board

Yeah, you really don't want to back-power the board by plugging the AC adapter into the mainboard.  You especially don't want to charge batteries that way.  There's a big note on the schematic about that, but it's easy to miss.  For the laptop and desktop cases, the port-farm cover on the side covers up the onboard DC port to prevent that from happening.

It looks like the charge status is correct.  Again, try running "gg it".  The charge/discharge FETs are both on and the cells look good.  You should be able to manually start charging, at least...

52 (edited by dbtayl 2015-03-30 00:49:30)

Re: Flashing Senoko PVT board

Well, I hope I didn't fry anything that way. It wouldn't be the first time, though.

I occationally get "cell balancing: in-progress" in the output of my stats command, but it never says I can charge. "gg it" doesn't seem to help.

Like I said before, I do get messages (from the Senoko) when I plug in the charger, so it should at least detect that's there. I've even gotten a popup in XFCE saying charger connected, but that's not reflected anywhere else, so I don't know what happened there.

EDIT: Looks like I CAN manually charge:

ch> gg auto 0
ch> chg set 1000 12600
Setting charger: 1000mA @ 12600mV... Ok
ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         on
Discharge FET:      on
State:              ???
Time until full:    408 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             6%
Max capacity:       5986 mAh
Design capacity:    6000 mAh
Temperature:        20.24505 C
Voltage:            10904 mV
Current:            889 mA
Average current:    889 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     3636 mV
Cell 2 voltage:     3636 mV
Cell 3 voltage:     3633 mV
Cell 4 voltage:     0 mV
Charge status:      0x8044
    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?     in-progress
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      yes
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE CHARGE ALARM
    TERMINATE DISCHARGE ALARM
Charge state:
    Battery initialized
No errors detected
No safety alerts
No safety status messages
ch>

It doesn't seem to like the current I'm putting in there, though. 1 A should be WELL below what's safe for the charger and the batteries. Since the gg was automatically turning the charging off, I assume that's why. What triggers that? I see the target voltage and target current fields are both 0- maybe that has something to do with it?


EDIT2: And it still turns off charging after a while, even when I tell the gg not to control it.

53 (edited by GregRob 2015-04-01 22:01:22)

Re: Flashing Senoko PVT board

Pelrun, it looked like this when it failed:

gregrob@novena01:~/novena-gg-tools$ sudo flash xobs-gg.dfi
Flash length: 2048
Erasing rows 0-1...
Retrying erase...
Retrying erase...
Retrying erase...
.
.
.
Retrying erase...
Retrying erase...
Retrying erase...
Flash verify failed, try running this again.

I actually did end up power cycling once before it finally did work, I was sweating that since you had warned it could go badly. 

And when it did work it looked like:

gregrob@novena01:~/novena-gg-tools$ ./flash xobs-gg.dfi 
Flash length: 2048
Erasing rows 0-1...
Writing data flash row 0
Writing data flash row 1
Erasing rows 2-3...
Writing data flash row 2
Writing data flash row 3
Erasing rows 4-5...
Writing data flash row 4
Writing data flash row 5
.
.
.
Writing data flash row 58
Writing data flash row 59
Erasing rows 60-61...
Writing data flash row 60
Writing data flash row 61
Flash verified, exiting BootROM mode

As mentioned all the gg commands appear to be working now, but I have not gotten the charger to run.  I've only spent a bit of time on it, but "gg auto 1" and "gg chg +" don't seem to start things.  And yes I ran "gg it".  I also tried "chg resume".  Neither FET seems to ever change state.  I have the following in the stats response:

EDIT (April 1): on IRC xobs advised not to do the gg auto 1, and if you have change it back with gg auto 0

Alarms:
    TERMINATE CHARGE ALARM
    TERMINATE DISCHARGE ALARM
Charge state:
    Battery initialized
    Battery discharging/relaxing
No errors detected
No safety alerts
No safety status messages

It  is plugged into a real battery now (the battery is in a safe charging bag, just in case of trouble).

Re: Flashing Senoko PVT board

After poking around a bit more, and trying:
  gg auto 0
  chg set 1000 11100
  gg chg +

I still haven't gotten the charger to run.  Here is a the full stats response:

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:             49%
Max capacity:       4993 mAh
Design capacity:    5000 mAh
Temperature:        26.24317 C
Voltage:            11424 mV
Current:            0 mA
Average current:    0 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     3809 mV
Cell 2 voltage:     3808 mV
Cell 3 voltage:     3807 mV
Cell 4 voltage:     0 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

Re: Flashing Senoko PVT board

pelrun wrote:

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

Thank-you! This worked fine for me. Much appreciated.

Re: Flashing Senoko PVT board

GregRob wrote:

After poking around a bit more, and trying:
  gg auto 0
  chg set 1000 11100
  gg chg +

I still haven't gotten the charger to run.

I got precisely the same effect until I shorted out the appropriate temperature sensing pins, oddly - despite setting "gg tempsource greater" already. Sticking the jumper across the TS pins fixed it and mine has now gone into charge, happily.

Re: Flashing Senoko PVT board

I already had one of the temperature sensors shorted, and was reading 26 C.  I've now shorted both sets, it is still reading 26 C,  also tried "gg tempsource internal", and I get the same temp.  Still no action on either FET.

58 (edited by GregRob 2015-03-30 05:14:20)

Re: Flashing Senoko PVT board

Ok, after a bit more poking I realized my gas gauge was stuck again.  So I re-wrote xobs' data to it using pelrun's flash tool, and then did a gg chg + and a gg it, and the charger is now running!

If I do tweak it at all, and it is still working I should use the data reading tool to grab my own image that I can then reflash if it sticks again in the future.

59 (edited by dbtayl 2015-03-30 05:47:30)

Re: Flashing Senoko PVT board

Got it! I used Pelrun's tool to write xobs' configuration to my gg, and now it's all good. Why it didn't occur to me to try that earlier, I don't know, but it seems to be all good now.

That's so nice to see after all the soldering...

A big thanks to Pelrun!


As a side note, would it be educational to dig through a "bad" gg dump to see what's going on? I didn't think to dump mine before flashing, but it's a thought. I don't know how things work enough to know if that would be helpful or not.

Re: Flashing Senoko PVT board

I did briefly look at the differences between my dump and a "clean" image I got from TI, but it wasn't obvious at the time which differences meant anything. I've got a better idea now where the various variables live (having a firmware disassembly helps!) but haven't tried it again.

Re: Flashing Senoko PVT board

The "stats" command will read values out from the gas gauge.  The "temperature" reading there is the same one used by the gas gauge firmware, so if it's within a sane range, everything will be fine.  Having said that, you can probably use "gg tempsource internal", which will be more accurate than simply shorting T and X.  It won't really be accurate at all, since the battery and gas gauge are far apart, but it's better than a normal resistor.

You may not be getting a charge because the gas gauge doesn't think it /can/ charge.  The charger thread simply reads "Target voltage" and "Target current" from the gas gauge once every 2.5 seconds and feeds that data into the charger.  It's possible to have the gas gauge do this directly, but we didn't go that route for nebulous and vague reasons.  Probably complexity.

Anyway, you can manually feed charge values to the charger.  Run "chg 1000 12600" to enable 12.6V @ 1A.  That should give enough current for the gas gauge to realize that yes, in fact, there IS a power source attached.  You might want to disable the charger thread when you do this, but be sure to re-enable it when you're done, otherwise you'll hit the charger's watchdog timer.  If you don't feed charge values to the charger every ~200 seconds it will stop charging.

62 (edited by GuzTech 2015-04-01 03:44:28)

Re: Flashing Senoko PVT board

I've bought the following battery:

http://www.hobbyking.com/hobbyking/stor … 3PKS_.html

and hooked it up to the Senoko board I got from mclien. I had the same issues as stated in this topic in that my gas gauge seemed to be stuck. So I used pelrun's program to flash xobs' data on it and then I got sane values from the gg stats.

I can use the Novena on just a battery, but I cannot charge it however. I've asked on IRC and tried a couple of things, but it does not charge the battery. Here are some stats:

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:             33%
Max capacity:       2436 mAh
Design capacity:    2500 mAh
Temperature:        25.16135 C
Voltage:            11309 mV
Current:            0 mA
Average current:    0 mA
Target voltage:     12600 mV
Target current:     1000 mA
Number of cells:    3 cells
Cell 1 voltage:     3772 mV
Cell 2 voltage:     3770 mV
Cell 3 voltage:     3767 mV
Cell 4 voltage:     0 mV
Charge status:      0x200
    Charging allowed?   yes
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    no
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     yes
    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:
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:          896 mA
        Voltage:          12592 mV
        Input:            3328 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

I've tried gg auto 0 and 1, and gg it. I've flashed xobs' data multiple times, and even reflashed the senoko firmware just in case, but it's still a no go. I used the internal temperature sensor which reported values like 23.-229 C, and then I shorted the T and X wires on the left. Now I have 25.24327 C.

FWIW, the Senoko detects when I plug in AC, but xfce always indicates that I'm running off batteries (even if I don't have batteries attached).

http://bitlog.it - uncovering secrets at the frontier of technology

63 (edited by pelrun 2015-04-19 20:35:22)

Re: Flashing Senoko PVT board

'gg auto 0' (EDIT: auto 1 is bad!) and 'gg it' are what you want; you also want to wait a while. The charging doesn't start immediately. Note that 'stats' is specifying a Target Current value of 1000mA, which shows that the gauge is actually requesting a charge. Senoko periodically reads that value and sends it to the charger IC; you can simulate the same thing by doing a 'chg set 1000 12600'.

Also, XFCE only updates the battery status once a minute or so, so you may not see the AC adapter status update.

'gg reboot' is also useful to give the gauge a kick.

Re: Flashing Senoko PVT board

It looks mostly correct.  The only weird thing is that the "current" measured is 0, which means that even though the charger is on, no current is flowing through the CHG FET.

Since everything looks good from the software side, it's time to check the hardware.  The actual battery is connected to the gas gauge, right?  Not just the balancing taps?  Check the connections around the FETs, too.

Regarding XFCE not noticing the AC adapter -- that's due to a bug in the kernel that was released with bare boards.  Or possibly a bug in Senoko, depending on how you look at it.  I patched it on the kernel side in https://github.com/xobs/novena-linux/co … 500546a922 but you could patch it in the firmware of Senoko by manually modifying senoko/senoko-slave.c:186 and setting registers.features = 0xff.

65 (edited by GuzTech 2015-04-01 19:14:55)

Re: Flashing Senoko PVT board

I've tried 'gg auto 1' and 0, 'gg it', and 'gg reboot' many times, and I've left the AC adapter the entire night, but it still remains at the normal discharge state and refuses to charge. 'chg set 1000 12600' also gives the same result.

'current' stays at 0 when the AC is plugged in and changes into around -800 mA when running off the battery (as expected). The battery has three plugs: the balance plug, and two discharge plugs (Futaba/JR, and another one). I've replaced the non-Futaba plug with a Molex plug and measured 11.4 V on it. Both those plugs are connected.

http://guztech.nl/battery.jpg

One thing bugs me though. On the battery information page, it says that the discharge plug is the Futaba/JR plug, but Futaba and JR are practically the same. The other plug (that also measures 11.4 V) is the one I cut off and put a Molex plug on. I cannot imagine that this plug discharges, but does not allow charging, but given the fact that it should work, but doesn't, makes me question everything.

A visual inspection of the Senoko board does not reveal anything unusual.

http://bitlog.it - uncovering secrets at the frontier of technology

66 (edited by GuzTech 2015-04-01 23:06:10)

Re: Flashing Senoko PVT board

Ok after quite a few times of reflashing the .dfi file, I think I have it working now. First thing I did was 'gg tempsource internal' because it gave me negative values and I've noticed that if the temperature is negative, the Senoko does not listen very well to user commands. Next, I did a 'gg capacity 3 2500', and 'gg reboot' to make sure I got sane values.

Then I started messing around with the 'gg cal' command since that was pretty much the only command I hadn't touched yet. Not knowing what values I had to give it, I did a 'gg cal 12600 2500 25', and the stats were completely wrong (cell voltages were too high, alarms went off, etc.), but it did try to charge the battery. Since this is the closest I got to actually getting the battery to charge, I reflashed the .dfi file, and did the following:

1. gg tempsource internal
2. gg capacity 3 2500
3. gg reboot

This gives me correct values. Then I did:

gg cal 11254 2440 22 (values that I got after step 3 above)

and now it looks like it is charging. The stats are:

ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         on
Discharge FET:      on
State:              charge
Time until full:    125 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             11%
Max capacity:       2397 mAh
Design capacity:    2500 mAh
Temperature:        24.24337 C
Voltage:            11258 mV
Current:            2135 mA
Average current:    2197 mA
Target voltage:     12600 mV
Target current:     5000 mA
Number of cells:    3 cells
Cell 1 voltage:     3755 mV
Cell 2 voltage:     3754 mV
Cell 3 voltage:     3750 mV
Cell 4 voltage:     0 mV
Charge status:      0x240
    Charging allowed?   yes
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    no
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     yes
    Pulse charging?     no
    Pulse disable CHG?  no
    Cell balancing?     in-progress
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      no
    Overcharge?         no
    Battery empty?      no
Alarms:
Charge state:
    Battery initialized
No errors detected
No safety alerts
No safety status messages

I honestly don't know if the values are correct (5000 mA target current for example), but looks like it is working. I'll post my experiences after it is done charging.

EDIT:

It's done charging, I pulled out the AC and I got a current of 32767 mA (max value of a signed short), and now it reports that it's at 0%. Stats:

Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         off
Discharge FET:      on
State:              overcurrent
Time until full:    77 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             0%
Max capacity:       2385 mAh
Design capacity:    2500 mAh
Temperature:        28.24297 C
Voltage:            11079 mV
Current:            32767 mA
Average current:    32767 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     3694 mV
Cell 2 voltage:     3694 mV
Cell 3 voltage:     3691 mV
Cell 4 voltage:     0 mV
Charge status:      0x44
    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?     in-progress
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      yes
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE CHARGE ALARM
    TERMINATE DISCHARGE ALARM
Charge state:
    Battery initialized
    Battery fully discharged
No errors detected
No safety alerts
Safety status:
    Charge overcurrent condition
    Tier-2 charge overcurrent condition

And after a while with the AC pluggin in again:

ch> stats
Manufacturer:       Texas Inst.
Part name:          bq20z95
Firmware version:   0x5009
Charge FET:         on
Discharge FET:      on
State:              fault charge terminate
Time until full:    153 minutes
Time until empty:   65535 minutes
Chemistry:          LION
Serial number:      0x0001
Charge:             8%
Max capacity:       2450 mAh
Design capacity:    2500 mAh
Temperature:        23.-229 C
Voltage:            11196 mV
Current:            2455 mA
Average current:    1157 mA
Target voltage:     0 mV
Target current:     0 mA
Number of cells:    3 cells
Cell 1 voltage:     3735 mV
Cell 2 voltage:     3734 mV
Cell 3 voltage:     3728 mV
Cell 4 voltage:     0 mV
Charge status:      0x244
    Charging allowed?   yes
    Can suspend?        no
    Can precharge?      no
    Can maintenance?    no
    Temperature limit?  no
    Temperature limit?  no
    Can fastcharge?     yes
    Pulse charging?     no
    Pulse disable CHG?  no
    Cell balancing?     in-progress
    Precharge timeout?  no
    Fastcharge timeout? no
    Overcharge OV?      no
    Overcharge OC?      yes
    Overcharge?         no
    Battery empty?      no
Alarms:
    TERMINATE CHARGE ALARM
Charge state:
    Battery initialized
No errors detected
No safety alerts
No safety status messages
http://bitlog.it - uncovering secrets at the frontier of technology

Re: Flashing Senoko PVT board

Either unplug the battery temporarily or issue a "gg rm 0". It's set a flag for the overcurrent condition it saw earlier (which I think was caused by a bad calibration - you're meant to physically measure the values given to the cal command), and you need to reset it.

Marking the battery as non-removable makes it clear the flag shortly after the OC condition clears; removable requires that the battery actually be disconnected to clear it.

Re: Flashing Senoko PVT board

Calibration is meant to be run exactly once.  Ever.

The way it's designed to work is the battery manufacturer gets a specific grade of lithium, packages it together with a specific type of metal and casing, and connects it to the circuit using known wiring with a fixed capacitance.  They then measure the temperature, current, and voltage using very precise equipment.  This is then programmed in using the "cal" program (which was originally a Visual Basic implementation).  The flash is then read out and loaded onto every battery they manufacture.

If you feed it incorrect values, you can get all sorts of oddities.  For example, I once put a negative sign in and therefore had it inverted, and it refused to charge unless the AC adapter was unplugged.  Silly thing.

When I ran calibration on mine, the current was very small.  On the order of -8 to -9 mA.  Depending on which value I specified, I could have the battery report to me that it was charging at 3000 mA or 3300 mA.  It's very sensitive.

Re: Flashing Senoko PVT board

pelrun, I just wanted to give you a big thanks. Today I finished putting together my battery and I found out that my gas gauge was not responding, your flashing program worked at the first try and now everything works fine smile

Re: Flashing Senoko PVT board

I just wanted to give an update. I've got my Senoko working correctly now!

The problem was just as xobs said that the problem was hardware related. The 5.1K resistor between the gas gauge chip and the charge FET didn't have continuity on one end, which I figured out by measuring the G (gain) terminal of the charge FET chip. Whether I issued a "gg chg +" or "gg chg -" command, it stayed at 8.65V whereas the the discharge chip showed ~22V and ~11V when turning it on and off respectively.

After soldering one end of the resistor and making sure there is continuity, everything works like a charm smile

http://bitlog.it - uncovering secrets at the frontier of technology