This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with bqtool

Other Parts Discussed in Thread: BQSTUDIO

We are having trouble knowing whether we have successfuly flashed our part or now.  We have the bqtool installed, and we have exported a .fs file.   When we run it, we get ambigous output, we get failures, but a "Success!" at the end of the run.  Can we get some advice?  How do we know if this worked or not?   

bqtool --bqfs-flash --bqfs-file=0421_1_08_10-bq27421G1B.gm.fs --i2c-dev-file=/dev/i2c-0

This question is a follow up to 

Here is the output:

bqtool: init_linux_i2c_interface(): slave address not provided, assuming 0xaa
bqtool: read_bq_poll_intvl(): Failed to read /sys/module/bq27x00_battery/parameters/poll_interval
bqtool: bqfs_exec_cmd(): 
Command C failed at line 18:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 18
bqtool: bqfs_flash(): Retrying bqfs cmd line 18..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 18:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 18
bqtool: bqfs_flash(): Retrying bqfs cmd line 18..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 24:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 24
bqtool: bqfs_flash(): Retrying bqfs cmd line 24..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 24:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 24
bqtool: bqfs_flash(): Retrying bqfs cmd line 24..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 30:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 30
bqtool: bqfs_flash(): Retrying bqfs cmd line 30..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 30:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 30
bqtool: bqfs_flash(): Retrying bqfs cmd line 30..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 36:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 36
bqtool: bqfs_flash(): Retrying bqfs cmd line 36..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 36:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 36
bqtool: bqfs_flash(): Retrying bqfs cmd line 36..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 42:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 42
bqtool: bqfs_flash(): Retrying bqfs cmd line 42..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 42:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 42
bqtool: bqfs_flash(): Retrying bqfs cmd line 42..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 48:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 48
bqtool: bqfs_flash(): Retrying bqfs cmd line 48..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 48:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 48
bqtool: bqfs_flash(): Retrying bqfs cmd line 48..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 54:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 54
bqtool: bqfs_flash(): Retrying bqfs cmd line 54..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 54:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 54
bqtool: bqfs_flash(): Retrying bqfs cmd line 54..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 60:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 60
bqtool: bqfs_flash(): Retrying bqfs cmd line 60..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 60:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 60
bqtool: bqfs_flash(): Retrying bqfs cmd line 60..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 66:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 66
bqtool: bqfs_flash(): Retrying bqfs cmd line 66..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 66:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 66
bqtool: bqfs_flash(): Retrying bqfs cmd line 66..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 72:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 72
bqtool: bqfs_flash(): Retrying bqfs cmd line 72..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 72:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 72
bqtool: bqfs_flash(): Retrying bqfs cmd line 72..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 78:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 78
bqtool: bqfs_flash(): Retrying bqfs cmd line 78..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 78:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 78
bqtool: bqfs_flash(): Retrying bqfs cmd line 78..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 84:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 84
bqtool: bqfs_flash(): Retrying bqfs cmd line 84..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 84:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 84
bqtool: bqfs_flash(): Retrying bqfs cmd line 84..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 90:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 90
bqtool: bqfs_flash(): Retrying bqfs cmd line 90..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 90:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 90
bqtool: bqfs_flash(): Retrying bqfs cmd line 90..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 96:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 96
bqtool: bqfs_flash(): Retrying bqfs cmd line 96..
bqtool: bqfs_exec_cmd(): 
Command C failed at line 96:
bqtool: bqfs_exec_cmd(): Expected data: bqtool: bqfs_exec_cmd(): 
Received data: bqtool: bqfs_exec_cmd(): 
bqtool: bqfs_exec_cmd(): command execution failed at line 96
bqtool: bqfs_flash(): Retrying bqfs cmd line 96..
.............................................................................................
bqtool: main(): comamnd "--bqfs-flash" executed successfully!

Below is the .fs file

============

;--------------------------------------------------------
;Verify Existing Firmware Version
;--------------------------------------------------------
W: AA 00 01 00
C: AA 00 21 04
W: AA 00 02 00
C: AA 00 08 01
;--------------------------------------------------------
;SET_CFGUPDATE
;--------------------------------------------------------
W: AA 00 13 00
X: 1500
W: AA 3E 02 00
W: AA 40 02 26 00 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 A5
X: 200
W: AA 3E 02 00
C: AA 60 A5
W: AA 3E 24 00
W: AA 40 00 19 28 63 5F FF 62 00 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 69
X: 200
W: AA 3E 24 00
C: AA 60 69
W: AA 3E 30 00
W: AA 40 0E 74 FD FF 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 49
X: 200
W: AA 3E 30 00
C: AA 60 49
W: AA 3E 31 00
W: AA 40 0A 0F 02 05 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 AD
X: 200
W: AA 3E 31 00
C: AA 60 AD
W: AA 3E 40 00
W: AA 40 25 F8 0F 10 00 14 04 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 A2
X: 200
W: AA 3E 40 00
C: AA 60 A2
W: AA 3E 44 00
W: AA 40 05 00 32 01 C2 14 14 00 03 08 98 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 39
X: 200
W: AA 3E 44 00
C: AA 60 39
W: AA 3E 50 00
W: AA 40 02 BC 01 2C 00 1E 00 C8 C8 14 08 00 3C 0E 10 00 0A 46 05 14 05 0F 03 20 00 64 46 50 0A 01 90 00
W: AA 60 BB
X: 200
W: AA 3E 50 00
C: AA 60 BB
W: AA 3E 50 01
W: AA 40 64 19 DC 5C 60 00 7D 00 04 03 19 25 0F 14 0A 78 60 28 01 F4 00 00 00 00 00 00 43 80 04 01 14 00
W: AA 60 2A
X: 200
W: AA 3E 50 01
C: AA 60 2A
W: AA 3E 50 02
W: AA 40 0B 0B B8 01 2C 0A 01 0A 00 00 00 C8 00 64 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 C1
X: 200
W: AA 3E 50 02
C: AA 60 C1
W: AA 3E 51 00
W: AA 40 00 A7 00 64 00 FA 00 3C 3C 01 B3 B3 01 90 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 8A
X: 200
W: AA 3E 51 00
C: AA 60 8A
W: AA 3E 52 00
W: AA 40 49 A5 00 00 00 81 0E E6 0E A4 05 DC 15 AE 15 CC 0B B8 00 C8 00 32 00 14 03 E8 01 00 F2 10 68 00
W: AA 60 3E
X: 200
W: AA 3E 52 00
C: AA 60 3E
W: AA 3E 52 01
W: AA 40 0A 10 C2 FF DB FF DC 00 02 02 BC 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 AE
X: 200
W: AA 3E 52 01
C: AA 60 AE
W: AA 3E 59 00
W: AA 40 00 0B 00 0C 00 0E 00 10 00 0D 00 0C 00 0D 00 0D 00 0D 00 0C 00 0D 00 11 00 1A 00 33 00 C5 00 00
W: AA 60 4E
X: 200
W: AA 3E 59 00
C: AA 60 4E
W: AA 3E 70 00
W: AA 40 80 00 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
W: AA 60 FF
X: 200
W: AA 3E 70 00
C: AA 60 FF
;--------------------------------------------------------
;Exit CFGUPDATE
;--------------------------------------------------------
W: AA 00 00 00
W: AA 00 42 00
X: 2000

Note that we have since fixed the error:

bqtool: read_bq_poll_intvl(): Failed to read /sys/module/bq27x00_battery/parameters/poll_interval


By patching SYSFS_POLL_INTVL in interface-linux-i2c.c to be "/sys/module/bq27xxx_battery/parameters/poll_interval"

The rest of the errors, and suspicious "Success!" remain.

  • Where did you get bqtool from? Did you compile it from source code?

    Form a bqtool point of view, the errors aren't critical assuming that you have the bqtool which uses the retry count of 3 (4 total tries) for comparison commands.
  • We compiled bqtool from the most current source that we downloaded from the ti gitorious site.

    I agree about the retries, but we got concerned when we tried sending the code to an invalid address, and got the same successful response, so we don't have much faith in the "success!' message.

    Is there some way we can validate that the values are successfully written?

  • The gauge will transfer data blocks that were written via I2C to a data subclass if the checksum is correct. Your FlashStream file contains verification ("C:" command) which reads back the check-sum and if this check-sum isn't correct after four attempts (three retries) then it will stop and report and error "bqtool: main(): comamnd "--bqfs-flash" failed" followed by usage info.

    >Is there some way we can validate that the values are successfully written?

    You can read back the data memory and verify this manually via bqStudio and the I2C advanced comm option.

    What "invalid address" did you write to?
  • We wrote to address 0xA0.

    After doing some testing, it does seem like the chip is programmed; or at least it is now behaving as expected.   Thanks for the help.

  • bqtool is failing over 50% of the time as tested with the following one-liner. Is there a more stable release somewhere aside from git://git.ti.com/bms-linux/bqtool.git (sha 011576112ea7c0f467fcaeac49cafd56beb80750) or a different utility we could try?

    Note that I instrumented the failure in linux_i2c_write() and it appears that the ioctl() call is setting errno to EREMOTEIO which isn't referenced in the man page but does seem to come from the omap i2c driver when it doesn't get an ACK.

    One liner:
    failed=0; for ((i=0;i<100;i++)); do ./bqtool --bqfs-flash --bqfs-file=/etc/firstboot/bq27421.gm.fs --i2c-dev-file=/dev/i2c-0; [ $? -ne 0 ] && failed=$((failed + 1));done;echo $failed

    Run 1: 54%
    Run 2: 51%
  • There is no other ready to use linux tool.

    Let's assume that the reason for the error message from the I2C driver is due to the gauge not responding. Please log the actual I2C transaction that causes the EREMOTEIO error.

    Are you using 400kHz I2C? If so, can you experiment switching the I2C clock rate to 100kHz?

    bqtool doesn't have code that complies with section 8.5.4.3 from the datasheet. Depending on the I2C speed and how the I2C driver schedules packets, one or more of the restrictions from 8.5.4.3 may be violated, which will prevent the gauge from acknowledging a bus transaction.

    It's not that easy to guarantee this in bqtool (or any user space app that uses the I2C dev interface) - this should be taken care of in a dedicated kernel driver or you can experiment with delays in the bqtool code that interfaces with the I2C dev interface (static int linux_i2c_read(struct gauge_info_t *gauge, uint8_t slave_addr, uint8_t *buf, uint8_t len) and static int linux_i2c_write(struct gauge_info_t *gauge, uint8_t slave_addr, uint8_t *buf, uint8_t len) from interface-linux-i2c.c). Note that delays in this code may not have the desired effect because you can't control from user space how the I2C kernel driver and the I2C hardware are going to schedule the transactions on the physical bus.