How access GPIO pins on i.MX6q sabre lite board from Linux user space?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How access GPIO pins on i.MX6q sabre lite board from Linux user space?

4,442 次查看
josephzolyak
Contributor I

I want to access the GPIO pins and the General Purpose Timer (GPT) on my i.MX6q sabre lite board from Linux user space.

Is there something already built into the Linux kernel that allows me to program the hardware registers from my application

code? If so what is it?  If not, do I need to create a Linux device driver from scratch? (Is there any examples of device driver

code available for the sabre lite board to look at?)

I am porting over some code from a TI C6747 DSP chip over the to ARM Cortex-A9, and I want to do some benchmark

tests. I would like to toggle GPIO9 (pin 4 on connector J7) on the i.MX6q board to measure filter execution timing with

a scope. I was also interested in trying the General Purpose Timer to measure execution times. Any recommendation

on which method is more accurate when initiated from my application code running in Linux user space?  Thanks!

标签 (2)
标记 (5)
1 回复

865 次查看
AnsonHuang
NXP Employee
NXP Employee

Hi, Joseph

     There is a lot of GPIO access from userspace discussion in this community, you can search "GPIO" to get them, for example, I have this topic come out when doing the search "https://community.freescale.com/message/254497#254497", there is also document in linux DOC, Documentation/gpio.txt , you can also refer to it.

     If they are all too complicated, you can also try a simple way to achieve your goal, there is a memtool in /unit_tests of our rootfs, you can use it to access almost all the register you want, so you can setup GPIO, and toggle it via access its register directly(generally, you only need to config a pin's IOMUX to GPIO, then set GPIO's direction and output value). For GPT, if you want to access directly instead of calling linux API to get the time you want, you can just read the GPT's CNT register to get what you want, its freq should be 3MHz, you can also test its freq with two read in a fixed time, such as read it via "/unit_tests/memtool 0x2098024", after 5 secs, read it again, then count its freq. Now, we know how to read the GPT counter and its freq, you can measure the execution times. The GPT is running counting up.