mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
efuse: Burn func can return an error
esp_efuse_utility_burn_chip()
This commit is contained in:
parent
2ba9cd6c54
commit
2e9e5d6e7c
@ -101,8 +101,12 @@ esp_err_t esp_efuse_utility_fill_buff(unsigned int num_reg, esp_efuse_block_t ef
|
||||
*
|
||||
* If CONFIG_EFUSE_VIRTUAL is set, writing will not be performed.
|
||||
* After the function is completed, the writing registers are cleared.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_FAIL: The operation was not successfully completed.
|
||||
*/
|
||||
void esp_efuse_utility_burn_efuses(void);
|
||||
esp_err_t esp_efuse_utility_burn_efuses(void);
|
||||
|
||||
/**
|
||||
* @brief Returns the number of array elements for placing these "bits" in an array with the length of each element equal to "size_of_base".
|
||||
|
@ -110,14 +110,30 @@ static bool efuse_hal_is_coding_error_in_block(unsigned block)
|
||||
|
||||
#endif // ifndef CONFIG_EFUSE_VIRTUAL
|
||||
|
||||
static void efuse_hal_clear_program_registers(void)
|
||||
{
|
||||
for (uint32_t r = EFUSE_BLK0_WDATA0_REG; r <= EFUSE_BLK0_WDATA6_REG; r += 4) {
|
||||
REG_WRITE(r, 0);
|
||||
}
|
||||
for (uint32_t r = EFUSE_BLK1_WDATA0_REG; r <= EFUSE_BLK1_WDATA7_REG; r += 4) {
|
||||
REG_WRITE(r, 0);
|
||||
}
|
||||
for (uint32_t r = EFUSE_BLK2_WDATA0_REG; r <= EFUSE_BLK2_WDATA7_REG; r += 4) {
|
||||
REG_WRITE(r, 0);
|
||||
}
|
||||
for (uint32_t r = EFUSE_BLK3_WDATA0_REG; r <= EFUSE_BLK3_WDATA7_REG; r += 4) {
|
||||
REG_WRITE(r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Efuse read operation: copies data from physical efuses to efuse read registers.
|
||||
void esp_efuse_utility_clear_program_registers(void)
|
||||
{
|
||||
REG_WRITE(EFUSE_CONF_REG, EFUSE_CONF_READ);
|
||||
efuse_hal_clear_program_registers();
|
||||
}
|
||||
|
||||
// Burn values written to the efuse write registers
|
||||
void esp_efuse_utility_burn_efuses(void)
|
||||
esp_err_t esp_efuse_utility_burn_efuses(void)
|
||||
{
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL
|
||||
ESP_LOGW(TAG, "Virtual efuses enabled: Not really burning eFuses");
|
||||
@ -137,6 +153,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
esp_efuse_coding_scheme_t scheme = esp_efuse_get_coding_scheme(num_block);
|
||||
for (uint32_t addr_wr_block = range_write_addr_blocks[num_block].start; addr_wr_block <= range_write_addr_blocks[num_block].end; addr_wr_block += 4) {
|
||||
if (REG_READ(addr_wr_block) != 0) {
|
||||
efuse_hal_clear_program_registers();
|
||||
unsigned w_data_len;
|
||||
unsigned r_data_len;
|
||||
if (scheme == EFUSE_CODING_SCHEME_3_4) {
|
||||
@ -183,12 +200,13 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
|
||||
} while ((!correct_written_data || coding_error_occurred) && repeat_burn_op++ < 3);
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
}
|
||||
if (coding_error_occurred) {
|
||||
ESP_LOGE(TAG, "Coding error occurred in block");
|
||||
}
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -196,6 +214,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
#endif // CONFIG_EFUSE_VIRTUAL
|
||||
esp_efuse_utility_reset();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_efuse_utility_apply_34_encoding(const uint8_t *in_bytes, uint32_t *out_words, size_t in_bytes_len)
|
||||
|
@ -116,7 +116,7 @@ void esp_efuse_utility_clear_program_registers(void)
|
||||
}
|
||||
|
||||
// Burn values written to the efuse write registers
|
||||
void esp_efuse_utility_burn_efuses(void)
|
||||
esp_err_t esp_efuse_utility_burn_efuses(void)
|
||||
{
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL
|
||||
ESP_LOGW(TAG, "Virtual efuses enabled: Not really burning eFuses");
|
||||
@ -135,6 +135,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
for (int num_block = EFUSE_BLK_MAX - 1; num_block >= EFUSE_BLK0; num_block--) {
|
||||
for (uint32_t addr_wr_block = range_write_addr_blocks[num_block].start; addr_wr_block <= range_write_addr_blocks[num_block].end; addr_wr_block += 4) {
|
||||
if (REG_READ(addr_wr_block) != 0) {
|
||||
ets_efuse_clear_program_registers();
|
||||
if (esp_efuse_get_coding_scheme(num_block) == EFUSE_CODING_SCHEME_RS) {
|
||||
uint8_t block_rs[12];
|
||||
ets_efuse_rs_calculate((void *)range_write_addr_blocks[num_block].start, block_rs);
|
||||
@ -175,12 +176,13 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
|
||||
} while ((!correct_written_data || coding_error_occurred) && repeat_burn_op++ < 3);
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
}
|
||||
if (coding_error_occurred) {
|
||||
ESP_LOGE(TAG, "Coding error occurred in block");
|
||||
}
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -188,6 +190,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
#endif // CONFIG_EFUSE_VIRTUAL
|
||||
esp_efuse_utility_reset();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// After esp_efuse_write.. functions EFUSE_BLKx_WDATAx_REG were filled is not coded values.
|
||||
|
@ -97,7 +97,7 @@ void esp_efuse_utility_clear_program_registers(void)
|
||||
}
|
||||
|
||||
// Burn values written to the efuse write registers
|
||||
void esp_efuse_utility_burn_efuses(void)
|
||||
esp_err_t esp_efuse_utility_burn_efuses(void)
|
||||
{
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL
|
||||
ESP_LOGW(TAG, "Virtual efuses enabled: Not really burning eFuses");
|
||||
@ -116,6 +116,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
for (int num_block = EFUSE_BLK_MAX - 1; num_block >= EFUSE_BLK0; num_block--) {
|
||||
for (uint32_t addr_wr_block = range_write_addr_blocks[num_block].start; addr_wr_block <= range_write_addr_blocks[num_block].end; addr_wr_block += 4) {
|
||||
if (REG_READ(addr_wr_block) != 0) {
|
||||
ets_efuse_clear_program_registers();
|
||||
if (esp_efuse_get_coding_scheme(num_block) == EFUSE_CODING_SCHEME_RS) {
|
||||
uint8_t block_rs[12];
|
||||
ets_efuse_rs_calculate((void *)range_write_addr_blocks[num_block].start, block_rs);
|
||||
@ -156,12 +157,13 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
|
||||
} while ((!correct_written_data || coding_error_occurred) && repeat_burn_op++ < 3);
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
}
|
||||
if (coding_error_occurred) {
|
||||
ESP_LOGE(TAG, "Coding error occurred in block");
|
||||
}
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -169,6 +171,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
#endif // CONFIG_EFUSE_VIRTUAL
|
||||
esp_efuse_utility_reset();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// After esp_efuse_write.. functions EFUSE_BLKx_WDATAx_REG were filled is not coded values.
|
||||
|
@ -97,7 +97,7 @@ void esp_efuse_utility_clear_program_registers(void)
|
||||
}
|
||||
|
||||
// Burn values written to the efuse write registers
|
||||
void esp_efuse_utility_burn_efuses(void)
|
||||
esp_err_t esp_efuse_utility_burn_efuses(void)
|
||||
{
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL
|
||||
ESP_LOGW(TAG, "Virtual efuses enabled: Not really burning eFuses");
|
||||
@ -116,6 +116,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
for (int num_block = EFUSE_BLK_MAX - 1; num_block >= EFUSE_BLK0; num_block--) {
|
||||
for (uint32_t addr_wr_block = range_write_addr_blocks[num_block].start; addr_wr_block <= range_write_addr_blocks[num_block].end; addr_wr_block += 4) {
|
||||
if (REG_READ(addr_wr_block) != 0) {
|
||||
ets_efuse_clear_program_registers();
|
||||
if (esp_efuse_get_coding_scheme(num_block) == EFUSE_CODING_SCHEME_RS) {
|
||||
uint8_t block_rs[12];
|
||||
ets_efuse_rs_calculate((void *)range_write_addr_blocks[num_block].start, block_rs);
|
||||
@ -156,12 +157,13 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
|
||||
} while ((!correct_written_data || coding_error_occurred) && repeat_burn_op++ < 3);
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
}
|
||||
if (coding_error_occurred) {
|
||||
ESP_LOGE(TAG, "Coding error occurred in block");
|
||||
}
|
||||
if (!correct_written_data) {
|
||||
ESP_LOGE(TAG, "Written data are incorrect");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -169,6 +171,7 @@ void esp_efuse_utility_burn_efuses(void)
|
||||
}
|
||||
#endif // CONFIG_EFUSE_VIRTUAL
|
||||
esp_efuse_utility_reset();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// After esp_efuse_write.. functions EFUSE_BLKx_WDATAx_REG were filled is not coded values.
|
||||
|
@ -90,7 +90,7 @@ esp_err_t esp_efuse_write_field_blob(const esp_efuse_desc_t* field[], const void
|
||||
if (err == ESP_OK) {
|
||||
err = esp_efuse_utility_apply_new_coding_scheme();
|
||||
if (err == ESP_OK) {
|
||||
esp_efuse_utility_burn_efuses();
|
||||
err = esp_efuse_utility_burn_efuses();
|
||||
}
|
||||
}
|
||||
esp_efuse_utility_reset();
|
||||
@ -125,7 +125,7 @@ esp_err_t esp_efuse_write_field_cnt(const esp_efuse_desc_t* field[], size_t cnt)
|
||||
if (err == ESP_OK) {
|
||||
err = esp_efuse_utility_apply_new_coding_scheme();
|
||||
if (err == ESP_OK) {
|
||||
esp_efuse_utility_burn_efuses();
|
||||
err = esp_efuse_utility_burn_efuses();
|
||||
}
|
||||
}
|
||||
esp_efuse_utility_reset();
|
||||
@ -189,7 +189,7 @@ esp_err_t esp_efuse_write_reg(esp_efuse_block_t blk, unsigned int num_reg, uint3
|
||||
if (err == ESP_OK) {
|
||||
err = esp_efuse_utility_apply_new_coding_scheme();
|
||||
if (err == ESP_OK) {
|
||||
esp_efuse_utility_burn_efuses();
|
||||
err = esp_efuse_utility_burn_efuses();
|
||||
}
|
||||
}
|
||||
esp_efuse_utility_reset();
|
||||
@ -272,7 +272,7 @@ esp_err_t esp_efuse_batch_write_commit(void)
|
||||
if (--s_batch_writing_mode == 0) {
|
||||
esp_err_t err = esp_efuse_utility_apply_new_coding_scheme();
|
||||
if (err == ESP_OK) {
|
||||
esp_efuse_utility_burn_efuses();
|
||||
err = esp_efuse_utility_burn_efuses();
|
||||
ESP_LOGI(TAG, "Batch mode. Prepared fields are committed");
|
||||
} else {
|
||||
esp_efuse_utility_reset();
|
||||
|
Loading…
Reference in New Issue
Block a user