efuse: Validates data after burning and re-burnes it if necessary

This commit is contained in:
Konstantin Kondrashov
2022-04-27 01:10:41 +08:00
parent 1f0e27ca63
commit df30b362a8
25 changed files with 721 additions and 127 deletions

View File

@@ -11,6 +11,7 @@
#include "hal/efuse_hal.h"
#include "hal/efuse_ll.h"
#define ESP_EFUSE_BLOCK_ERROR_BITS(error_reg, block) ((error_reg) & (0x0F << (4 * (block))))
uint32_t efuse_hal_get_chip_revision(void)
{
@@ -61,3 +62,22 @@ void efuse_hal_rs_calculate(const void *data, void *rs_values)
}
/******************* eFuse control functions *************************/
bool efuse_hal_is_coding_error_in_block(unsigned block)
{
if (block == 0) {
for (unsigned i = 0; i < 5; i++) {
if (REG_READ(EFUSE_RD_REPEAT_ERR0_REG + i * 4)) {
return true;
}
}
} else if (block <= 10) {
// The order of error in these regs is different only for the C3 chip.
// EFUSE_RD_RS_ERR0_REG: (hi) BLOCK7, BLOCK6, BLOCK5, BLOCK4, BLOCK3, BLOCK2, BLOCK1, ------ (low)
// EFUSE_RD_RS_ERR1_REG: BLOCK9, BLOCK8
// BLOCK10 is not presented in the error regs.
uint32_t error_reg = REG_READ(EFUSE_RD_RS_ERR0_REG + (block / 8) * 4);
return ESP_EFUSE_BLOCK_ERROR_BITS(error_reg, block % 8) != 0;
}
return false;
}

View File

@@ -54,6 +54,16 @@ void efuse_hal_program(uint32_t block);
*/
void efuse_hal_rs_calculate(const void *data, void *rs_values);
/**
* @brief Checks coding error in a block
*
* @param block Index of efuse block
*
* @return True - block has an error.
* False - no error.
*/
bool efuse_hal_is_coding_error_in_block(unsigned block);
#ifdef __cplusplus
}
#endif