AHP or APB??

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

AHP or APB??

Postby Kaisha » Sat Oct 02, 2021 3:33 pm

In the ESP32 TRM we have a description of the AHP bus:
The CPU can access peripherals via DPORT address more efficiently than via AHB address. However,
DPORT address is characterized by speculative reads, which means it cannot guarantee that each read is
valid. In addition, DPORT address will upset the order of r/w operations on the bus to improve performance,
which may cause programs that have strict requirements on the r/w order to crash. On the other hand, using
AHB address to read FIFO registers will cause unpredictable errors. To address above issues please strictly
follow the instructions documented in ESP32 ECO and Workarounds for Bugs, specifically sections 3.3, 3.10,
3.16, and 3.17.
I'm not really sure what it stands for, and why there are two busses, and the ECO 'workarounds' doesn't really make it clear when to use DPORT and when the AHB bus... So looking through the esp idf code I come across:

https://github.com/espressif/esp-idf/bl ... t_access.h
// There are several ways to read the DPORT registers:
// 1) Use DPORT_REG_READ versions to be SMP-safe in IDF apps.
// This method uses the pre-read APB implementation(*) without stall other CPU.
// This is beneficial for single readings.
// 2) If you want to make a sequence of DPORT reads to buffer,
// use dport_read_buffer(buff_out, address, num_words),
// it is the faster method and it doesn't stop other CPU.
// 3) If you want to make a sequence of DPORT reads, but you don't want to stop other CPU
// and you want to do it faster then you need use DPORT_SEQUENCE_REG_READ().
// The difference from the first is that the user himself must disable interrupts while DPORT reading.
// Note that disable interrupt need only if the chip has two cores.
// 4) If you want to make a sequence of DPORT reads,
// use DPORT_STALL_OTHER_CPU_START() macro explicitly
// and then use _DPORT_REG_READ macro while other CPU is stalled.
// After completing read operations, use DPORT_STALL_OTHER_CPU_END().
// This method uses stall other CPU while reading DPORT registers.
// Useful for compatibility, as well as for large consecutive readings.
// This method is slower, but must be used if ROM functions or
// other code is called which accesses DPORT without any other workaround.
// *) The pre-readable APB register before reading the DPORT register
// helps synchronize the operation of the two CPUs,
// so that reading on different CPUs no longer causes random errors APB register.
And here we see reference to the APB bus...

Are the APB bus and AHB bus the same thing and this is just a typo?

Also, where is the DPORT_INTERRUPT_DISABLE macro defined?

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Re: AHP or APB??

Postby Kaisha » Wed Oct 06, 2021 6:10 pm

Anyone??

ESP_Dazz
Posts: 308
Joined: Fri Jun 02, 2017 6:50 am

Re: AHP or APB??

Postby ESP_Dazz » Sat Oct 09, 2021 6:19 am

To answer your questions directly:
I'm not really sure what it stands for
  • APB = Advanced Peripheral Bus (specification here)
  • AHB = Advanced High-performance Bus. IIRC the ESP32 uses AHB-Lite (specification here)
  • DPORT = Short for Data Port. The full name is Xtensa Local Memory Interface (XLMI) Port. Can't send you a spec here unfortunately as Xtensa specifications can only be obtained under an NDA.
and why there are two busses
Because in modern microprocessors/SoCs, it is common for a CPU to have multiple ports, each connecting to one or more bus hierarchies. See and ARM Processor as an example. Each port is mapped to a separate address range, and the CPU will internally DeMux the access to the correct port based on address range.

Moreover, it is possible that:
  • The same piece of physical memory/registers can be accessed by two or more ports
  • The same piece of physical memory can be exclusive to a particular CPU, or shared (i.e., global) amongst multiple CPUs
  • It is also possible that two ports can end up accessing the same child bus via an arbiter.
Are the APB bus and AHB bus the same thing and this is just a typo?
Not a typo. AHB and APB are different. It is not uncommon (and is the case for the ESP32) that the APB bus is a child bus of the AHB within a bus hierarchy. See the Multi-layer AHB specification as an example.
Also, where is the DPORT_INTERRUPT_DISABLE macro defined?
Currently on the master branch, DPORT_INTERRUPT_DISABLE macro is defined here.

W.R.T macro usage:
  • There are a couple of HW bugs in the ESP32 (different bugs apply to different chip revisions) that can corrupt read/writes when the DPort is accessed under certain conditions (e.g., another CPU accessing a particular address range simultaneously).
  • As per the comment, multiple workaround macros have been offered, each optimized to a particular type of usage (e.g., whether you're only reading a particular DPORT register, or need to read a series of DPORT registers
  • The pre-readable APB register is one of the workarounds offered, where before a DPORT register is accessed, a random register (basically just a date register) is read first. Again, remember that SoCs can have multiple bus hierarchies, thus why reading the APB bus can affect the DPORT bus (thus working around the HW bug).

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Re: AHP or APB??

Postby Kaisha » Thu Oct 14, 2021 9:53 am

Appreciate the info.

moefear85
Posts: 41
Joined: Sun Sep 05, 2021 4:55 pm

Re: AHP or APB??

Postby moefear85 » Mon Jul 11, 2022 12:18 am

and all of this confusion only applies to esp32? or are there similar errata for esp32-s2 and esp32-s3?

ESP_Sprite
Posts: 8921
Joined: Thu Nov 26, 2015 4:08 am

Re: AHP or APB??

Postby ESP_Sprite » Mon Jul 11, 2022 1:07 am

It only applies to the -S2. We would have a different set of errata for the S2 and S3 if we would find issues like this in that silicon.

Who is online

Users browsing this forum: No registered users and 110 guests