I have been saving values to an ESP-WROVER-B module and sometimes, when I want to read back, I have the next error:
Code: Select all
"CRC failed"
Code: Select all
esp_partition_read(partition, index * sizeof(my_data), (void*)data_to_read, sizeof(my_data));
uint8_t crc = crc8_be(0, (const uint8_t*)data_to_read, sizeof(my_data) - 1);
if (data_to_read->crc != crc)
{
ESP_LOGE(TAG, "CRC failed");
return ESP_FAIL;
}
return ESP_OK;
Code: Select all
struct
{
uint32_t value;
uint8_t crc;
}my_data;
Code: Select all
my_data new_value;
new_value.value = its_value;
new_value.crc = crc8_be(0, (const uint8_t*)&new_value, sizeof(my_data) - 1);
My actual problem is that these pieces of code work fine, but sometimes I have the "CRC failed" message in the log, what could have happened?
Best regards,
P