espefuse.py Alternative

Aidin77
Posts: 17
Joined: Thu Apr 19, 2018 6:56 pm

espefuse.py Alternative

Postby Aidin77 » Sun Feb 07, 2021 5:37 pm

According to https://docs.espressif.com/projects/esp ... ments.html

components/esptool_py/esptool/espefuse.py set_flash_voltage 3.3V

This command will burn the XPD_SDIO_TIEH, XPD_SDIO_FORCE, and XPD_SDIO_REG eFuses.

could I replacing the above command with this program ?

Code: Select all

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_spi_flash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "sdkconfig.h"
#include "driver/periph_ctrl.h"
#include "soc/rtc_cntl_reg.h"
#include "rom/efuse.h"
#include "soc/efuse_reg.h"
#include "soc/soc.h"
#include "esp_efuse.h"
#include "esp_log.h"

static const char *TAG = "efuse";

void setup(){  
  bool burned = false;
  
  printf("\nWarning! Once the eFuses are burned you cannot revert back!");
  vTaskDelay(5000 / portTICK_PERIOD_MS);
  
  
  
  //burning BLOCK3 bit0
  if (!!(REG_READ(EFUSE_BLK0_RDATA4_REG) & EFUSE_RD_SDIO_TIEH) == 0) { //check if eFuse was previously burned (if not burned eFuse == 0)
        ESP_EARLY_LOGI(TAG, "\nBurning EFUSE_BLK0_WDATA4_RE fuse EFUSE_RD_SDIO_TIEH to 1");
        esp_efuse_reset();
        REG_WRITE(EFUSE_BLK0_RDATA4_REG, EFUSE_RD_SDIO_TIEH);
    esp_efuse_burn_new_values();
    burned = true;
    }else{
    printf("\nSDIO_TIEH already burned");
  }
  
  //burning SDIO_FORCE
  if (!!(REG_READ(EFUSE_BLK0_RDATA4_REG) & EFUSE_RD_SDIO_FORCE) == 0) {
        ESP_EARLY_LOGI(TAG, "\nBurning EFUSE_BLK0_WDATA4_RE fuse EFUSE_RD_SDIO_FORCE to 1");
        esp_efuse_reset();
        REG_WRITE(EFUSE_BLK0_WDATA4_REG, EFUSE_RD_SDIO_FORCE);
    esp_efuse_burn_new_values();
    burned = true;
    }else{
    printf("\nSDIO_FORCE already burned");
  }
  
  //burning SDIO_REG
  if (!!(REG_READ(EFUSE_BLK0_RDATA4_REG) & EFUSE_RD_XPD_SDIO_REG) == 0) {
        ESP_EARLY_LOGI(TAG, "\nBurning EFUSE_BLK0_WDATA4_RE fuse EFUSE_RD_XPD_SDIO_REG to 1");
        esp_efuse_reset();
        REG_WRITE(EFUSE_BLK0_WDATA4_REG, EFUSE_RD_XPD_SDIO_REG);
    esp_efuse_burn_new_values();
    burned = true;
    }else{
    printf("\nSDIO_REG already burned");
  }
  
  if(burned)
    printf("\nFuses burned!");
  else
    printf("\nFuses already burned!");
  
  for (int i = 5; i >= 0; i--) {
        printf("\nRestarting in %d seconds...\n", i);
        vTaskDelay(1000 / portTICK_PERIOD_MS);
    }
    printf("\nRestarting now.\n");
    fflush(stdout);
    esp_restart();
}

void loop() {
  // put your main code here, to run repeatedly:

}

Who is online

Users browsing this forum: No registered users and 306 guests