Jump to content

Java based GPIO via MMIO fast (compared to gpiod)!


sgjava

Recommended Posts

OK, playing around with NanoPi Duo (H2+) to see what kind of performance boost I can get using MMIO (/dev/mem) instead of gpiod (forget sysfs) and it was pretty impressive. I used pre-calculated offset to run a square wave (rapid on/off) on pin 203 IOG11 and I hit ~3.8 MHz compared to ~500 KHz using gpiod. You can take a peek at the source at https://github.com/sgjava/java-periphery/blob/master/src/main/java/com/codeferm/periphery/demo/MmioTest.java. So the idea is how to make this generic with boards with multiple GPIO chips and different register configurations. The cool thing is the underlying MMIO stuff is kernel cross platform. Any ways I've been thinking about this for a while and now it's more of a reality.

 

This was with 32 bit writes, I haven't tried 8 bit writes to see what the difference is.

 

18:20:05.423 [main] INFO  com.codeferm.periphery.demo.MmioTest - 3832959.62 writes per second

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines