Information on using GPIO's on ARM Cortex A8

Thread Starter

dl324

Joined Mar 30, 2015
18,328
I've started experimenting with the $9 C.H.I.P. computer based on this processor and am looking for information regarding where to get libraries to access the GPIO's.

The makers of CHIP (Next Thing Co), provided examples accessing the GPIO's from the shell using a sysfs interface. I'm looking for something more direct, hoping it will be faster. The fastest I can toggle the I/O's using the sysfs interface from C is about 2KHz and that won't be fast enough for the applications I have in mind.

Thanks in advance for any replies.
 

nsaspook

Joined Aug 27, 2009
16,323
I've started experimenting with the $9 C.H.I.P. computer based on this processor and am looking for information regarding where to get libraries to access the GPIO's.

The makers of CHIP (Next Thing Co), provided examples accessing the GPIO's from the shell using a sysfs interface. I'm looking for something more direct, hoping it will be faster. The fastest I can toggle the I/O's using the sysfs interface from C is about 2KHz and that won't be fast enough for the applications I have in mind.

Thanks in advance for any replies.
The ioctl interface is slow with all the abstraction layers from userland to kernel code and scheduling.. I haven't looked at the hardware details of the C.H.I.P. but with root access you should able to do direct register programming of GPIO similar to this.
http://elinux.org/RPi_GPIO_Code_Samples#Direct_register_access

With a Linux kernel module you can directly access memory mapped registers via the MMU with a ioremap instead of /dev/mem.
Code:
dev->iobase = GPIO_BASE; /* bcm iobase */
/*
* dev->mmio is a void pointer with 8bit pointer indexing,
* we need 32bit indexing so mmio is casted to a (__iomem uint32_t*)
* pointer for GPIO R/W operations
*/
dev->mmio = ioremap(dev->iobase, SZ_16K);
if (!dev->mmio) {
dev_err(dev->class_dev, "invalid gpio io base address!\n");
return -EINVAL;
}
http://www.makelinux.net/ldd3/chp-9-sect-4

https://bbs.nextthing.co/t/solved-gpio-direct-access/2971/3
The details are here somewhere.
https://github.com/NextThingCo/
 
Last edited:

Thread Starter

dl324

Joined Mar 30, 2015
18,328
The ioctl interface is slow with all the abstraction layers from userland to kernel code and scheduling.. I haven't looked at the hardware details of the C.H.I.P. but with root access you should able to do direct register programming of GPIO similar to this.
Thanks for the info.

It turns out that the GPIO's NTC "advertised" are on a separate chip that the processor communicates with over I2C, which makes them slow. If I use some of the IO's on the processor itself, they toggle at about 200kHz using the sysfs interface; that's sufficient for the projects I had in mind.
 

nsaspook

Joined Aug 27, 2009
16,323
Thanks for the info.

It turns out that the GPIO's NTC "advertised" are on a separate chip that the processor communicates with over I2C, which makes them slow. If I use some of the IO's on the processor itself, they toggle at about 200kHz using the sysfs interface; that's sufficient for the projects I had in mind.
Much better, 2KHz sounded very low even for the slowest direct processor ioctl based toggles.
 
Top