Definitive Easy Mode to access (3xGPIO and UART)

Post Reply
mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Definitive Easy Mode to access (3xGPIO and UART)

Unread post by mdrjr » Thu May 15, 2014 10:37 am

Nice images -> https://drive.google.com/folderview?id= ... sp=sharing

There are 3 GPIO's (1.8V Logic Level) on U3 that you can use.

GPIO199, GPIO200 and GPIO204

To enable those GPIO's

Code: Select all

cdroot@odroid:~# cd /sys/class/gpio/
root@odroid:/sys/class/gpio# echo 199 > export 
root@odroid:/sys/class/gpio# echo 200 > export 
root@odroid:/sys/class/gpio# echo 204 > export 

How to flash an LED (red colored) on the GPIO.
Note: The LED must be a RED one since red are the leds that requires less voltage to operate.
Connect an LED like this -> https://drive.google.com/file/d/0B54WDu ... sp=sharing
TIP: The bigger lead of the LED is the positive and the smaller is the Negative(Ground).

This code will setup the GPIO.

Code: Select all

cd /sys/class/gpio
echo 204 > export
cd gpio204
echo out > direction
Flash the LED:

Code: Select all

while true; do
echo 0 > value
sleep 1 
echo 1 > value
sleep 1
done
The code above is a infinite loop that will flash the LED.. explained:

Code: Select all

while true; do # while true is true, do this:
echo 0 > value # turn off the led
sleep 1 # wait 1 sec
echo 1 > value # turn on the led
sleep 1 # wait 1 sec
done # we are done here
Performance notes:
Toggling the GPIO from shell with a infinite loop. I could measure 10kHz on the scope.
Poking the /sys nodes with a C program I could get 250kHz (source: https://docs.google.com/document/d/17SQ ... sp=sharing)

You can use mlinuxguy Gpio example to get ~2.4Mhz out of it.
https://github.com/mlinuxguy/odpygpio

User avatar
Digimaster
Posts: 220
Joined: Tue Feb 26, 2013 4:16 pm
languages_spoken: english, russian
ODROIDs: U2, X2, U3, C1, C2, XU4 × 300+
Location: Moscow, Russia
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by Digimaster » Thu May 15, 2014 1:30 pm

Thank you mdrjr for the complete guide for gpio! Nice pictures!

Here is a simple extra logic for powerful device control (relay switch) http://forum.odroid.com/viewtopic.php?f ... =20#p33362
I'm also going to make a simple logic for dry switch input to 1,8v logic.

User avatar
memeka
Posts: 4077
Joined: Mon May 20, 2013 10:22 am
languages_spoken: english
ODROIDs: XU rev2 + eMMC + UART
U3 + eMMC + IO Shield + UART
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by memeka » Thu May 15, 2014 1:46 pm

Don't you need to disable bitbanging driver?

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Thu May 15, 2014 6:08 pm

With the latest kernel update, the I2C driver is not loaded automatically.

So the i2c-gpio-custom module should be loaded manually if you need the I2C.

User avatar
sert00
Posts: 745
Joined: Sun Feb 24, 2013 12:26 am
languages_spoken: english,italian
ODROIDs: ODROID-U2*2__ODROID-U3__ODROID-XU-E__ODROID-XU-Ebeta__ODROID-C1__ODROID-XU4
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by sert00 » Fri May 16, 2014 4:24 am

great 3ad!so usefull,thanks
2x Odroid-U2
2x Odroid-XU-E
Odroid-U3
Odroid-C1+
Odroid-XU4
Lcd touch panel 10.1"
....and many of the goodies available....

Respectech
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.
Location: California
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by Respectech » Mon Jul 07, 2014 11:54 am

When I try to open two of the ports, I get errors:

root@odroid:/sys/class/gpio# echo 199 > export
bash: echo: write error: Device or resource busy
root@odroid:/sys/class/gpio# echo 200 > export
bash: echo: write error: Device or resource busy

but 204 works. I've tried it directly after a reboot. Any ideas why?

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Mon Jul 07, 2014 12:27 pm

Update the kernel first!

Respectech
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.
Location: California
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by Respectech » Mon Jul 07, 2014 1:33 pm

OK. For anybody who wants to know, the information on how to update the kernel is in mdrjr's signature: http://forum.odroid.com/viewtopic.php?f=29&t=1516

I upgraded the kernel and rebooted the ODROID-U3, and now I am able to access pins 199 and 200. However, I am not able to access the GPIO pins on the IO Board:

odroid@odroid:/sys/class/gpio$ echo 304 > export
bash: echo: write error: No such device

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Mon Jul 07, 2014 2:37 pm

As we described in the above post... you should do "sudo modprobe i2c-gpio-custom".

Respectech
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.
Location: California
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by Respectech » Mon Jul 07, 2014 3:49 pm

Thanks for the additional information and help!

In addition to the above (updating the kernel), here is the exact sequence of events I needed to do to get past the "No such device" message when exporting a pin on the IO Board, and to be able to turn pin P17 on and off:

odroid@odroid:/sys/class/gpio$ sudo su
root@odroid:/sys/class/gpio# modprobe gpio-pca953x
root@odroid:/sys/class/gpio# modprobe i2c-gpio-custom bus0=4,200,199
root@odroid:/sys/class/gpio# echo tca6416 0x20 > /sys/devices/platform/i2c-gpio.4/i2c-4/new_device
root@odroid:/sys/class/gpio# echo 304 > export
root@odroid:/sys/class/gpio# cd gpio304
root@odroid:/sys/class/gpio/gpio304# echo out > direction
root@odroid:/sys/class/gpio/gpio304# echo 1 > value ;Turns on the pin
root@odroid:/sys/class/gpio/gpio304# echo 0 > value ;Turns off the pin

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Mon Jul 07, 2014 7:27 pm

Thank you for the confirmation.
Your comprehensive instruction will be very helpful for other people! ;)

omegatek
Posts: 4
Joined: Tue May 13, 2014 3:11 am
languages_spoken: english
ODROIDs: ODROID-U3
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by omegatek » Wed Sep 24, 2014 3:31 am

Can I use the 5V PSU? Specifically, I would like to be able to turn the 5V on and off or is it always on? Is there a way use the 5v to power something else but be able to toggle power to it through software?

mdrjr
Site Admin
Posts: 11698
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by mdrjr » Wed Sep 24, 2014 3:34 am

5V there is always on.
You can use one GPIO to trigger a transistor that will allow pass the 5V :)

omegatek
Posts: 4
Joined: Tue May 13, 2014 3:11 am
languages_spoken: english
ODROIDs: ODROID-U3
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by omegatek » Thu Sep 25, 2014 11:35 am

Ah, great idea. Thank you!

KC7NOA
Posts: 834
Joined: Wed Feb 27, 2013 2:25 pm
languages_spoken: english
ODROIDs: Odroid-X2(blown HDMI output)
Odroid-C2 to replace X2
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by KC7NOA » Thu Jan 08, 2015 11:36 am

is this still the easy way .. on a X2 too ?

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Thu Jan 08, 2015 12:24 pm

KC7NOA wrote:is this still the easy way .. on a X2 too ?
Yes, if you have the same Kernel.

KC7NOA
Posts: 834
Joined: Wed Feb 27, 2013 2:25 pm
languages_spoken: english
ODROIDs: Odroid-X2(blown HDMI output)
Odroid-C2 to replace X2
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by KC7NOA » Thu Jan 08, 2015 2:28 pm

i dont think so ... iv just got the latest of mdrjr script pulls ...

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Thu Jan 08, 2015 5:20 pm

Did you check the pin-out difference between X2 and U3?
Tell me what you tried...

KC7NOA
Posts: 834
Joined: Wed Feb 27, 2013 2:25 pm
languages_spoken: english
ODROIDs: Odroid-X2(blown HDMI output)
Odroid-C2 to replace X2
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by KC7NOA » Fri Jan 09, 2015 4:35 am

its way different ... X2 has alot more....

i was wondering if the process would work for the X2 ... or is there a more up to date way to use the gpio's on a X2 ....

iv also sent linuxguy a pm .. no response yet ...

edit ---- missed you asking what iv done --

nothing yet .. i need to decide on level conversion .... i want to control relays mostly .. and a few digital, one being I2C ... but i think i would need to port some smooth tuneing firmware to be used in conjunction with the I2C`....

KC7NOA
Posts: 834
Joined: Wed Feb 27, 2013 2:25 pm
languages_spoken: english
ODROIDs: Odroid-X2(blown HDMI output)
Odroid-C2 to replace X2
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by KC7NOA » Thu Jan 15, 2015 2:15 pm

Guess odpygpio will work with the current kernel ....

User avatar
odroid
Site Admin
Posts: 29369
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by odroid » Thu Jan 15, 2015 2:19 pm

Toggle the same GPIO pins(GPIO199, GPIO200 and GPIO204) on your board.
You need to compare the pin-map on U3 with your X2.

uy0ll
Posts: 3
Joined: Mon Dec 15, 2014 3:06 am
languages_spoken: russian, english
ODROIDs: U3
Contact:

Re: Definitive Easy Mode to access (3xGPIO and UART)

Unread post by uy0ll » Fri Feb 13, 2015 2:17 am

You can use mlinuxguy Gpio example to get ~2.4Mhz out of it.
https://github.com/mlinuxguy/odpygpio
Maps the GPIO pin to the sysfs only support OdroidXU, X2, not U3. How to use library for GPIO199, GPIO200 and GPIO204 on U3 board?

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests