Jump to content


Photo

Fedora 23 on pcduino3 nano lite GPIO issue

pcduino3 nano lite fedora 23 gpio

  • Please log in to reply
9 replies to this topic

#1 macemoneta

macemoneta

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationNJ

Posted 16 January 2016 - 07:06 AM

Fedora 23 boots and runs fine, but I'm having a problem with GPIOs.

 

From the command line, I can export a GPIO:

echo 2 >/sys/class/gpio/export

But if I try to set it to output:

echo out > /sys/class/gpio/gpio2/direction

the pcduino immediately hard locks requiring a reset. I've tried this with the 4.3.3 kernel and the 4.4.0 kernel. Nothing is actually connected to the GPIO or other pins on the pcduino.

 

 



#2 youkee

youkee

    Advanced Member

  • Administrators
  • 237 posts

Posted 16 January 2016 - 08:55 AM

I think the GPIO drivers is not available, so you can't control GPIO.



#3 macemoneta

macemoneta

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationNJ

Posted 16 January 2016 - 09:47 AM

OK, I found the info. The mainline kernel which is used by Fedora doesn't use the pin mapping, so you have to calculate the sysfs GPIO from the port number, using the formula:

(position of letter in alphabet - 1) * 32 + pin number

If the port is Pxnn, you take the position of the letter 'x' in the alphabet, and 'nn' is the pin number. So gpio pin 2 is port PH07, which has x=H (the 8th letter of the alphabet) and nn=7. Plugging that in, you get:

(8-1)*32+7=231

So to use gpio pin 2:

echo 231 >/sys/class/gpio/export
echo out > /sys/class/gpio/gpio231/direction

I made a quick reference for the pcduino3 nano lite:

gpio_pin_0 = port:PI19 = sysfs:275
gpio_pin_1 = port:PI18 = sysfs:274
gpio_pin_2 = port:PH07 = sysfs:231
gpio_pin_3 = port:PH06 = sysfs:230
gpio_pin_4 = port:PH08 = sysfs:232
gpio_pin_5 = port:PB02 = sysfs:34
gpio_pin_6 = port:PI03 = sysfs:265
gpio_pin_7 = port:PH09 = sysfs:233
gpio_pin_8 = port:PH10 = sysfs:234
gpio_pin_9 = port:PH05 = sysfs:229
gpio_pin_10 = port:PI10 = sysfs:266
gpio_pin_11 = port:PI12 = sysfs:268
gpio_pin_12 = port:PI13 = sysfs:269
gpio_pin_13 = port:PI11 = sysfs:267

I hope that saves someone else the time hunting this down.


  • youkee and Drake411 like this

#4 youkee

youkee

    Advanced Member

  • Administrators
  • 237 posts

Posted 17 January 2016 - 04:31 AM

So it works? right?



#5 rgmhtt

rgmhtt

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 17 January 2016 - 05:33 AM

I am looking into using arduino IDE 1.6.4.  It is in the Fedora23-testing repo.  Install that, then look over at:

 

https://learn.adafru...o-v164/overview

 

To see how to add this as a supported board...



#6 macemoneta

macemoneta

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationNJ

Posted 17 January 2016 - 07:37 AM

So it works? right?

 

Yes, it works.  :)



#7 youkee

youkee

    Advanced Member

  • Administrators
  • 237 posts

Posted 17 January 2016 - 08:09 AM

Yes, it works.   :)

 

Wow, it is great!



#8 macemoneta

macemoneta

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationNJ

Posted 17 January 2016 - 12:56 PM

Wow, it is great!

 

Yes, mainline 4.4 kernel, latest Fedora software, what's not to like?   :)

 

Also, the onboard LEDs USR1 and USR2 (marked LED3 and LED4 on the board) can be controlled by:

# Remove from system control
modprobe -r leds-gpio

# Export the USR1 and USR2 LEDs
echo 239 > /sys/class/gpio/export
echo 240 > /sys/class/gpio/export

# Turn them on
echo 0 > /sys/class/gpio/gpio239/value
echo 0 > /sys/class/gpio/gpio240/value

# Turn them off
echo 255 > /sys/class/gpio/gpio239/value
echo 255 > /sys/class/gpio/gpio240/value

Very handy while testing.


  • Drake411 likes this

#9 nightseas

nightseas

    Member

  • Administrators
  • 23 posts

Posted 25 January 2016 - 10:15 AM

Yes, mainline 4.4 kernel, latest Fedora software, what's not to like?   :)

 

Also, the onboard LEDs USR1 and USR2 (marked LED3 and LED4 on the board) can be controlled by:

# Remove from system control
modprobe -r leds-gpio

# Export the USR1 and USR2 LEDs
echo 239 > /sys/class/gpio/export
echo 240 > /sys/class/gpio/export

# Turn them on
echo 0 > /sys/class/gpio/gpio239/value
echo 0 > /sys/class/gpio/gpio240/value

# Turn them off
echo 255 > /sys/class/gpio/gpio239/value
echo 255 > /sys/class/gpio/gpio240/value

Very handy while testing.

 

 

Brilliant! I've also verified it on Lubuntu 14.04.

 

But the LED pins may have some problems on reusing. Got an error when removing the led module:

linaro@Nano:~$ sudo modprobe -r leds-gpio
modprobe: ERROR: ../libkmod/libkmod-module.c:769 kmod_module_remove_module() could not remove 'leds_gpio': Function not implemented
 
My kernel version is also 4.4.0:
root@Nano:/home/linaro# uname -a
Linux Nano 4.4.0-rc1 #7 SMP Mon Jan 25 10:25:26 CET 2016 armv7l armv7l armv7l GNU/Linux

 

Can you share your kernel configurations? Or Any suggestions on the error?

 

Thanks.

BR//Xiaohai


Just a lazy rabbit~~


#10 macemoneta

macemoneta

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationNJ

Posted 30 January 2016 - 03:41 AM

The kernel configuration used by Fedora 23 for ARM:

 

http://pastebin.com/Z6aXz7jf







Also tagged with one or more of these keywords: pcduino3, nano, lite, fedora, 23, gpio

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users