bug report STSW-IMG054
While implementing on an RPI5 I ran across a bug in the vl53l9.c driver file in the STSW-IMG054 package. It is specifically in vl53l9-nucleo-n657-fmw-1.1.1/drivers/vl53l9/vl53l9.c
Bug report:
- File: vl53l9.c
- Function: _write_cmd()
- Location: approximately line 936-943 in the ST source.
- Problem: _command_t (a 4 byte object on AMR64 build) is used for current_cmd, but vl53l9_read8() writes only one byte into that object.
- Observed behavior: On the Raspberry Pi 5 ARM64 build, current_cmd was 0xAA00 after the sensor returned 0x00 from register 0x0400.
- Consequence: The comparison against COMMAND_NONE fails, causing _write_cmd() to time out despite successful command completion.
- Correction: Use uint8_t current_cmd and pass ¤t_cmd to vl53l9_read8().
-The corrected code allowed the complete vl53l9_init() sequence to succeed, including firmware revision verification (0x00B5).
Line 936 (original): _command_t current_cmd;
Line 936 (corrected): uint8_t current_cmd;
Line 943 (original): ret = vl53l9_read8(p_dev, VL53L9_REGADDR_COMMAND, (uint8_t *)¤t_cmd);
Line 943 (corrected): ret = vl53l9_read8(p_dev, VL53L9_REGADDR_COMMAND, ¤t_cmd);
