WiringPi for Odroid C1

Post Reply
RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

WiringPi for Odroid C1

Post by RWAP »

I have an Odroid C1 and have a HAT with software I have developed and use successfully on the Raspberry Pi, Banana Pi and Orange Pi PC.

I use the WiringPi library to access the GPIO header which makes it easier for cross-platform support.

However, I am struggling to get it working on the Odroid C1.

I tried:

a) apt-get install wiringpi
gpio -v
reports an error - unknown device.
gpio readall
also reports an error

b) I therefore installed the WiringPi library from:

https://github.com/hardkernel/wiringPi

I cloned this to the Odroid C1 and it installs v2.33 (same as apt-get)

gpio-v
works and identifies the device as Odroid C1 / C2
gpio readall
then works

However, when I try running my software I see the error:
**************** wiringPiGpioCheck ****************

Call Function = pinMode, wiringPiMode = WPI_MODE_PINS

Error gpio control (OrigPin = 9, pin = -1)

c) I tried (as per the readme on https://github.com/hardkernel/wiringPi ) to clone and install wiringPi from
git://git.drogon.net/wiringPi

This appeared to install v2.49
gpio -v
reports the machine as a raspberry pi, and gpio readall works, but my code doesn't - no leds - nothing... (and no errors)

I am using the following wiring pins:
inputs { 8, 1, 7, 0 , 2 , 3 , 12, 13, 14, 11 };
outputs { 4, 5, 10};
leds { 6 ,10, 9}

The 3 LEDs remain ON constantly using the https://github.com/hardkernel/wiringPi version.

So - any ideas what is causing this?

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

I have managed to fix this, by using the development branch:

git clone git://github.com/hardkernel/wiringPi -b dev

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

There are however, a couple of issues:

1 - I don't seem to get any data on wiring pin 8 (unlike the other implementations)
2 - digitalWrite (9, LOW); does not tun off my LED connected to that pin

Looking at the output of gpio readall, wiring pins 8 and 9 are not connected to the GPIO header :(

Any ideas as to why this is?

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: WiringPi for Odroid C1

Post by odroid »

Wiring pin #8 and #9 don't exist on C2. Refer the pin map in this WiKi page.
https://wiki.odroid.com/odroid-c1/hardw ... connectors

Also check "lsmod" output to remove any unused preloaded device drivers.

BTW, we will check it with C1, C2 and XU4 together early next week.
If the master branch doesn't work, we will update this wiki page.
https://wiki.odroid.com/odroid-xu4/appl ... o/wiringpi

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

odroid wrote:Wiring pin #8 and #9 don't exist on C2. Refer the pin map in this WiKi page.
https://wiki.odroid.com/odroid-c1/hardw ... connectors
Is there a reason for that ? The Raspberry Pi seems to use the two pins for the same thing, so it just means my HAT will not work with the Odroid which is a shame... :(

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: WiringPi for Odroid C1

Post by odroid »

We will try to find a way use the I2C pins as a normal GPIO with WiringPi early next week.
Image
Image

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

Has any progress been made with this?

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: WiringPi for Odroid C1

Post by odroid »

Sorry. I forgot this thread.

Can you toggle C1+ Pin#3 and Pin#5 on the command line?
Pin#3 is mapped to GPIO 74, Pin#5 is mapped to GPIO 75.
Try to export the GPIOs and change the direction to output and toggle the output level.
https://wiki.odroid.com/odroid-c1/appli ... 40pin_gpio

If it works, we will modify the WiringPi source code quickly to support those two additional IO ports.

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

Unfortunately, attempts to export pin 3 or pin 5, with

Code: Select all

echo 5 > /sys/class/gpio/export
reports a write error - device or resource busy. :?

Code: Select all

echo out > /sys/class/gpio/gpio5/direction
reports no such file or directory

and

Code: Select all

echo 5 > /sys/class/gpio/unexport
reports invalid argument.

I guess I need to stop the I2C control over pins 3 and 5 for this to work - although the Raspberry Pi, Banana Pi and Orange Pi PC all work without doing this.

Unfortunately, I can see someone else had the same issue - viewtopic.php?f=80&t=17522

I wonder how the other Pi variants manage this?

User avatar
tobetter
Posts: 5489
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 216 times
Been thanked: 639 times
Contact:

Re: WiringPi for Odroid C1

Post by tobetter »

@RWAP, I think you should use 74 and 75 instead of 3 and 5. 74 and 75 are pin number can be acknowledgeable by Linux kernel driver while 3 and 5 are the pin number on the pin header.

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

tobetter wrote:@RWAP, I think you should use 74 and 75 instead of 3 and 5. 74 and 75 are pin number can be acknowledgeable by Linux kernel driver while 3 and 5 are the pin number on the pin header.
Ah you are correct - that works and toggles my LED on/off (connected to #75)

So, it looks as though all that is required is for the Wiring module to be updated to point to these pins :D

User avatar
tobetter
Posts: 5489
Joined: Mon Feb 25, 2013 10:55 am
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1
Location: Paju, South Korea
Has thanked: 216 times
Been thanked: 639 times
Contact:

Re: WiringPi for Odroid C1

Post by tobetter »

RWAP wrote:
tobetter wrote:@RWAP, I think you should use 74 and 75 instead of 3 and 5. 74 and 75 are pin number can be acknowledgeable by Linux kernel driver while 3 and 5 are the pin number on the pin header.
Ah you are correct - that works and toggles my LED on/off (connected to #75)

So, it looks as though all that is required is for the Wiring module to be updated to point to these pins :D
Good to hear it works, there is another expert on this and stay tuned. :)

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: WiringPi for Odroid C1

Post by odroid »

Thank you for the confirmation.
We will update the WiringPi source code within a few days since tomorrow is a national holiday in Korea.

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

odroid wrote:Thank you for the confirmation.
We will update the WiringPi source code within a few days since tomorrow is a national holiday in Korea.
Thank you - that will be most helpful. :D

User avatar
odroid
Site Admin
Posts: 34849
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean, Japanese
ODROIDs: ODROID
Has thanked: 927 times
Been thanked: 758 times
Contact:

Re: WiringPi for Odroid C1

Post by odroid »

WiringPi library has been updated and you can access pin #3 and #5.

RWAP
Posts: 14
Joined: Mon Apr 30, 2018 4:28 am
languages_spoken: english
ODROIDs: Odroid C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by RWAP »

odroid wrote:WiringPi library has been updated and you can access pin #3 and #5.
OK - that works (v2.44 - dev branch on the github) - thank you (although there are various warnings when building the new version).

I guess the thing which remains is to move the development version into the main github (which is still v2.33) and also update the version installed by apt-get install wiringpi (again this is still v2.33) :D

rexxman
Posts: 1
Joined: Sat Jul 27, 2019 12:02 pm
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 0
Contact:

Re: WiringPi for Odroid C1

Post by rexxman »

Firstly thanks for providing this port of wriningPi for Odroid.,

I am porting a wiringPi program from the Raspberry Pi to my Odroid C1 and have come
across a bug with the Odroid implementation. Can't see how to raise an issue on GitHub
so am reporting it here; hope that is Ok.

My code calls piBoardId() to display details about the board and then calls wiringPiSetup()
and the remainder of the code. This works fine on Raspberry Pi.

On my Odroid I call piBoardId() successfully and display the board details.
Then I call wiringPiSetup() and get the error "Unknown Model"

The error is that piBoardId() calls piGpioLayout() which sets the global board details [libwiring]
and sets a static variable [gpioLayout] to 1 to indicate that piGpioLayout() has been called.

wiringPiSetup() first sets the global board details [libwiring] to zero and calls piGpioLayout().
piGpioLayout() checks the static variable [gpioLayout] and exits without re-populating [libwiring]
and wiringPiSetup() fails because the board model is unknown.

I can change the order of piBoardId() and wiringPiSetup() so that wiringPiSetup() is called
first, but that is inconsistent with the semantics of wiringPi on the Raspberry Pi.

Thanks, Mark

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

Re: WiringPi for Odroid C1

Post by joshua.yang »

rexxman wrote:
Sat Jul 27, 2019 12:21 pm
Firstly thanks for providing this port of wriningPi for Odroid.,

I am porting a wiringPi program from the Raspberry Pi to my Odroid C1 and have come
across a bug with the Odroid implementation. Can't see how to raise an issue on GitHub
so am reporting it here; hope that is Ok.

My code calls piBoardId() to display details about the board and then calls wiringPiSetup()
and the remainder of the code. This works fine on Raspberry Pi.

On my Odroid I call piBoardId() successfully and display the board details.
Then I call wiringPiSetup() and get the error "Unknown Model"

The error is that piBoardId() calls piGpioLayout() which sets the global board details [libwiring]
and sets a static variable [gpioLayout] to 1 to indicate that piGpioLayout() has been called.

wiringPiSetup() first sets the global board details [libwiring] to zero and calls piGpioLayout().
piGpioLayout() checks the static variable [gpioLayout] and exits without re-populating [libwiring]
and wiringPiSetup() fails because the board model is unknown.

I can change the order of piBoardId() and wiringPiSetup() so that wiringPiSetup() is called
first, but that is inconsistent with the semantics of wiringPi on the Raspberry Pi.

Thanks, Mark
Hi.

Yes, on our port, wiringPiSetup() calls piGpioLayout() first to set libwiring structure with proper parameters by parsing /proc/cpuinfo.

So, if /proc/cpuinfo has correct information for the board itself, wiringPiSetup() should work flawlessly. It means it should recognize the board name and revision and it should not say "Unknown model".

I doubt that your /proc/cpuinfo has no information for providing its name to WiringPi. Could you check this?

Code: Select all

cat /proc/cpuinfo
In my C1, it results,

Code: Select all

root@odroid:~# cat /proc/cpuinfo
Processor	: ARMv7 Processor rev 1 (v7l)
processor	: 0
BogoMIPS	: 3.27

processor	: 1
BogoMIPS	: 3.27

processor	: 2
BogoMIPS	: 3.27

processor	: 3
BogoMIPS	: 3.27

Features	: swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xc05
CPU revision	: 1

Hardware	: ODROIDC
Revision	: 000a
Serial		: 1b00000000000000
Check the last 3 lines that involve hardware name and revision version.

And before that, you don't have to call piBoardId() at first when you use WiringPi for ODROIDs. That function is not necessary.
wiringPiSetup() does the work that piBoardId() originally did.

User avatar
joerg
Posts: 1130
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 53 times
Been thanked: 122 times
Contact:

Re: WiringPi for Odroid C1

Post by joerg »

@rexxman, maybe you are using a mainline kernel? In that case it would be clear, if there are missing hardware, revision and serial in cpuinfo. You can see in my thread: viewtopic.php?f=114&t=35474#p260341

hami
Posts: 26
Joined: Sat Mar 19, 2016 5:31 am
languages_spoken: english, czech
ODROIDs: C1+, C2, C4
Has thanked: 0
Been thanked: 4 times
Contact:

Re: WiringPi for Odroid C1

Post by hami »

Dear experts, Hardkernel,

I am not able to obtain a working wiringpi for C1 on the official Ubuntu image. I have installed Ubuntu 18.04.3 minimal img, done system update&upgrade, added hardkernel ppa and installed odroid-wiringpi. Then ran

Code: Select all

$ gpio -v
and obtained

Code: Select all

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

** Model string on this board is not well formatted **
In the next step I uninstalled odroid-wiringpi and tried to compile in from github repository

Code: Select all

git clone https://github.com/hardkernel/wiringPi
cd wiringPi
./build
and ran

Code: Select all

gpio -v
with the same message as above. Do you know what is wrong? Does the kernel version support the odroid-wiringpi? I would expect that yes because I took all information from https://wiki.odroid.com/odroid-c1/appli ... o/wiringpi.

I also tried to use Armbian Focal (https://www.armbian.com/odroid-c1/) and repeated the steps above (I installed only from hardkernel ppa). The "gpio" have worked and returned

Code: Select all

root@odroidc1:~/wiringPi# gpio -v
gpio version: 3.2
Copyright (c) 2012-2017 Gordon Henderson, 2017-2020 Hardkernel Co., Ltd.
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.
  *--> Hardkernel ODROID-C1
  * Root or sudo required for GPIO access.
So the biggest difference is the kernel version only. I would prefer to you the official hardkernel image because it suppors hdmi, emmc etc. but the wiringpi oest not work.

Actually it somehow works (using official harkernel Ubuntu image for C1) if I clone the "dev" branch from repository (as mentioned on top of this thread):

Code: Select all

git clone git://github.com/hardkernel/wiringPi -b dev
cd wiringPi
./build
/usr/local/bin/gpio -v
gpio version: 2.44
Copyright (c) 2012-2017 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: /usr/local/bin/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.
Why? Because it is the older version 2.44 against 3.2?

Next, there is also an issue with the wiringpi python wrapper on the official Hardkernel Ubuntu 18.04.3 image - neither ppa, pypi not github code works. Again on Armbian Focal there are no problems with this python wrapper.

How to install wiringpi with a python support on Odroid C1 with the official Hardkernel Ubuntu image? Thank you.

igorpec
Posts: 642
Joined: Sat Dec 12, 2015 4:34 pm
languages_spoken: english,german,slovene
ODROIDs: XU4, HC1, C2, C1+
Has thanked: 32 times
Been thanked: 83 times
Contact:

Re: WiringPi for Odroid C1

Post by igorpec »

So the biggest difference is the kernel version only.
Whenever you talk with the hardware, kernel is in charge, Python is just a wrapper. If you get your needed functionality with (modern kernel) powered Armbian, use it! If you urgently need also a HDMI and eMMC, forget about whole idea.
Why?
IHMO nobody will invest anything to support / maintain a 3.10.y kernel that is EOL for years. C1 is a device that is probably just about to be declared EOL. At least with an official kernel, which is ... just terrible in comparison to a modern one. But the biggest problem is not kernel, but u-boot. That will certainly not be upgraded to modern version.
ARMBIAN
Linux for ARM development boards

Download latest images for Odroids | Build them from sources | Donate to support development

hami
Posts: 26
Joined: Sat Mar 19, 2016 5:31 am
languages_spoken: english, czech
ODROIDs: C1+, C2, C4
Has thanked: 0
Been thanked: 4 times
Contact:

Re: WiringPi for Odroid C1

Post by hami »

@igorpec thank you for your point of view. I do not want to throw C1 into the dustbin thus I will use Armbian. Thank's for it and thank's for it that works (even if partially). HDMI is not crucial for me but eMMC.

In general, if there is no support from the Hardkernel side, it would be mentioned on its official site or its wiki page - but there one can read "We guarantee the production of C1+ to the end of 2020, but expect to continue production long after". From this I would expect some HW/SW support from Hardkernel. Why to product C1 boards when they do not want to continue in SW support? Next, the PPA is from Hardkernel (at least as it is named), so again I would expect some level of the support.

mad_ady
Posts: 8314
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 573 times
Been thanked: 433 times
Contact:

Re: WiringPi for Odroid C1

Post by mad_ady »

Most likely official support will still exist, but on the 3.10 kernel. So I expect HK will release a 20.04 image for C1 in the future. Why not a newer kernel? Because the SOC vendor (Amlogic) only officially supports 3.10, and going to a newer kernel means missing features and new bugs. HK doesn't have all the code the SOC manufacturer has, so can't easily port the old drivers to the new kernel.
It's sad, and I understand your desire to keep using the board, but it's how things are with most SOC vendors.
These users thanked the author mad_ady for the post:
joerg (Tue Jun 23, 2020 12:03 am)

hami
Posts: 26
Joined: Sat Mar 19, 2016 5:31 am
languages_spoken: english, czech
ODROIDs: C1+, C2, C4
Has thanked: 0
Been thanked: 4 times
Contact:

Re: WiringPi for Odroid C1

Post by hami »

Hi all,

previously I overlooked the master-old branch of both hardkernel/wiringPi and hardkernel/WiringPi2-Python. I have to say that wiringpi (together with python wrapper) works for me on HK's Ubuntu 18.04 (I tested input/output as well as callback function).
These users thanked the author hami for the post:
odroid (Fri Jun 26, 2020 10:49 am)

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

Re: WiringPi for Odroid C1

Post by joshua.yang »

Hello all,

I hope attached meson8b_odroidc.dtb file to fix to install the latest WiringPi, which is on the master branch. Actually, it needs the new version Odroid WiringPi 3.3. I just have uploaded that to our Github. :)

This, replacing only the meson8b_odroidc.dtb file will work unless you're using a too old Linux kernel image. Just changing model property from AMLOGIC to Hardkernel ODROID-C1.
Let me know if it doesn't work. Then I'll link the full compression file involves Linux kernel image, DTB, and modules.

Here's the working screenshot.
wiringpi_3.3_on_c1.png
wiringpi_3.3_on_c1.png (319.03 KiB) Viewed 563 times
I have tested with Ubuntu 20.04 (ubuntu-20.04-3.10-minimal-odroid-c1-20200519.img.xz) with replacing the DTB file.

In WiringPi, I have modified the codebase a lot to support our various models more efficiently and to add some additional features. That means that I have been trying to avoid "hardcoded" coding style.
Even with this thought, mine may definitely not be perfect but I think I should do it in this way.

In this progress, I forgot the Odroid-C1 hasn't its identifier like in the other boards' way. The format of board name information at /proc/cpuinfo and /proc/device-tree/model is different from the other boards have.

Sorry for the inconvenience.

Please let me know if you face any issue with our board and our WiringPi.
Attachments
meson8b_odroidc.dtb.zip
(5.67 KiB) Downloaded 26 times
These users thanked the author joshua.yang for the post:
joerg (Sat Jun 27, 2020 12:37 am)

hami
Posts: 26
Joined: Sat Mar 19, 2016 5:31 am
languages_spoken: english, czech
ODROIDs: C1+, C2, C4
Has thanked: 0
Been thanked: 4 times
Contact:

Re: WiringPi for Odroid C1

Post by hami »

Dear joshua.yang,

it's a great news. I can confirm that wiringpi v3.3 works with your dtb version.

Cheers,
Petr

update: I have used Ubuntu 20.04 (ubuntu-20.04-3.10-minimal-odroid-c1-20200519.img.xz) with kernel 3.10.107-22 (after apt upgrade I had to rewrite dtb again)
These users thanked the author hami for the post (total 3):
joerg (Sat Jun 27, 2020 12:37 am) • joshua.yang (Mon Jun 29, 2020 9:48 am) • odroid (Mon Jun 29, 2020 11:13 am)

Post Reply

Return to “Issues”

Who is online

Users browsing this forum: No registered users and 0 guests