BUG - WiringPi2 on C1 with Armbian kernel 5.10

Post Reply
User avatar
tosiara
Posts: 31
Joined: Wed Sep 17, 2014 11:14 pm
languages_spoken: english
ODROIDs: U3, C0, C1
Has thanked: 0
Been thanked: 0
Contact:

BUG - WiringPi2 on C1 with Armbian kernel 5.10

Post by tosiara »

Hi,

I'm using C1 with latest Armbian from archive builds (Armbian_21.02.3_Odroidc1_focal_current_5.10.21).
The old wiringPi did not work (gives unknown board id 0), so I have built wiringPi2 from hardkernel github repo.

There is a bug when INPUT pin gives wrong digitalRead() value.

Simple PoC program:

Code: Select all

#include <stdio.h>
#include <unistd.h>
#include <wiringpi2/wiringPi.h>

void main()
{
    wiringPiSetup();
    pinMode(4, INPUT);

	while(1)
	{
		printf ("digitalRead: %d\n", digitalRead(4));
		usleep(100000);
	}
}
Put a jumper between pin 4 and gnd.

gcc -I/usr/include/wiringi2 test.c -lwiringPi
sudo ./a.out

Code: Select all

digitalRead: 0
digitalRead: 0
..
.. <-- here I remove jumper and start getting "1" as expected 
digitalRead: 1
digitalRead: 1
digitalRead: 1
digitalRead: 1
...
...
... <-- after 3-4 sec, without changing anything digitalRead returns "0"
digitalRead: 0
digitalRead: 0
digitalRead: 0
...
...
... <-- after 3-4 sec, again, without changing anything digitalRead again returns "1"
digitalRead: 1
digitalRead: 1
digitalRead: 1
...
..
And it continues switching every 3-4 seconds.

With placed jumper digitalRead always returns "0" correctly. Instability occurs only when the jumper is removed.

The same program works fine with older kernel and old wiringPi library.

Anyone knows how to fix this? Or how to use old wiringPi with newer kernel?

Thanks

User avatar
mad_ady
Posts: 12061
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4 (HC1, HC2), C1+, C2, C4 (HC4), N1, N2, N2L, H2, H3+, Go, Go Advance, M1, M1S
Location: Bucharest, Romania
Has thanked: 663 times
Been thanked: 1309 times
Contact:

Re: BUG - WiringPi2 on C1 with Armbian kernel 5.10

Post by mad_ady »

Is the bug in wiringPi, or can you see the same thing at sysfs/gpiod level as well?

User avatar
tosiara
Posts: 31
Joined: Wed Sep 17, 2014 11:14 pm
languages_spoken: english
ODROIDs: U3, C0, C1
Has thanked: 0
Been thanked: 0
Contact:

Re: BUG - WiringPi2 on C1 with Armbian kernel 5.10

Post by tosiara »

How do I read pin state using sysfs/gpiod? Could you please provide me the command to run so I can check?

User avatar
tosiara
Posts: 31
Joined: Wed Sep 17, 2014 11:14 pm
languages_spoken: english
ODROIDs: U3, C0, C1
Has thanked: 0
Been thanked: 0
Contact:

Re: BUG - WiringPi2 on C1 with Armbian kernel 5.10

Post by tosiara »

Code: Select all

# echo 104 > /sys/class/gpio/export
bash: echo: write error: Invalid argument
# dmesg | tail -n 1
[ 2172.828444] export_store: invalid GPIO 104

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 1 guest