|BeagleBone kernel module for fast GPIO access||Jerrill||3/23/12 7:34 AM|
I'm working on a BeagleBone project that needs to drive a few GPIO pretty fast (driving a 110-bit shift register, chip selects, etc. with a full SR update occurring every 4 ms). I've got my add-on hardware proven out using sys/class/gpio but it's way too slow. My next thought before going off and changing the hardware design is to write a kernel module to do the heavy lifting of driving the GPIO pins.
My initial attempts at building just a "Hello, World!" type module ultimately lead to a dead end with a missing header file that doesn't exist. I'm sure I'm missing something pretty simple (like a define somewhere that needs to be adjusted) but I would be eternally grateful to anyone who can know down the learning curve a bit.
Does anyone have a working example of how to build a kernel module that flashes, say, the USR3 LED without using sys/class/gpio. Source code and Makefile would be great. Thanks in advance for any assistance, links, etc.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Paul Maddox||3/23/12 7:40 AM|
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Andrey Nechypurenko||3/23/12 8:12 AM|
> Does anyone have a working example of how to build a kernel module that
You can take a look at the following source for the example how to
You can also take a look at the following article for some more
Since many months I want to re-write the code as a kernel module
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||David Goodenough||3/23/12 8:27 AM|
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Jason Kridner||3/23/12 8:56 AM|
>Would you not be better off writing some PRUSS code, and doing the GPIO
If just driving a shift register, using one of the synchronous serial
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Jerrill||3/23/12 9:10 AM|
I looked at the PRU module information in the Sitara Technical Reference Manual here:
Yes, it looks like this peripheral is intended for exactly what I want to do, though I've never used the peripheral before and would have some studying to do.
My background is firmware development (in C and assembly) on microcontrollers like the MSP430, 8050, PIC, etc. So I'm comfortable digesting this sort of documentation. However I'm new to ARM and new to Embedded Linux. What I'm missing is the experience with Linux to know how to even begin to interface to a GPIO (much less a PRU) from the higher level abstraction layers of the OS. Right now there is this big wall between me and all the horsepower the micro offers and it's called Linux and I'm just don't know enough (yet) to get around it.
Right now, my understanding is that unless I want to compile a custom kernel, then I need to build a custom kernel module. I don't know how to do either off the top of my head, but I imagine that the learning curve on the kernel module is less steep. I've done both in the past with some of the more commercial Linux versions following dirt simple tutorials, but haven't had much success doing the same for the BeagleBone yet.
Any direction is welcome. Thanks.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Jerrill||3/23/12 9:15 AM|
Yes, I designed the hardware so that I can use a SPI port as well but I do have some other chip select type IO I need to do. Again I still have the same problem with how to build a kernel module to run the SPI peripheral and the GPIO in for a close-to-realtime sort of application. Any tutorials are welcome.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Bas Laarhoven||3/23/12 10:57 AM|
On 23-3-2012 17:10, Jerrill wrote:Hi Jerill,I looked at the PRU module information in the Sitara Technical Reference Manual here:
You don't need to build a custom kernel module to use the PRUSS. You only need the uio_pruss module and a user space application to load and start a PRU.
I don't know if the uio_pruss module is enabled and built by default nowadays. If not, then you'll need to compile a kernel, or obtain the module from someone else.
It will be a steep learning curve, but all information is available if you search the newsgroup or otherwise ask around. And it's fun to do. You'll also find that the PRU is a fine design with plenty of debugging capabilities. Myself, I'm controlling 4 stepper motors with one PRU and each runs up to 60 kHz steprate (a limitation of the motor drivers, much headroom available). Acceleration is also done in the PRU. Linux is only used for the not hard-realtime code.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Bas Laarhoven||3/23/12 11:01 AM|
On 23-3-2012 18:57, Bas Laarhoven wrote:Oops, sorry for the typo in your name!On 23-3-2012 17:10, Jerrill wrote:I looked at the PRU module information in the Sitara Technical Reference Manual here:
|Re: BeagleBone kernel module for fast GPIO access||dogisfat||3/23/12 12:50 PM|
I have a working kernel module for toggling GPIO which was working on posting a guide to recreating. I don't know if it will be fast enough as the GPIO kernel module only toggles at a little greater than 2 MHz and is not as regular in period as a good pwm output or something of the like.
|Re: [beagleboard] Re: BeagleBone kernel module for fast GPIO access||Jack Mitchell||3/23/12 12:58 PM|
-- To join: http://beagleboard.org/discuss
I would also be interested in seeing an example of something like this. If not a guide, then just some example code would be nice to get me started!
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Jerrill||3/25/12 7:32 PM|
On Friday, March 23, 2012 1:57:35 PM UTC-4, Bas Laarhoven wrote:
The uio_pruss module sounds like it's the way I would like to go with my project. I did a locate for uio_pruss and pruss and pru and didn't find anything on the current Angstrom/Cloud9 SD card image, so I'm assuming that that means that it's not loaded by default.
I'm in the process of Googling to see what I need to do to find the source code and build the module (unless someone already has it built for 3.2.5+). If you have any information on where to get started (Linux newbie here... sorry...) I would greatly appreciate it.
Thank you in advance for any information you can provide.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Jack Mitchell||3/26/12 1:14 AM|
-- To join: http://beagleboard.org/discuss
I recently saw a commit by Koen enabling the PRU on the BeagleBone for the 3.2 kernel. Have you build the latest and greatest Angstrom image recently?
-- Jack Mitchell (ja...@embed.me.uk) Embedded Systems Engineer http://www.embed.me.uk --
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||dl4mea||3/29/12 11:38 PM|
I made an example how to access the GPIO directly through mmap which is here:
In the same way, I tested the toggle rate, and each pulse was 228ns wide, means 4MHz. Straight forward code, set and reset in a simple sequence.
|Re: BeagleBone kernel module for fast GPIO access||jduhamel||4/3/12 6:28 PM|
please let me know when you post the guide
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||jmelson||7/16/12 2:40 PM|
On Saturday, July 14, 2012 1:53:04 AM UTC-5, Hans wrote:
Yeah I'm trying to get faster GPIO throughput too and have been able to reach about 5MHz using mmap. But this is still way slower than should be achievable because I can reach speeds of >25MHz by writing bare metal code for the BeagleBone. Does anyone know if writing a kernel driver would allow access w/o mmap and maybe improve throughput?
My understanding is that using mmap you are already accessing the GPIO hardware at the lowest level. The trick they use to reduce power and
maybe complexity is to multiplex the GPIO by banks. On the original Beagle Board it is about 240 ns, apparently the bone cuts it to ~225 ns
with a faster clock, or maybe because it has fewer GPIO banks. So, I don't think you can go faster via GPIO accesses. When I started with this
I tried to figure out how to turn up the clock on the GPIO system, but I never got that to work.
At least what I've seen so far, there is no way to get 25 MHz out of the GPIO. Now, the MMC peripherals can go faster, but they are serial, so
that may not increase speed much over a byte-wide GPIO port.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Koen Kooi||8/2/12 11:08 PM|
Op 2 aug. 2012, om 22:05 heeft Hans <hans.a...@gmail.com> het volgende geschreven:
> But I've measured 25 MHz via GPIO by writing bare metal code for beaglebone so I know the chip can drive GPIO at least 25MHz. What is it about running under Angstrom and/or using mmap that's limiting us to 5 Mhz?
Userspace, just write a kernel driver, much better performance
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Francois||8/3/12 4:03 AM|
Would anyone have any example of how to write a kernel driver for gpio ?
On Friday, August 3, 2012 6:08:29 PM UTC+12, Koen Kooi wrote:
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Andrew Bradford||8/3/12 4:37 AM|
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||jmelson||8/3/12 9:28 AM|
It would be really helpful if there was a beagle-specific example. I assume
there are include files that perform the same thing as mmap in the kernel
environment, but are probably different.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||jmelson||8/3/12 9:29 AM|
|Re: Re: [beagleboard] BeagleBone kernel module for fast GPIO access||iceburg||8/3/12 9:31 AM|
I can ensure you that by using module, at least 10MHz were achieved by me.
The MANNUAL says Bank0 can works under 100MHz with proper configuration of clk, but only bank0.
if you set the registers and get this real, inform me please.
Looking forward your seccess.
主题：Re: [beagleboard] BeagleBone kernel module for fast GPIO access
|Re: Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Hans||8/3/12 9:41 AM|
Awesome, that's just what I wanted to hear. I won't be trying to reach 100 MHz, but if I have time to play with clk config I'll let you know.
|Re: [beagleboard] BeagleBone kernel module for fast GPIO access||Koen Kooi||8/3/12 10:38 AM|
There would be *nothing* beagle specific about it, it's just plain old linux.
|Re: BeagleBone kernel module for fast GPIO access||Dave H.||8/3/12 4:36 PM|
Jerrill et al,
Here is a GPIO module and accompanying userspace test program I wrote for Linux running on a Nios2 core (soft core for Altera).
The Makefile will build both. (test = builds userspace program, module builds module, all builds both)
fwti_gpio_test.c is the userspace program source.
fwti_gpio.c is the module source.
There isn't much platform-specific in there. Where you see NIOS2 for the architecture and calls to the nios2 gcc tools, you will need to switch it to use the ARM stuff.
I am in the process of converting this to Beagle. If you beat me to it, please send me your results!
|Re: BeagleBone kernel module for fast GPIO access||Wesley||8/30/12 2:05 PM|
I don't know if you finished but here are my results? I got up to 25MHz and I posted a discussion on it here:
On Friday, August 3, 2012 4:36:47 PM UTC-7, Dave H. wrote:
Jerrill et al,