Other Parts Discussed in Thread: BQSTUDIO
Hello,
We have implemented flash stream parser based on the code described in slua801. we tested the parser and it parses the flash stream file as per specifications (flash stream specification file attached1856.Flash Stream File Format.pdf).
During our tests with the bq35100 device we found that firmware revision that was read and compared against a known value was failing. When using bqstudio reading of ID and version was working correctly.
In order to do the same with flash streamer file to read id and fimware version, we had to add 100ms delay after i2cwrite command (see below routine).
char *BQ35100_execute_fs(char *pFS) { int nLength = strlen(pFS); int nDataLength; char pBuf[16]; char pData[32]; int n, m; char *pEnd = NULL; char *pErr; bool bWriteCmd = false; bool bReadCmd = false; bool bCompareCmd = false; unsigned char nRegister; m = 0; for (n = 0; n < nLength; n++) if (pFS[n] != ' ') pFS[m++] = pFS[n]; pEnd = pFS + m; pEnd[0] = 0; do { switch (*pFS) { case ';': break; case 'W': case 'C': case 'R': bWriteCmd = *pFS == 'W'; bReadCmd = *pFS == 'R'; bCompareCmd = *pFS == 'C'; pFS++; if ((*pFS) != ':') goto exit_parse; pFS++; n = 0; while ((pEnd - pFS > 2) && (n < sizeof(pData) + 2) &&(*pFS != '\n')) { pBuf[0] = *(pFS++); pBuf[1] = *(pFS++); pBuf[2] = 0; m = strtoul(pBuf, &pErr, 16); if (*pErr) return (pFS - 2); if (n == 0) deviceAddress = m; if (n == 1) nRegister = m; if (n > 1) pData[n - 2] = m; n++; } if (n < 3) goto exit_parse; nDataLength = n - 2; if (bWriteCmd) { BQ35100_dump_data("Write", nRegister, pData, nDataLength); i2cWriteBytes(nRegister, (uint8_t *)pData, nDataLength); /* Adding a delay giving bq35100 device sometime to put register value on I2C bus before we read it. */ DelayMs(100); } if (bCompareCmd || bReadCmd) { char pDataFromGauge[nDataLength]; i2cReadBytes(nRegister, (uint8_t *)pDataFromGauge, nDataLength); if (bCompareCmd) { BQ35100_dump_data("Read", nRegister, pDataFromGauge, nDataLength); BQ35100_dump_data("Compare", nRegister, pData, nDataLength); if (memcmp(pData, pDataFromGauge, nDataLength)) { DEBUG_PRINTF("%s: Memory comparison action failed, exiting...\r\n", __func__); goto exit_parse; } } else BQ35100_dump_data("Read", nRegister, pDataFromGauge, nDataLength); } break; case 'X': pFS++; if ((*pFS) != ':') goto exit_parse; pFS++; n = 0; while ((pFS != pEnd) && (*pFS != '\n') &&(n <sizeof(pBuf) - 1)) { pBuf[n++] = *pFS; pFS++; } pBuf[n] = 0; n = atoi(pBuf); DEBUG_PRINTF("%s: Delaying %u ms\r\n",__func__, n); DelayMs(n); break; default: goto exit_parse; } while ((pFS != pEnd) && (*pFS != '\n')) pFS++; //skip to next line if (pFS != pEnd) pFS++; } while (pFS != pEnd); exit_parse: deviceAddress = BQ35100_I2C_ADDRESS; return pFS; }
Now when we tried to use overall configuration flash streamer (see attached files), the parsing failed at compare after X: 2ms, We tried increasing the delay to 200 ms from 2 ms. This time it went further in flash stream file but failed at a different point in compare command
;--------------------------------------------------------
;Data Block
;--------------------------------------------------------
W: 16 00 03 00 00
W: 16 64 03 00
X: 200
C: 16 66 00
W: 16 00 02 00 00 00 E2 FF 33 03 D7 33 BB D6 33 E0 D6 33 09 D6 33 FF FF 3F 00 01 00 FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F FF FF 3F 03 01 3D 00 01 3D 02 01 3D 0A 00 3D 0A 00 3D 80 03 3D 00 00 3D 00 00 3D 35 80 3D 11 02 3D 49 00 3D 20 2A 0E DF FA 0E E2 FF 32
W: 16 64 60 2B
X: 200
C: 16 66 00
W: 16 00 02 01 00 00 FF AA 0E FB A7 0E FF A6 0E F5 ED 3A 06 D7 3A FF 1C 0E C7 FF 36 FF A1 0E FF A0 0E FD A3 0E F2 A2 0E C2 FF 3A FF A1 0E 7F A0 0E FF A3 0E 7F A2 0E BC A5 0E FF A4 0E BB FF 3A FD A1 0E F2 A0 0E FD A3 0E F2 A2 0E BB FF 3A 07 D7 3A 9E FF 3A E2 FF 33 FF AF 0E 01 4F 03 3F 11 0C BF FF 32 2F 10 0C
W: 16 64 22 31
X: 200
At this point the parser exited and any subsequent attempts to access the chip failed. Note that the delay command were 2ms originally and we changed it to 200ms thinking additional delay would help. We have now bricked ~3 chips this way. We need help to get this flash streamer mechanism in order to calibrate and configure bq35100 device in factory.
Thank you in advance.
Regards,
Maulin Lodhia
Flash stream files used for the test
https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/196/flash_5F00_stream_5F00_files.7z