Comments (9)
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.
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.
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:
- BCM2835 ARM Peripherals: https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
- RPI GPIO direct control using mmap: https://elinux.org/RPi_GPIO_Code_Samples
- Search for 'bcm2835 library', it is open source library for rpi which implement mmap for almost every peripheral of rpi.
from soem-w5500-rpi.
Thanks for your references!
Is mmap equals to DMA here? As I know, the DMA contains mmap.
from soem-w5500-rpi.
And, why not directly use DMA rather than mmap under ARM?
from soem-w5500-rpi.
I mean, though use DMA in user space is difficult, but there still have people can do that.
Related links:
- https://forums.intel.com/s/question/0D50P0000490WHSSA2/spi-performance?t=1547520228654
- 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.
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.
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.
Really thanks for your patience and professionalism. I will keep working on it.
from soem-w5500-rpi.
Related Issues (20)
- How to use it to control 2 slaves? HOT 1
- can it work on beaglebone black? HOT 4
- Map script gets stuck with 100% CPU HOT 5
- raspberry pi 4 HOT 1
- About the shift_time = 380000; HOT 2
- PDO mapping for Ezi-Servo Fastech Drive HOT 1
- Issues with RPI4 (4Gb), wiz550 and prebuilt kernel HOT 6
- Segmentation Fault with c++ HOT 1
- RPI 4 built-in NIC
- Xenomai task/thread APIs HOT 2
- Usage with a cython wrapper. HOT 4
- w5500 connect to ethercat io board
- I have a question about the CSP
- 64 bit version
- 64 bit version
- Awesome work!
- Can U add some delay for link? HOT 3
- How to get an EtherCAT slave? HOT 2
- Is the Beckhoff PLC necessary? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soem-w5500-rpi.