I am interfacing with the BHI260AB shuttle board over I2C using a Cortex M0 as the host MCU (Adafruit Feather M0 board). I use the 'load_firmware.c' example code provided with the BHY2 Sensor API to upload firmware to the external flash chip on the shuttle board. The firmware file I included in my code is the 'Bosch_SHUTTLE_BHI260_BMM150-flash.fw.h' file supplied with the BHY2 Sensor API. After uploading the firmware and booting the BHI260AB from flash, the Error Value register reports a 0x12 error ("SHA hash mismatch") and the Boot Status register activates the 'Flash Verify Error' bit. I have made the following modifications to the example code: Changed to I2C interface Included custom functions for I2C read & write operations and a delay function Removed lines relating to COINES Replaced printf statements with appropriate printing statements for the Arduino framework Included a check on the result of the bhy2_upload_firmware_to_flash_partly function to ensure that the firmware is being received Decreased the size of the increment in the 'upload_firmware' function to 200, because the default 256 increment leads to a timeout error I have also created an alternative firmware file using the BHI260 SDK, using the default configuration that comes with the SDK. At 1 point this firmware was uploaded correctly and after booting from flash a valid kernel version was reported, but at the next attempt with the exact same code and firmware it reported the SHA hash mismatch again. I am suspecting that some bytes are getting lost in data transfer to the flash chip, but I have no clue what could cause that. Any possible clues are appreciated! For reference, these are my I2C read and write functions: int8_t user_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *ptr) { uint16_t ndone = 0; uint8_t nread; uint8_t stop = 0; Wire.beginTransmission(BHI_I2C_address); Wire.write(reg_addr); Wire.endTransmission(); while (ndone < len) { nread = min(255,len-ndone); ndone += nread; if (ndone == len) { stop = 1; } Wire.requestFrom(BHI_I2C_address,nread,stop); for (uint8_t i = 0; i < nread; i++) { *reg_data = Wire.read(); reg_data++; } } return 0; } int8_t user_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *ptr) { Wire.beginTransmission(BHI_I2C_address); Wire.write(reg_addr); while (len--) { Wire.write(*reg_data); reg_data++; } Wire.endTransmission(); return 0; }
... View more