[SOLVED] wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post Reply
Sebas_Ledesma
Posts: 169
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 19 times
Been thanked: 14 times
Contact:

[SOLVED] wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by Sebas_Ledesma »

Hi:

I'm migrating my software from C2 to C4 (Ubuntu 18.04/Kernel 3.16 to Ubuntu 20.04/Kernel 4.9).
One of the modules read the GPIO using wiringPi to get the state of the buttons and also the push encoder.
I can read the buttons, ie (simplied code):

Code: Select all

	
#define ENC_SW  	6  	//Pin 22 on C2
#define SW1 	0	//Pin 11  on C2
#define SW2 	1	//Pin 12  on C2
#define SW3 	2	//Pin 13  on C2
#define SW4 	3	//Pin 15  on C2
#define SW5 	4	//Pin 16  on C2
#define SW6 	5	//Pin 18  on C2
...
	auxButton[0] = digitalRead(ENC_SW);
	auxButton[1] = digitalRead(SW1);
	auxButton[2] = digitalRead(SW2);
	auxButton[3] = digitalRead(SW3);
	auxButton[4] = digitalRead(SW4);
	auxButton[5] = digitalRead(SW5);
	auxButton[6] = digitalRead(SW6);
but when trying to set an interrupt handler for the rotary encoder using wiringPiISR

Code: Select all

	if (wiringPiISR(13,  INT_EDGE_BOTH, &enc_Generic_Interrupt) < 0)
	{
		printf( "Unable to setup ISR: %s\n", strerror(errno));
	}
the program aborts with this message:

Code: Select all

wiringPiISR: unable to open /sys/class/gpio/gpio485/direction: No such file or directory
Usefull info:
lsmod

Code: Select all

Module                  Size  Used by
fuse                  110592  2
squashfs               49152  0
cpufreq_ondemand       20480  0
cpufreq_powersave      16384  0
cpufreq_userspace      16384  0
cpufreq_conservative    16384  0
rtl8xxxu              114688  0
i2c_meson_master       20480  0
amvdec_ports          196608  0
sch_fq_codel           20480  6
amvdec_vp9            122880  0
amvdec_vc1             65536  0
amvdec_real            45056  0
amvdec_mmpeg4          40960  0
amvdec_mpeg4           65536  0
amvdec_mpeg12         106496  0
amvdec_mmjpeg          28672  0
amvdec_mjpeg           40960  0
amvdec_h265           147456  0
amvdec_h264mvc         57344  0
amvdec_mh264          159744  0
amvdec_h264           147456  0
amvdec_avs             69632  0
stream_input          180224  9 amvdec_h265,amvdec_mh264,amvdec_h264mvc,amvdec_ports,amvdec_real,amvdec_vp9,amvdec_h264,amvdec_mpeg12,amvdec_avs
decoder_common        188416  15 amvdec_h265,amvdec_mjpeg,amvdec_mh264,amvdec_mmpeg4,amvdec_h264mvc,amvdec_mmjpeg,amvdec_ports,amvdec_real,stream_input,amvdec_vp9,amvdec_h264,amvdec_mpeg12,amvdec_avs,amvdec_vc1,amvdec_mpeg4
firmware               28672  15 amvdec_h265,amvdec_mjpeg,amvdec_mh264,amvdec_mmpeg4,amvdec_h264mvc,amvdec_mmjpeg,decoder_common,amvdec_real,stream_input,amvdec_vp9,amvdec_h264,amvdec_mpeg12,amvdec_avs,amvdec_vc1,amvdec_mpeg4
media_clock            45056  10 amvdec_h265,amvdec_mh264,decoder_common,amvdec_ports,firmware,stream_input,amvdec_vp9,amvdec_h264,amvdec_mpeg12,amvdec_avs
ip_tables              28672  0
x_tables               49152  1 ip_tables
ipv6                  466944  44
spidev                 20480  2
spi_meson_spicc        20480  0
gpio readall

Code: Select all

 +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 493 |   8 |   SDA.2 | ALT1 | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 494 |   9 |   SCL.2 | ALT1 | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 481 |   7 |  IO.481 |   IN | 1 |  7 || 8  | 1 | ALT1 | TxD1    | 15  | 488 |
 |     |     |      0V |      |   |  9 || 10 | 1 | ALT1 | RxD1    | 16  | 489 |
 | 479 |   0 |  IO.479 |   IN | 0 | 11 || 12 | 0 | IN   | IO.492  | 1   | 492 |
 | 480 |   2 |  IO.480 |   IN | 0 | 13 || 14 |   |      | 0V      |     |     |
 | 483 |   3 |  IO.483 |   IN | 0 | 15 || 16 | 0 | IN   | IO.476  | 4   | 476 |
 |     |     |    3.3V |      |   | 17 || 18 | 0 | IN   | IO.477  | 5   | 477 |
 | 484 |  12 |    MOSI | ALT4 | 0 | 19 || 20 |   |      | 0V      |     |     |
 | 485 |  13 |    MISO | ALT4 | 1 | 21 || 22 | 1 | IN   | IO.478  | 6   | 478 |
 | 487 |  14 |    SLCK | ALT4 | 0 | 23 || 24 | 1 | OUT  | SS      | 10  | 486 |
 |     |     |      0V |      |   | 25 || 26 | 0 | IN   | IO. 23  | 11  | 433 |
 | 474 |  30 |   SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3   | 31  | 475 |
 | 490 |  21 |  IO.490 |  OUT | 0 | 29 || 30 |   |      | 0V      |     |     |
 | 491 |  22 |  IO.491 |  OUT | 0 | 31 || 32 | 0 | OUT  | IO. 24  | 26  | 434 |
 | 482 |  23 |  IO.482 |   IN | 0 | 33 || 34 |   |      | 0V      |     |     |
 | 495 |  24 |  IO.495 |  OUT | 0 | 35 || 36 | 0 | OUT  | IO. 22  | 27  | 432 |
 |     |  25 |   AIN.2 |      |   | 37 || 38 |   |      | 1V8     | 28  |     |
 |     |     |      0V |      |   | 39 || 40 |   |      | AIN.0   | 29  |     |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- C4 ---+---+------+---------+-----+-----+

Additional info:
This problem it's pretty similar/the same that the reported in
viewtopic.php?t=31904

If I call

Code: Select all

   wiringPiISR(7,  INT_EDGE_BOTH, &enc_Generic_Interrupt) ;
the function executes without problem, but if I call:

Code: Select all

	if (wiringPiISR(13,  INT_EDGE_BOTH, &enc_Generic_Interrupt) < 0) ...
wiringPiISR: unable to open /sys/class/gpio/gpio485/direction: No such file or directory

Code: Select all

	if (wiringPiISR(14,  INT_EDGE_BOTH, &enc_Generic_Interrupt) < 0)...
wiringPiISR: unable to open /sys/class/gpio/gpio487/direction: No such file or directory

I've tried by adding:

Code: Select all

blacklist w1_gpio 
blacklist wire 
to /etc/modprobe.d/blacklist.conf
but it didnt solve it.

Thanks in advance,
Sebas
Last edited by Sebas_Ledesma on Mon Feb 22, 2021 11:57 pm, edited 1 time in total.

Sebas_Ledesma
Posts: 169
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 19 times
Been thanked: 14 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by Sebas_Ledesma »

I've noticed that pin 21 (WiringPi 13) and pin 23 (wiringPi 14) are used by the SPI interface (and the spidev it's loaded in my configuration).
How I dissalbe the SPI in C4 / Ubuntu?

Thanks in advance,
Sebas

User avatar
joerg
Posts: 1306
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: 82 times
Been thanked: 180 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by joerg »

Maybe you can do it in conf.ini, if your version of Linux have this devicetree overlays.
https://wiki.odroid.com/common/applicat ... ee_overlay

Sebas_Ledesma
Posts: 169
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 19 times
Been thanked: 14 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by Sebas_Ledesma »

Update:
I still have to learn/test the devicetree overlay.
I've tried:

Code: Select all

sudo rmmod spidev
and it never ends.
And also tested:

Code: Select all

sudo modprobe -rv spidev
with the same result.

Sebas

User avatar
odroid
Site Admin
Posts: 36930
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1595 times
Been thanked: 1072 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by odroid »

Can you show us your config.ini file?
https://wiki.odroid.com/common/applicat ... _with_dtbo

Sebas_Ledesma
Posts: 169
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 19 times
Been thanked: 14 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by Sebas_Ledesma »

Here is my config.ini (from /media/boot)

Code: Select all

[generic]
; Auto Detection of Monitor settings based on your Screen information
display_autodetect=true

; HDMI Mode
; Resolution Configuration
;    Symbol             | Resolution
; ----------------------+-------------
;    "480x272p60hz"     | 480x272 Progressive 60Hz
;    "480x320p60hz"     | 480x320 Progressive 60Hz
;    "480p60hz"         | 720x480 Progressive 60Hz
;    "576p50hz"         | 720x576 Progressive 50Hz
;    "720p60hz"         | 1280x720 Progressive 60Hz
;    "720p50hz"         | 1280x720 Progressive 50Hz
;    "1080p60hz"        | 1920x1080 Progressive 60Hz
;    "1080p50hz"        | 1920x1080 Progressive 50Hz
;    "1080p30hz"        | 1920x1080 Progressive 30Hz
;    "1080p24hz"        | 1920x1080 Progressive 24Hz
;    "1080i60hz"        | 1920x1080 Interlaced 60Hz
;    "1080i50hz"        | 1920x1080 Interlaced 50Hz
;    "2160p60hz"        | 3840x2160 Progressive 60Hz
;    "2160p50hz"        | 3840x2160 Progressive 50Hz
;    "2160p30hz"        | 3840x2160 Progressive 30Hz
;    "2160p25hz"        | 3840x2160 Progressive 25Hz
;    "2160p24hz"        | 3840x2160 Progressive 24Hz
;    "smpte24hz"        | 3840x2160 Progressive 24Hz SMPTE
;    "2160p60hz420"     | 3840x2160 Progressive 60Hz YCbCr 4:2:0
;    "2160p50hz420"     | 3840x2160 Progressive 50Hz YCbCr 4:2:0
;    "640x480p60hz"     | 640x480 Progressive 60Hz
;    "800x480p60hz"     | 800x480 Progressive 60Hz
;    "800x600p60hz"     | 800x600 Progressive 60Hz
;    "1024x600p60hz"    | 1024x600 Progressive 60Hz
;    "1024x768p60hz"    | 1024x768 Progressive 60Hz
;    "1280x800p60hz"    | 1280x800 Progressive 60Hz
;    "1280x1024p60hz"   | 1280x1024 Progressive 60Hz
;    "1360x768p60hz"    | 1360x768 Progressive 60Hz
;    "1440x900p60hz"    | 1440x900 Progressive 60Hz
;    "1600x900p60hz"    | 1600x900 Progressive 60Hz
;    "1600x1200p60hz"   | 1600x1200 Progressive 60Hz
;    "1680x1050p60hz"   | 1680x1050 Progressive 60Hz
;    "1920x1200p60hz"   | 1920x1200 Progressive 60Hz
;    "2560x1080p60hz"   | 2560x1080 Progressive 60Hz
;    "2560x1440p60hz"   | 2560x1440 Progressive 60Hz
;    "2560x1600p60hz"   | 2560x1600 Progressive 60Hz
;    "3440x1440p60hz"   | 3440x1440 Progressive 60Hz
hdmimode=1080p60hz

; Monitor output
; Controls if HDMI PHY should output anything to the monitor
monitor_onoff=false

; Overscan percentage
; This value scales down the actual screen size by the percentage below
; valid range is 80 to 100
overscan=100

; SDR/HDR Configuration
; This forces SDR or HDR modes
; valid options are: sdr hdr auto
sdrmode=auto

; voutmode : hdmi or dvi
; hdmi / dvi
voutmode=hdmi

; HPD enable/disable option
; false / true
disablehpd=false

; Enable/Disable CEC
cec=true

; Hardkernel ODROID-VU7 support
; By default VU7 support is disabled
disable_vu7=true

; Maximum CPU frequency
; 100/250/500/667/1000/1200/1404/1500/1608/1704/1800/1908 (stock)/2016/2100
; max_freq_a55=1800


; Maximum number of CPU cores
maxcpus=4

; Wake-On-Lan support (0=disable, 1=enable)
; enable_wol=1


; Device Tree Overlay
overlay_resize=16384
overlay_profile=
overlays="spi0 i2c0 i2c1 uart0"

[overlay_custom]
overlays="i2c0 i2c1"

[overlay_hktft32]
overlays="hktft32"

[overlay_hktft35]
overlays="hktft35"

Sebas

Sebas_Ledesma
Posts: 169
Joined: Thu Jun 08, 2017 2:49 am
languages_spoken: english
ODROIDs: c2
Has thanked: 19 times
Been thanked: 14 times
Contact:

Re: wiringPiISR: unable to open /sys/class/gpio/gpio485/direction

Post by Sebas_Ledesma »

In config.ini I've changed:

Code: Select all

overlays="spi0 i2c0 i2c1 uart0"
to

Code: Select all

overlays="i2c0 i2c1 uart0"
and now the spidev it's not listed in lsmod and I can use wiringPi 13 and 14 (pins 21 & 23 of the 40 pin connector).

I can also confirm that wiringPiISR function works in Ubuntu 20.04 , kernel 4.9.241-69.

Thanks!
These users thanked the author Sebas_Ledesma for the post:
odroid (Tue Feb 23, 2021 10:05 am)

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: Sebas_Ledesma and 1 guest