How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

BlueJay
Posts: 2
Joined: Thu Apr 13, 2023 9:09 pm

How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

Postby BlueJay » Thu Apr 13, 2023 9:20 pm

I would like to store the PCB revision number in an efuse so that it's unaffected by changes in firmware code.

I've read all the documentation regarding efuses (for example https://docs.espressif.com/projects/esp ... use-fields ).

However, I've come unstuck - everything uses IDF, and I'm using ESP32-Arduino (via platformio). Is there any documentation on using the EFuses via arduino somewhere that I can refer to? I don't have `idf.py`, `efuse_table_gen.py` or even the csv file(s) as far as I can see. I do have the `espefuse.py` script, but I don't think that's much use without having first set up the items in the custom csv table and created the headers etc?

Googling hasn't helped - everything points to the IDF documentation. Please can someone get me started :)

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

Postby lbernstone » Fri Apr 14, 2023 4:07 am

There's no "create" efuses. These are hardware registers, so the space is pretty much fixed. Keep in mind that changes you make in efuses are permanent. If you will ever need to change this information, you should be using nvs (or Preferences) instead.
arduino-esp32 is built on esp-idf, so all those functions (well, most of them) are available to use in arduino. You should be able to use the example to piece together the commands and includes needed to make it work.
The espefuse tools are located at https://github.com/espressif/esptool
The example is at https://github.com/espressif/esp-idf/tr ... stem/efuse
Docs, which I think you have already found, are at https://docs.espressif.com/projects/esp ... efuse.html

BlueJay
Posts: 2
Joined: Thu Apr 13, 2023 9:09 pm

Re: How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

Postby BlueJay » Fri Apr 14, 2023 8:58 am

Thanks for the reply @lbernstone

I should have been more careful in my wording - I do understand what the Efuses are and am familiar with NVS. I'm looking to permanently store a read-only PCB version value for example. When I referred to "creating" them, I meant the process of defining an efuse in the custom table and generating the C header to access it by name, as detailed in your second link - following by burning the fuses - using the tools and code available in ESP32 Arduino. The information in your second link (and in fact all of the documentation including your third link) refers to using some python scripts and IDF functions that are not available on Arduino. As I put in my original post, I have the espefuse.py tools included in your first link, but not idf.py to process the csv and generate the c headers.

So to reword and hopefully clarify my question:
1. Using ESP32 Arduino, how do we create/ process the csv file and turn it into the C headers as detailed here: https://docs.espressif.com/projects/esp ... -component
2. Assuming someone can help with step 1 (or tell us how to avoid it), how do we then write the required efuse values, and read them from Arduino code. All documentation refers to ESP-IDF, I'm struggling to find anything that references Arduino.

proddy
Posts: 2
Joined: Tue Jan 09, 2018 10:16 pm

Re: How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

Postby proddy » Mon Sep 09, 2024 8:29 am

Hi BlueJay, I'm looking for something similar in Arduino. Before I dive into all the docs and code examples, did you get anywhere with this?

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: How do you create/ write/ read efuses with ESP32 Arduino? Are there any docs?

Postby lbernstone » Mon Sep 09, 2024 3:39 pm

There's no tools to do this in arduino-esp32, because that's not what Arduino is about. arduino-esp32 is an abstraction layer built on top of esp-idf to provide the cross-platform functionality that is Arduino. ESP-IDF is still there under arduino-esp32, and you are welcome to use its functions.
If you want to modify the efuse hardware, you need to use the tools designed for modifying the specific hardware, which are the esptools and the efuse functions in esp-idf. Messing with efuses is one of the few ways to brick an esp32, so be careful.

Who is online

Users browsing this forum: No registered users and 128 guests