Home/Support/Support Forum/Driving Pin 37 of CC i.MX28
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Driving Pin 37 of CC i.MX28

0 votes
Hello,

my goal is to change the output value of pin 37 of the CC i.MX28.

I understood, that i have to use the functions from sys/iotcl.h

But i dont know how to figure out how to open the pin with the 'open' function.

The GPIO example only works after i used the command "modprobe gpio". Serious? Do i have to make that call every time i start the system?

Than it was hard too find the correct gpio.h - before taking a look at the gpio example.

Now i understood that i have to create an device node. But i have no idea what to type in here..? The example "mknod 48 c 240 48" - what is happening here?

I guess 'c' is the mode. But 240, than again 48? I have no idea..

Can anybody help me with this problem?

Nils
asked Oct 28, 2015 in Embedded Devices by Curby New to the Community (2 points)

Please log in or register to answer this question.

2 Answers

0 votes
It would be nice to know witch OS you are using, let me guess.. DEL?
-modprobe gpio: yes you have to load the gpio module every time you start the system. This can be done automatically by putting gpio in /etc/modules.conf

-im not into DEL anymore cause im using DEY but as i can remember you have to tell the system witch GPIO is used. so iirc pin37 is GPIO2_12 -> gpio76 -> "mknod 76 c 240 76"

-i think you also can access gpio via sysfs (not sure if this works in DEL). try this in your command line:
#echo 76 > /sys/class/gpio/export
#echo out > /sys/class/gpio76/direction
#echo 0 > /sys/class/gpio76/value
#echo 1 > /sys/class/gpio76/value

1. export the gpio
2. set it to out (or input)
3./4. on/off

when this works you can write a initscript to export all your used gpios at bootup
answered Oct 29, 2015 by floko New to the Community (3 points)
0 votes
I assume you are using DEL because you mention GPIO module.

>The GPIO example only works after i used the command "modprobe gpio".

The GPIO example is more of an "How to write Linux kernel module" example than "How to use GPIO" example

>Serious?
Yes :)

>Do i have to make that call every time i start the system?
There are number of standard Linux autostart scripts so technically you can automate this, but then again, kernel module has no point if you are loading it on every boot.
Please use sysfs driver instead.

Per DigiESP online help:
The GPIOs can be easily accessed from the sysfs. GPIO sysfs support can be enabled in Linux Kernel Configuration > Device Drivers > GPIO Support > /sys/class/gpio/... (sysfs interface).


For information about how to manage the GPIOs from sysfs, refer to the Linux kernel documentation at kernel/linux-2.6.35/Documentation/gpio.txt

DEL online help explains the mknode part:

GPIO device nodes must be manually created, one per GPIO pin. First, create a container folder named /dev/gpio. Then add to that location a character node with major number 240 and a minor number that matches the GPIO number. For simplicity, this example names the GPIO pins by their numbers, as shown below:



# mkdir /dev/gpio
# cd /dev/gpio
# mknod 48 c 240 48
# mknod 53 c 240 53
# mknod 60 c 240 60
# ls -l
crw-rw---- 1 root root 240, 48 Jan 1 1970 48
crw-rw---- 1 root root 240, 53 Jan 1 1970 53
crw-rw---- 1 root root 240, 60 Jan 1 1970 60

Alternatively, to have the system create the device nodes after startup, edit the special system file /etc/makedevs.d/platformname with entries for creating the gpio folder and the required device nodes. For example:



# Example:
#<name> <type><mode><uid><gid><major><minor><start><inc><count>
/dev/gpio d 755
/dev/gpio/48 c 660 0 0 240 48
/dev/gpio/53 c 660 0 0 240 53
/dev/gpio/60 c 660 0 0 240 60

Depending on the platform, the /etc/makedevs.d/platformname file may already contain instructions to create the container folder /dev/gpio and nodes for certain GPIOs.

If you'd like to understand more about the magic behind those numbers i'd recommend buying a good Linux developer's book.

Here is a link to freescale forum with some more explanations and examples (3rd post):

https://community.freescale.com/thread/316241
answered Oct 29, 2015 by LeonidM Veteran of the Digi Community (3,656 points)
...