Closed darexa closed 2 years ago
Can you please submit a PR with a fix?
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.
Describe the bug There is a timing issue with the BQ274xx driver. Unfortunately timings are poorly documented for the device so I'm unsure about the proper fix but I've gotten it to work at least.
To Reproduce Build the driver using STM32L452 running at 80MHz. Since this seems to be timing related it might or might not work with other modules/speeds etc.
Expected behavior There is a readout of checksum of the data block. An expected checksum is also calculated, though they are never compared. Expected to be the same, they are not. Looking at the data, it is offset by 1 byte.
https://github.com/zephyrproject-rtos/zephyr/blob/f08c44def5fc56f7724664acc6b2e2291911f457/drivers/sensor/bq274xx/bq274xx.c#L498-L510
Impact I've made a custom driver with a fix, so its not a showstopper for me. For anyone using else using this driver, no configuration settings will be correct if this bug occurs and you will not know since you get no error. My current fix is adding a delay (BQ274XX_SUBCLASS_DELAY) at this line:
https://github.com/zephyrproject-rtos/zephyr/blob/f08c44def5fc56f7724664acc6b2e2291911f457/drivers/sensor/bq274xx/bq274xx.c#L491
I can't find any documentation regarding this 5ms delay other than that it is already in this driver.
Logs and console output Logging the incorrect read block. [00:00:00.039,780] bq274xx_custom:
00 80 00 00 81 0e db 0e a8 07 3a 15 ae 05 3c 0b |........ ..:...<.
b8 00 c8 00 32 00 14 03 e8 01 00 b9 10 04 00 50 |....2... .......P
After adding a delay(correct block):
[00:00:00.049,280] bq274xx_custom:
40 00 80 00 00 81 0e db 0e a8 07 3a 15 ae 05 3c |@....... ...:...<
0b b8 00 c8 00 32 00 14 03 e8 01 00 b9 10 04 00 |.....2.. ........
Environment (please complete the following information):
Additional context Custom board using STM32L452 at 80MHz. Have not tried on a nucleo board.