esp32 UART FIFO read

szmodz
Posts: 8
Joined: Thu Mar 21, 2019 10:11 am

esp32 UART FIFO read

Postby szmodz » Mon May 22, 2023 11:53 am

Hi,

I'm trying to figure out the reason behind the NOP in ESP32 uart_ll_read_rxfifo

https://github.com/espressif/esp-idf/bl ... _ll.h#L203

Is this related to esp32 errata 3.16 ?

szmodz
Posts: 8
Joined: Thu Mar 21, 2019 10:11 am

Re: esp32 UART FIFO read

Postby szmodz » Mon May 22, 2023 12:13 pm

The wording in errata 3.16 (plural workarounds) would seem to imply that you either need to use a memw instruction / volatile keyword (which should be handled by the READ_PERI_REG macro), or insert 7 NOPs.

So it doesn't explain this NOP (using READ_PERI_REG should be enough), or is there another reason behind it ?

Unless the errata actually describes two steps of a single workaround?

MicroController
Posts: 1726
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: esp32 UART FIFO read

Postby MicroController » Tue May 23, 2023 11:54 am

It seems that MEMW would solve the speculative/lost access but maybe not the FIFO pointer update timing issue. Given that the NOP is only conditionally used when compiler optimizations are on, I guess that someone found that the "worst-case" (i.e. fastest) iteration time for this particular loop when optimized was just short of the time required.
It's also possible that the single volatile asm statement just serves to prevent gcc from doing certain optimizations, thus achieving the minimum iteration timing required.

szmodz
Posts: 8
Joined: Thu Mar 21, 2019 10:11 am

Re: esp32 UART FIFO read

Postby szmodz » Fri May 26, 2023 10:34 pm

yup.

Who is online

Users browsing this forum: No registered users and 141 guests