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.

BQ28Z610: Checksum mismatch when read data flash value

Part Number: BQ28Z610
Other Parts Discussed in Thread: BQSTUDIO

Dear TI,

We are working with FG IC BQ28Z610, we got it's driver from TI git repository "https://github.com/tibms/kernel-4.4/tree/release/drivers/power/bq28z610" 

0C 46 FC 08 0A B8 0B 0A 00 05 32 00 C2 01 05 14 00 0A 14 F6 FF 0C FE 32 A0 05 D4 0C 0A 01 01 0F 40 1F 71 24

- But when we read using bq28z610 driver the last 4 bytes are different and checksum is failed

[ 12.276473] [bq28z610] fg_print_buf: mac_read_block buf:
[ 12.276481] [bq28z610] fg_print_buf: 0C 46
[ 12.396379] [bq28z610] fg_print_buf: mac_read_block buf:
[ 12.396395] [bq28z610] fg_print_buf: 0C 46 FC 08 0A B8 0B 0A 00 05 32 00 C2 01 05 14 00 0A 14 F6 FF 0C FE 32 A0 05 D4 0C 0A 01 01 0F B0 CE B4 E2
[ 12.415618] [bq28z610] fg_mac_read_block: Checksum error

In addition BQ28Z610 already changed into full access mode for read data

Default code from bq28z610 driver for reading FW version also had this problem

Line 1061: [ 11.538581] [bq28z610] fg_print_buf: mac_read_block buf:
Line 1062: [ 11.538586] [bq28z610] fg_print_buf: 00 3E
Line 1063: [ 11.657029] [bq28z610] fg_print_buf: mac_read_block buf:
Line 1064: [ 11.657036] [bq28z610] fg_print_buf: 02 00 26 10 00 17 00 16 00 03 85 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 0B 30 A3
Line 1065: [ 11.676199] [bq28z610] fg_mac_read_block: Checksum error
Line 1066: [ 11.681727] [bq28z610] fg_read_fw_version: FW Ver:A3A3, Build:8AFF
Line 1067: [ 11.688182] [bq28z610] fg_read_fw_version: Ztrack Ver:FF11


Please help us check this problem.


Thank you very much!

  • Hello Hai,

    I would check this with bqStudio first.

  • Dear Mr. Kang,
    Sorry for my unclear question, some information are missed when submit case.
    I would like to update my bqStudio result

    Result from bqStudio is: 
    0C 46 FC 08 0A B8 0B 0A 00 05 32 00 C2 01 05 14 00 0A 14 F6 FF 0C FE 32 A0 05 D4 0C 0A 01 01 0F 40 1F 71 24
    But when we read from driver the last 4 bytes are different
    0C 46 FC 08 0A B8 0B 0A 00 05 32 00 C2 01 05 14 00 0A 14 F6 FF 0C FE 32 A0 05 D4 0C 0A 01 01 0F B0 CE B4 E2

    It lead to mismatch checksum issue.

    Regards,

  • Thanks Hai,

    Which subclass are you trying to modify.

    I don't see a 0x46 0xC0 on the TRM.

    Thanks!

  • Dear Mr. Kang,

    We want to change "Shutdown Voltage" - Class: Power, Subclass: Shutdown


    Current result is: 0C 46 FC 08 
    FC 08 is in little endian => Shutdown voltage is 0x08FC = 2300 => It is default value, we want to change it from driver side.

    Regards,

  • Got it.

    Can you follow the example in the TRM.

    You don't need to write all 32 bytes, you just need to write two bytes and follow the computation of the checksum.

    Thanks!

  • Dear Mr. Kang,

    Yes we just write 2 bytes 0C 46 as example, function fg_mac_read_block will read back 36 bytes for checksum and the problem is last 2 bytes are wrong (checksum and length)

    [ 12.276473] [bq28z610] fg_print_buf: mac_read_block buf:
    [ 12.276481] [bq28z610] fg_print_buf: 0C 46                                       // Write data
    [ 12.396379] [bq28z610] fg_print_buf: mac_read_block buf:
    [ 12.396395] [bq28z610] fg_print_buf: 0C 46 FC 08 0A B8 0B 0A 00 05 32 00 C2 01 05 14 00 0A 14 F6 FF 0C FE 32 A0 05 D4 0C 0A 01 01 0F B0 CE B4 E2                                                                                                        // Read data
    [ 12.415618] [bq28z610fg_mac_read_block: Checksum error

    "github.com/.../bq28z610_fg.c

    static int fg_mac_read_block(struct bq_fg_chip *bq, u16 cmd, u8 *buf, u8 len)
    {
    int ret;
    u8 cksum_calc, cksum;
    u8 t_buf[40];
    u8 t_len;
    int i;

    t_buf[0] = (u8)(cmd >> 8);
    t_buf[1] = (u8)cmd;
    ret = fg_write_block(bq, bq->regs[BQ_FG_REG_ALT_MAC], t_buf, 2);
    if (ret < 0)
    return ret;

    msleep(100);

    ret = fg_read_block(bq, bq->regs[BQ_FG_REG_ALT_MAC], t_buf, 36);
    if (ret < 0)
    return ret;

    fg_print_buf("mac_read_block", t_buf, 36);

    cksum = t_buf[34];
    t_len = t_buf[35];

    cksum_calc = checksum(t_buf, t_len - 2);
    if (cksum_calc != cksum)
    return 1;                                                       // Checksum error will return 1 and result will not be copied to input buffer

    for (i = 0; i < len; i++)
    buf[i] = t_buf[i+2];

    return 0;
    }

    In addition, default bq28z610 function fg_read_fw_version also get checksum error and you haven't checked this case.
    "github.com/.../bq28z610_fg.c

    static void fg_read_fw_version(struct bq_fg_chip *bq)
    {

    int ret;
    u8 buf[36];

    ret = fg_write_word(bq, bq->regs[BQ_FG_REG_ALT_MAC], FG_MAC_CMD_FW_VER);

    if (ret < 0) {
    bq_err("Failed to send firmware version subcommand:%d\n", ret);
    return;
    }

    mdelay(2);

    ret = fg_mac_read_block(bq, bq->regs[BQ_FG_REG_ALT_MAC], buf, 11);

    // You only check ret < 0 but in case of checksum error ret = 1 and buf didn't include  FW version data. 
    if (ret < 0) {                                                                               
    bq_err("Failed to read firmware version:%d\n", ret);
    return;
    }

    bq_log("FW Ver:%04X, Build:%04X\n",
    buf[2] << 8 | buf[3], buf[4] << 8 | buf[5]);
    bq_log("Ztrack Ver:%04X\n", buf[7] << 8 | buf[8]);             
    }

    Line 1061: [ 11.538581] [bq28z610] fg_print_buf: mac_read_block buf:

    Line 1062: [ 11.538586] [bq28z610] fg_print_buf: 00 3E
    Line 1063: [ 11.657029] [bq28z610] fg_print_buf: mac_read_block buf:
    Line 1064: [ 11.657036] [bq28z610] fg_print_buf: 02 00 26 10 00 17 00 16 00 03 85 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 38 0B 30 A3
    Line 1065: [ 11.676199] [bq28z610] fg_mac_read_block: Checksum error
    Line 1066: [ 11.681727] [bq28z610] fg_read_fw_version: FW Ver:A3A3, Build:8AFF
    Line 1067: [ 11.688182] [bq28z610] fg_read_fw_version: Ztrack Ver:FF11


    Regards,

  • I have assigned this post to an expert and he will respond here this week.

  • Hello Hai,

    I saw this post and the following lines caught my attention

    Line 1066: [ 11.681727] [bq28z610] fg_read_fw_version: FW Ver:A3A3, Build:8AFF
    Line 1067: [ 11.688182] [bq28z610] fg_read_fw_version: Ztrack Ver:FF11

    Are you able to read firmware version properly? Please compare to results from bqStudio. Hope this helps in your debug.

    Regards

  • Dear Mr. Shirish,

    Sorry for late response, we using FW_VERSION commands in bqstudio and the result is very different with driver's result.
    Details as below screen shot.

    Regards,

  • Hello Hai,

    I recommend that you get the FW_VERSION read to match before attempting data flash access. There could be problems in the code that could cause this or data may be corrupted on the bus. Make sure that the linux device is the only device on the bus during communication to eliminate any possible interference from other devices trying to control the bus. If you are getting identical results on every read, then the probability of corruption on the bus is low. Hope this helps you make progress.

    Regards