I ran into a hardfault when reading Smart Battery data with SMBus::block_read.
The fault is triggered in line 126 of
/Firmware/src/lib/drivers/smbus/SMBus.cpp
when memcpy writes beyond the end of the buffer “data” provided by the caller.
In my case the smbus device returned a byte count larger than the requested length (13 instead of 8 bytes).
I fixed this by adding a check for the length limit before the memcpy call, see
You could but you might want to take a look at the code.
memcpy(data, &rx_data[4], byte_count);
should be
memcpy(data, &rx_data[4], cpy_len);
Or your change will not do anything.