Giter Club home page Giter Club logo

Comments (9)

thanhtam-h avatar thanhtam-h commented on June 8, 2024 2

ioctl is used to transfer data between user space app with Linux driver, not between driver to physical layer (spi hardware). This approach need a native Linux driver running (loaded) and it doesn't guarantee realtime behavior. This method is found in wiringPi library
Using mmap you can (somehow) directly access physical layer from user space and avoid the use of Linux driver, so it is for solving realtime issue. If you closely look at native Linux spi driver, you can see in probe function, devm_ioremap_resource is called, that call is equivalent to mmap but used in kernel space, it makes physical memory available for that driver.
There is another approach guaranteeing realtime property, that is you can use Xenomai SPI RTDM driver. This is special driver for realtime purpose and only work in Xenomai. In this case you can use ioctl from user space. This approach is much more complicated than mmap, I have tried but didn't see much improvement compared to mmap, so I decided to use mmap.
I think you should read more about Linux driver, check this book : https://lwn.net/Kernel/LDD3/

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

May be I find the point:
The ARM use BCM2835 SPI controller, which use DMA naturally.
The normal Linux (X86) most use PIO controller without DMA.

from soem-w5500-rpi.

thanhtam-h avatar thanhtam-h commented on June 8, 2024

In Linux you can't directly access physical SoC's memory as with bare metal MCU (like AVR, PIC, ARM Cotex,..). You should use mmap to map physical memory into virtual space and then access to/from that space.
Function mmap only do memory mapping job, in order to control device's peripherals (GPIO, SPI, I2C, UART,...) you have to read chip's datasheet and control corresponded registers of each peripheral, just like what you do on bare metal MCU. This is the way I used for my driver .
Several references for you:

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

Thanks for your references!
Is mmap equals to DMA here? As I know, the DMA contains mmap.

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

And, why not directly use DMA rather than mmap under ARM?

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

I mean, though use DMA in user space is difficult, but there still have people can do that.
Related links:

  1. https://forums.intel.com/s/question/0D50P0000490WHSSA2/spi-performance?t=1547520228654
  2. https://forums.intel.com/s/question/0D50P00004905vGSAQ/low-speed-spi-port-pauses-on-minnowboard-max?language=en_US&wapkw=pxa2xx

But I have yet to work it through.

from soem-w5500-rpi.

thanhtam-h avatar thanhtam-h commented on June 8, 2024

First DMA is not an alternative of mmap, and second it depends on each SoC.
Anyway, It is out of this repository's scope so I suggest to close it

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

Thank you for your patient explanation.
Well, I got you.
You mean that the spi driver like wiringPi can be replaced by mmap.
And, do you have the comparison of speed before and after using mmap?
Ps: The linux spi driver always use ioctl() function to transfer data.

from soem-w5500-rpi.

littleggghost avatar littleggghost commented on June 8, 2024

Really thanks for your patience and professionalism. I will keep working on it.

from soem-w5500-rpi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.