Page 1 of 1

Why are registers in esptool different from the technical reference and the source code?

Posted: Wed Jun 10, 2020 9:51 am
by JosuGZ
On the esptool we have this:

Code: Select all

    EFUSE_REG_BASE = 0x6001a000

    def read_efuse(self, n):
        """ Read the nth word of the ESP3x EFUSE region. """
        return self.read_reg(self.EFUSE_REG_BASE + (4 * n))
But according to the technical reference, the address should be 0x3FF5A000 and on soc.h we have `#define DR_REG_EFUSE_BASE 0x3ff5A000`.

Why this difference?

Re: Why are registers in esptool different from the technical reference and the source code?

Posted: Thu Jun 11, 2020 12:50 am
by Angus
Hi Josu,

Thanks for pointing this out. Some peripheral registers in ESP32 are actually mapped at two equivalent memory ranges in the address space (the buses are named DPORT and AHB). DPORT addresses start with 0x3FF and AHB addresses start with 0x600.

Performance is generally faster when accessing via DPORT. However there are some cases where one or the other bus must be used (see "ESP32 ECO and Workarounds for Bugs" document sections "3.3.When the CPU accesses peripherals and writes a single address repeatedly, some writes may be lost. " and "3.18.CPU has limitations when accessing peripherals in chips").

Early versions of ESP-IDF included duplicate register mappings for both DPORT and AHB ranges, but most duplicate AHB bus addresses have been removed from ESP32 TRM and ESP-IDF for simplicity and only DPORT bus addresses are documented.

Looks like the AHB addresses were not changed in esptool. None of the ECO document issues with address space access apply to esptool accesses, as these memory reads and writes happen with hundreds of other instructions executed in between each access. However it should be updated for consistency in any case.

Angus

Re: Why are registers in esptool different from the technical reference and the source code?

Posted: Thu Jun 11, 2020 8:04 am
by JosuGZ
How can I do the translation? Because when I look at the esptool addresses on the dataset I find nothing.

Re: Why are registers in esptool different from the technical reference and the source code?

Posted: Thu Jun 11, 2020 11:25 pm
by Angus
Hi Josu,

You should be able to substitute 0x6001A000 for 0x3FF5A000 and everything will still work, relative to the base address the registers are at the same offsets. Will update esptool to use the DPORT base addresses ASAP.

The read_efuse() function in esptool.py is mostly used to read the ESP32 registers EFUSE_BLK0_RDATA0_REG through EFUSE_BLK0_RDATA6_REG (it's also used in one instance to read the efuse EFUSE_BLK1_RDATAx_REG registers). You can find these registers documented in sections 20.4 & 20.5 of the ESP32 Technical Reference Manual, and there are definitions in the efuse_reg.h header of ESP-IDF.

Angus