GPIO writes are going through cache with WRITE_BACK #350
-
Hi all, I'm currently trying to get a realtime-simulation working through the IO port of a Raspberry Pi Zero 2 W and I noticed that all my timing was WAY off. Love the project btw.!, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 10 replies
-
Hi Dirk, I don't understand this, because I suppose, the I/O memory space is already set to uncached "shared device" mode: https://github.com/rsta2/circle/blob/master/lib/pagetable.cpp#L77 Can you please post your own modifications to /lib/pagetable.cpp? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Sure.
Cheers, |
Beta Was this translation helpful? Give feedback.
-
The setting, you have modified, depends on the memory attributes of the memory space, where the page (aka translation) table is located in memory. It is used for the page table walks. This memory is definitely write-back, so the setting should be OK in Circle. It may affect the timing of your application, when you modify this setting, but in an unknown way. I cannot see a reason, why this setting should be modified in Circle. I have to say, that your timing requirements (80ns resolution) are near to the limits, which are possible with the GPIO hardware of the Raspberry Pi. I read about Circle-based applications, which are able to handle this, but they spent a lot of time to get it working. I suppose, you have to use the class |
Beta Was this translation helpful? Give feedback.
-
@rsta2 I want to update this, because I found my bug, and it was sort-of a surprise to me. |
Beta Was this translation helpful? Give feedback.
-
Thanks, but I think, this is not necessary. I did some tests now on a Raspberry Pi Zero 2 W with this class, which is derived from
Core 1 turns the rotor. Core 2 continuously writes an inverted value to pin 17, which is connected to pin 18 on the 40-pin header. After a delay pin 18 is read and compared with the written value. If the values differ, a warning is shown (which never happens). The delay is necessary, because the CPU cores both use the bus and compete for bus time. It takes some time, to write the current rotor character through to the SDRAM, so that the VC4 can read the pixel values to write them out through the HDMI port. Core 3 continuously reads a register from another I/O device (the system timer), which is a micro-seconds up-counter. The warning is never shown, so there is no interference with the GPIO peripheral. To me everything seems to be OK here. The delay is not nice, but as I told, time critical operations should not overlap with framebuffer accesses. Remains the question, why Linux shows a different behavior here? I can only guess, this may be caused by the newer KMS architecture, where the main CPU manages the HDMI display, not the VC4. The framebuffer memory region could have a write back cache policy in this case and framebuffer writes do not need to go through to the SDRAM. So there is no competition for bus time with the GPIO peripheral. |
Beta Was this translation helpful? Give feedback.
The setting, you have modified, depends on the memory attributes of the memory space, where the page (aka translation) table is located in memory. It is used for the page table walks. This memory is definitely write-back, so the setting should be OK in Circle. It may affect the timing of your application, when you modify this setting, but in an unknown way. I cannot see a reason, why this setting should be modified in Circle.
I have to say, that your timing requirements (80ns resolution) are near to the limits, which are possible with the GPIO hardware of the Raspberry Pi. I read about Circle-based applications, which are able to handle this, but they spent a lot of time to get it working…