C0 WiringPi

Post Reply
L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

C0 WiringPi

Post by L67GS »

I have wiringPi working on my C1+ for my Candice robot project but when I put that eMMC into the C0 gpio isn't working.
On the C1+ I was working with the git version and it was fine.
There's a thread on the Korean side of the forum on the topic, could somebody please summarize the fix for me?

output of gpio -v looks fine:

root@odroid:~# gpio -v
gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty

ODROID Board Details:
Type: ODROID-C1/C1+, Revision: 01, Memory: 1024MB
Maker: Hardkernel, Chip-Vendor: AMLogic
* Device tree is enabled.
*--> AMLOGIC
* Supports user-level GPIO access.

joshua.yang
Posts: 433
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 26 times
Been thanked: 98 times
Contact:

Re: C0 WiringPi

Post by joshua.yang »

Hi.

Try the latest version. You can download that via Git clone or Ubuntu PPA.

- Git clone

Code: Select all

git clone https://github.com/hardkernel/wiringPi
cd wiringPi
sudo ./build
- Ubuntu PPA

Code: Select all

sudo apt install software-properties-common
sudo add-apt-repository ppa:hardkernel/ppa
sudo apt update
sudo apt install odroid-wiringpi odroid-wiringpi-python
If the problem still exists, please tell us what's the Ubuntu and kernel version on your C0.
These users thanked the author joshua.yang for the post:
L67GS (Mon Sep 14, 2020 1:20 pm)

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

Thank you Joshua, I'll try that soon. Right now I'm using gpio write and have the project working, but I still have inputs and an analog read to do so I have to cross this bridge soon.

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

L67GS wrote:
Mon Sep 14, 2020 1:20 pm
Thank you Joshua, I'll try that soon. Right now I'm using gpio write and have the project working, but I still have inputs and an analog read to do so I have to cross this bridge soon.
Does the ppa version have your new dtb version that I saw in the other thread?

joshua.yang
Posts: 433
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 26 times
Been thanked: 98 times
Contact:

Re: C0 WiringPi

Post by joshua.yang »

L67GS wrote:
Mon Sep 14, 2020 2:55 pm
Does the ppa version have your new dtb version that I saw in the other thread?
Both the PPA version and the Github repository version has been fixed to be working without the edited DTB.
It just would work out of the box on C0/C1 series with a clean Ubuntu system.
These users thanked the author joshua.yang for the post:
L67GS (Mon Sep 14, 2020 3:26 pm)

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

Last night I got wiringpi working. I ran a c++ test program I wrote and some outputs not working. I'll test more on my C1+ and post more results.

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

I'm thankful I figured out a number of the GPIO ports can only be used for data and analog reads before someone had to tell me, but still not sure why 7 is only staying high for a second.
This is from one of my C0's:

Code: Select all

gpio readall
 +------+-----+----------+------+- Model ODROID-C -+------+----------+-----+---+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode |   Name   | wPi | GP|
 +------+-----+----------+------+---+----++----+---+------+----------+-----+---+
 |      |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |   |
 |   74 |   8 |    SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V       |     |   |
 |   75 |   9 |    SCL.1 |   IN | 1 |  5 || 6  |   |      | GND(0V)  |     |   |
 |   83 |   7 | GPIO. 83 |   IN | 0 |  7 || 8  |   |      | TxD1     | 15  |   |
 |      |     |  GND(0V) |      |   |  9 || 10 |   |      | RxD1     | 16  |   |
 |   88 |   0 | GPIO. 88 |   IN | 1 | 11 || 12 | 0 | IN   | GPIO. 87 | 1   |  8|
 |  116 |   2 | GPIO.116 |   IN | 1 | 13 || 14 |   |      | GND(0V)  |     |   |
 |  115 |   3 | GPIO.115 |   IN | 0 | 15 || 16 | 1 | IN   | GPIO.104 | 4   |  1|
 |      |     |     3.3V |      |   | 17 || 18 | 1 | IN   | GPIO.102 | 5   |  1|
 |  107 |  12 |     MOSI |   IN | 1 | 19 || 20 |   |      | GND(0V)  |     |   |
 |  106 |  13 |     MISO |   IN | 1 | 21 || 22 | 1 | IN   | GPIO.103 | 6   |  1|
 |  105 |  14 |     SCLK |   IN | 1 | 23 || 24 | 0 | IN   | CE0      | 10  |  1|
 |      |     |  GND(0V) |      |   | 25 || 26 | 1 | IN   | GPIO.118 | 11  |  1|
 |      |  30 |    SDA.2 |      |   | 27 || 28 |   |      | SCL.2    | 31  |   |
 |  101 |  21 | GPIO.101 |   IN | 1 | 29 || 30 |   |      | GND(0V)  |     |   |
 |  100 |  22 | GPIO.100 |   IN | 1 | 31 || 32 | 1 | IN   | GPIO. 99 | 26  |  9|
 |  108 |  23 | GPIO.108 |   IN | 0 | 33 || 34 |   |      | GND(0V)  |     |   |
 |   97 |  24 | GPIO.97  |   IN | 1 | 35 || 36 | 1 | IN   | GPIO. 98 | 27  |  9|
 |      |  25 |    AIN.1 |      |   | 37 || 38 |   |      | 1V8      | 28  |   |
 |      |     |  GND(0V) |      |   | 39 || 40 |   |      | AIN.0    | 29  |   |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+---+

Code: Select all

root@odroid:~# cat /sys/kernel/debug/gpio
GPIOs 0-138:
 gpio-3   (amlsd               ) out lo
 gpio-5   (DWC_OTG             ) out hi
 gpio-13  (blue:heartbeat      ) out hi
 gpio-49  (amlsd               ) in  hi
 gpio-83  (amlw1               ) in  lo

Code: Select all

root@odroid:~# lsmod
Module                  Size  Used by
nls_cp437               5102  1
w1_gpio                 3465  0
wire                   20495  1 w1_gpio
rt2800usb              17441  0
rt2800lib              74662  1 rt2800usb
snd_usb_audio         121948  0
rt2x00usb              10279  1 rt2800usb
snd_hwdep               5779  1 snd_usb_audio
rt2x00lib              39987  3 rt2x00usb,rt2800lib,rt2800usb
snd_usbmidi_lib        17341  1 snd_usb_audio
snd_rawmidi            19085  1 snd_usbmidi_lib
snd_seq_device          5909  1 snd_rawmidi
meson_gpiomem           3455  0
snd_soc_odroid_dac      5241  0
snd_soc_pcm5102         2972  1
ip_tables              11416  0
autofs4                22336  2

joshua.yang
Posts: 433
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 26 times
Been thanked: 98 times
Contact:

Re: C0 WiringPi

Post by joshua.yang »

L67GS wrote:
Thu Sep 17, 2020 10:30 am
I'm thankful I figured out a number of the GPIO ports can only be used for data and analog reads before someone had to tell me, but still not sure why 7 is only staying high for a second.
This is from one of my C0's:

Code: Select all

gpio readall
 +------+-----+----------+------+- Model ODROID-C -+------+----------+-----+---+
 | GPIO | wPi |   Name   | Mode | V | Physical | V | Mode |   Name   | wPi | GP|
 +------+-----+----------+------+---+----++----+---+------+----------+-----+---+
 |      |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |   |
 |   74 |   8 |    SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V       |     |   |
 |   75 |   9 |    SCL.1 |   IN | 1 |  5 || 6  |   |      | GND(0V)  |     |   |
 |   83 |   7 | GPIO. 83 |   IN | 0 |  7 || 8  |   |      | TxD1     | 15  |   |
 |      |     |  GND(0V) |      |   |  9 || 10 |   |      | RxD1     | 16  |   |
 |   88 |   0 | GPIO. 88 |   IN | 1 | 11 || 12 | 0 | IN   | GPIO. 87 | 1   |  8|
 |  116 |   2 | GPIO.116 |   IN | 1 | 13 || 14 |   |      | GND(0V)  |     |   |
 |  115 |   3 | GPIO.115 |   IN | 0 | 15 || 16 | 1 | IN   | GPIO.104 | 4   |  1|
 |      |     |     3.3V |      |   | 17 || 18 | 1 | IN   | GPIO.102 | 5   |  1|
 |  107 |  12 |     MOSI |   IN | 1 | 19 || 20 |   |      | GND(0V)  |     |   |
 |  106 |  13 |     MISO |   IN | 1 | 21 || 22 | 1 | IN   | GPIO.103 | 6   |  1|
 |  105 |  14 |     SCLK |   IN | 1 | 23 || 24 | 0 | IN   | CE0      | 10  |  1|
 |      |     |  GND(0V) |      |   | 25 || 26 | 1 | IN   | GPIO.118 | 11  |  1|
 |      |  30 |    SDA.2 |      |   | 27 || 28 |   |      | SCL.2    | 31  |   |
 |  101 |  21 | GPIO.101 |   IN | 1 | 29 || 30 |   |      | GND(0V)  |     |   |
 |  100 |  22 | GPIO.100 |   IN | 1 | 31 || 32 | 1 | IN   | GPIO. 99 | 26  |  9|
 |  108 |  23 | GPIO.108 |   IN | 0 | 33 || 34 |   |      | GND(0V)  |     |   |
 |   97 |  24 | GPIO.97  |   IN | 1 | 35 || 36 | 1 | IN   | GPIO. 98 | 27  |  9|
 |      |  25 |    AIN.1 |      |   | 37 || 38 |   |      | 1V8      | 28  |   |
 |      |     |  GND(0V) |      |   | 39 || 40 |   |      | AIN.0    | 29  |   |
 +------+-----+----------+------+---+----++----+---+------+----------+-----+---+

Code: Select all

root@odroid:~# cat /sys/kernel/debug/gpio
GPIOs 0-138:
 gpio-3   (amlsd               ) out lo
 gpio-5   (DWC_OTG             ) out hi
 gpio-13  (blue:heartbeat      ) out hi
 gpio-49  (amlsd               ) in  hi
 gpio-83  (amlw1               ) in  lo

Code: Select all

root@odroid:~# lsmod
Module                  Size  Used by
nls_cp437               5102  1
w1_gpio                 3465  0
wire                   20495  1 w1_gpio
rt2800usb              17441  0
rt2800lib              74662  1 rt2800usb
snd_usb_audio         121948  0
rt2x00usb              10279  1 rt2800usb
snd_hwdep               5779  1 snd_usb_audio
rt2x00lib              39987  3 rt2x00usb,rt2800lib,rt2800usb
snd_usbmidi_lib        17341  1 snd_usb_audio
snd_rawmidi            19085  1 snd_usbmidi_lib
snd_seq_device          5909  1 snd_rawmidi
meson_gpiomem           3455  0
snd_soc_odroid_dac      5241  0
snd_soc_pcm5102         2972  1
ip_tables              11416  0
autofs4                22336  2
Seems 1-wire module is loaded. This keeps grab some pins that you're going to use so those pins won't work as you intended.
Unload that using this command.

Code: Select all

modprobe -r w1_gpio
These users thanked the author joshua.yang for the post:
L67GS (Thu Sep 17, 2020 2:40 pm)

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

I'm going to be fine without pin 7, I've got more than enough working GPIO pins for this project. Is there a way to do software pullup on a pin when it's used as an input with wiringPi?

If not I can put a bank of resistors in as pullups but it's a battery operated application so I'd rather not.

joshua.yang
Posts: 433
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 26 times
Been thanked: 98 times
Contact:

Re: C0 WiringPi

Post by joshua.yang »

L67GS wrote:
Thu Sep 17, 2020 1:59 pm
I'm going to be fine without pin 7, I've got more than enough working GPIO pins for this project. Is there a way to do software pullup on a pin when it's used as an input with wiringPi?

If not I can put a bank of resistors in as pullups but it's a battery operated application so I'd rather not.
You can switch pull-up/pull-down of a pin with WiringPi. This controls the GPIO pin registers.

Code: Select all

# An example describes configuring the pull status of the #3 pin in WiringPi numbering
gpio mode 3 up
gpio mode 3 down
Then can see the pull status using gpio readall -a command.
These users thanked the author joshua.yang for the post:
L67GS (Thu Sep 17, 2020 2:40 pm)

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

Oh that's fantastic, thank you! Is there a nice way to do it from C++ or should I just use a handful of system() commands?

joshua.yang
Posts: 433
Joined: Fri Sep 22, 2017 5:54 pm
languages_spoken: Korean, English
ODROIDs: XU4, XU4Q + Cloudshell2, H2, N2
Has thanked: 26 times
Been thanked: 98 times
Contact:

Re: C0 WiringPi

Post by joshua.yang »

L67GS wrote:
Thu Sep 17, 2020 2:40 pm
Oh that's fantastic, thank you! Is there a nice way to do it from C++ or should I just use a handful of system() commands?
Sure, you can use them on C/C++/Python without system() function.

Here's an example of the basic WiringPi usage in C++.

Code: Select all

#include <iostream>
#include <wiringPi.h>

using namespace std;

#define LED 3

int main() {
  cout << "Set up for WiringPi...\n";
  wiringPiSetup();

  cout << "Make the LED pin to OUTPUT mode...\n";
  pinMode(LED, OUTPUT);

  cout << "Start LED blinking...\n";
  for (;;) {
    digitalWrite(LED, 1);
    delay(500);
    digitalWrite(LED, 0);
    delay(500);
  }

  return 0;
}
To compile that, I used this command.

Code: Select all

gcc blink.cpp -lstdc++ -lwiringPi -lwiringPiDev -lm -lpthread -lrt -lcrypt
Have to install libwiringpi-dev and libwiringpi2 if you had installed WiringPi using the apt package manager.

Here're some core functions which are frequently used.

Code: Select all

extern		void setDrive		(int pin, int value);
extern		int  getDrive		(int pin);
extern		int  getAlt		(int pin);
extern		int  getPUPD		(int pin);
extern		void pinMode		(int pin, int mode);
extern		void pullUpDnControl	(int pin, int pud);
extern		int  digitalRead	(int pin);
extern		void digitalWrite	(int pin, int value);
extern unsigned int  digitalReadByte	(void);
extern		void digitalWriteByte	(const int value);
extern		int  analogRead		(int pin);
Please refer to these codes to get further information about the supported WiringPi functions.
https://github.com/hardkernel/wiringPi/ ... gPi.h#L263
These users thanked the author joshua.yang for the post:
L67GS (Thu Sep 17, 2020 3:32 pm)

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

I ended up using

Code: Select all

 system ("gpio mode 3 up");

What I made of the wiringPi method didn't work for me.

Code: Select all

wiringPiSetup();
        pinMode(0, INPUT);
        pullUpDnControl(0, PUD_UP);
        pinMode(1, INPUT);
        pullUpDnControl(1, PUD_UP);
        pinMode(4, INPUT);
        pullUpDnControl(4, PUD_UP);
        pinMode(5, INPUT);
        pullUpDnControl(5, PUD_UP);
        pinMode(6, INPUT);
        pullUpDnControl(6, PUD_UP);
        pinMode(10, INPUT);
        pullUpDnControl(10, PUD_UP);
        pinMode(11, INPUT);
        pullUpDnControl(11, PUD_UP);

L67GS
Posts: 166
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: english
ODROIDs: XU4, C1+,(3) C0's, and a whole big pile of accessories, VU7A Plus,, ect....
Has thanked: 55 times
Been thanked: 24 times
Contact:

Re: C0 WiringPi

Post by L67GS »

I just found the method where pins can be defined and given state at the same time, it works!

Code: Select all

 wiringPiSetup();
        pinMode(0, INPUT_PULLUP);
        pinMode(1, INPUT_PULLUP);
        pinMode(4, INPUT_PULLUP);
        pinMode(5, INPUT_PULLUP);
        pinMode(6, INPUT_PULLUP);
        pinMode(10, INPUT_PULLUP);
        pinMode(11, INPUT_PULLUP);
These users thanked the author L67GS for the post:
joshua.yang (Fri Sep 18, 2020 1:39 pm)

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 1 guest