[SOLVED] Available GPIOs when using the LCD shield

Moderators: mdrjr, odroid

[SOLVED] Available GPIOs when using the LCD shield

Unread postby mad_ady » Fri Apr 14, 2017 8:26 pm

I was thinking about addin a relay to my C2 which uses the LCD shield and I found out from the schematics that I have the following options:
1. J1 (the RTC connector) provides 2 I2C pins and one GPIO
2. J7 (I2S connector on the C2) provides 5 I2S pins. Can they be used as GPIO pins?

What about pins 8, 10, 26, 31, 35, 37 No connection. Can those pins be accessed somehow?

Thanks
Last edited by mad_ady on Thu Apr 20, 2017 6:05 pm, edited 1 time in total.
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Available GPIOs when using the LCD shield

Unread postby Bagman » Sat Apr 15, 2017 12:22 am

2. J7 (I2S connector on the C2) provides 5 I2S pins. Can they be used as GPIO pins?


I am working to utilize the GPIO j7 Pins as well. i know the ODLib says you can use the j7, but i havent been able to access them in a meaningful way yet.

As far as i can see the accessible pins currently are (Pins 7,11,12,13,15,16,18,21,22,23,24,26,29,31,32,35,36) which includes 26, 31, 35 from your pin question.


If anyone knows how to utilize the j7 as GPIO with the ODLib please also let me know!
Bagman
 
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english

Re: Available GPIOs when using the LCD shield

Unread postby mad_ady » Sat Apr 15, 2017 1:51 am

I'll try next week (I access them via /sys) and report back
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Available GPIOs when using the LCD shield

Unread postby odroid » Sat Apr 15, 2017 10:23 am

You can't use GPIOs in J7 until you change the DT file to disable the I2S function.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Available GPIOs when using the LCD shield

Unread postby Bagman » Sat Apr 15, 2017 12:34 pm

Ill assume that means i would need to do similar steps as

viewtopic.php?f=137&t=25885&p=179328&hilit=DT+File#p179328
Bagman
 
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english

Re: Available GPIOs when using the LCD shield

Unread postby mad_ady » Thu Apr 20, 2017 5:11 pm

I installed
Code: Select all
sudo apt-get install device-tree-compiler

And used fdtdump /media/boot/meson64_odroidc2.dtb to list the device tree nodes. The I2S relevant nodes are:
Code: Select all
    I2S {
        compatible = "amlogic, aml-i2s-dai";
        #sound-dai-cells = <0x00000000>;
        resets = <0x0000000d 0x0000000d 0x0000000d 0x0000000d 0x0000000d 0x0000000d 0x00000463 0x5f627566 0x6c6b5f6d 0x6f320061 0x65725f72 0x6576656c 0x6e000000 0x0000000d 0x00000003 0x30006d63 0x0000004c 0x00000052 0x6932735f 0x00000003 0x6769632c 0x00000003>;
        reset-names = "top_glue", "aud_buf", "i2s_out", "amclk_measure", "aififo2", "aud_mixer", "mixer_reg", "adc", "top_level", "aoclk", "aud_in";
        clocks = <0x0000000d 0x00000003 0x30006d63 0x0000004c>;
        clock-names = "mpll0", "mclk";
        linux,phandle = <0x00000032>;
        phandle = <0x00000032>;
    };
    i2s_platform {
        compatible = "amlogic, aml-i2s";
        linux,phandle = <0x00000031>;
        phandle = <0x00000031>;
    };

How would one disable it? I'm guessing I'd need to set status = "disabled".
Code: Select all
# fdtput /media/boot/meson64_odroidc2.dtb /I2S status disabled
# fdtget /media/boot/meson64_odroidc2.dtb /I2S status
127
# fdtput /media/boot/meson64_odroidc2.dtb /i2s_platform status disabled
# fdtget /media/boot/meson64_odroidc2.dtb /i2s_platform status
127


The code above seems to disable i2s (I can't see any i2s output in dmesg after reboot): dmesg | grep -i i2s

And once it is disabled, what are the GPIO IDs that we can use?
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Available GPIOs when using the LCD shield

Unread postby odroid » Thu Apr 20, 2017 5:18 pm

Visit this link and scroll down little bit. And you can find GPIO numbers on J7 connector.
http://odroid.com/dokuwiki/doku.php?id= ... connectors
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Available GPIOs when using the LCD shield

Unread postby mad_ady » Thu Apr 20, 2017 5:48 pm

Thanks odroid, I missed that :)

I tested with the GPIOs, however GPIO #128 (GPIOAO.BIT6) can't be enabled:
Code: Select all
root@kbd:/sys/class/gpio# echo 128 > /sys/class/gpio/export
-su: echo: write error: Invalid argument
root@kbd:/sys/class/gpio# echo 130 > /sys/class/gpio/export
root@kbd:/sys/class/gpio# echo out > /sys/class/gpio/gpio130/direction
root@kbd:/sys/class/gpio# echo 0 > /sys/class/gpio/gpio130/value
root@kbd:/sys/class/gpio# echo 1 > /sys/class/gpio/gpio130/value
root@kbd:/sys/class/gpio# echo 132 > /sys/class/gpio/export
root@kbd:/sys/class/gpio# echo out > /sys/class/gpio/gpio132/direction
root@kbd:/sys/class/gpio# echo 0 > /sys/class/gpio/gpio132/value
root@kbd:/sys/class/gpio# echo 1 > /sys/class/gpio/gpio132/value
root@kbd:/sys/class/gpio# echo 131 > /sys/class/gpio/export
root@kbd:/sys/class/gpio# echo out > /sys/class/gpio/gpio131/direction
root@kbd:/sys/class/gpio# echo 0 > /sys/class/gpio/gpio131/value
root@kbd:/sys/class/gpio# echo 1 > /sys/class/gpio/gpio131/value
root@kbd:/sys/class/gpio# echo 133 > /sys/class/gpio/export
root@kbd:/sys/class/gpio# echo out > /sys/class/gpio/gpio133/direction
root@kbd:/sys/class/gpio# echo 0 > /sys/class/gpio/gpio133/value
root@kbd:/sys/class/gpio# echo 1 > /sys/class/gpio/gpio133/value


The others work as expected.
Now, I only have to figure out how to hook the commands to update the dtb after every kernel update...
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Available GPIOs when using the LCD shield

Unread postby odroid » Thu Apr 20, 2017 5:57 pm

GPIOAO.BIT6 seems to be mapped to SPDIF output.
So you might need to find another item in the DT file.
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Available GPIOs when using the LCD shield

Unread postby mad_ady » Thu Apr 20, 2017 6:04 pm

Ok, quick update. Here's how to make it "stick" across kernel updates:
1. Install device-tree-compiler
Code: Select all
sudo apt-get install device-tree-compiler

2. Create a file called /etc/kernel/postinst.d/i2s-disable
Code: Select all
$ cat /etc/kernel/postinst.d/i2s-disable
#!/bin/bash

#disable i2s for Odroid C2 after each kernel update
#requires device-tree-compiler
# sudo apt-get install device-tree-compiler

echo "Disabling I2S support from the device tree"
/usr/bin/fdtput /media/boot/meson64_odroidc2.dtb /I2S status disabled
/usr/bin/fdtput /media/boot/meson64_odroidc2.dtb /i2s_platform status disabled

3. Mark the file as executable
Code: Select all
$ sudo chmod a+x /etc/kernel/postinst.d/i2s-disable


Now, when you install a new kernel, the file will be executed and will modify the new dtb:
Code: Select all
$ sudo apt-get install --reinstall linux-image-3.14.79-110
...
run-parts: executing /etc/kernel/postinst.d/i2s-disable 3.14.79-110 /boot/vmlinuz-3.14.79-110
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: Available GPIOs when using the LCD shield

Unread postby mad_ady » Thu Apr 20, 2017 6:09 pm

odroid wrote:GPIOAO.BIT6 seems to be mapped to SPDIF output.
So you might need to find another item in the DT file.

I tried with
Code: Select all
fdtput /media/boot/meson64_odroidc2.dtb /SPDIF  status disabled


but I still can't export GPIO#128. Oh, well, no matter. I have the other 4 working. :)
User avatar
mad_ady
 
Posts: 4582
Joined: Wed Jul 15, 2015 5:00 pm
Location: Bucharest, Romania
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1

Re: [SOLVED] Available GPIOs when using the LCD shield

Unread postby odroid » Thu Apr 20, 2017 7:10 pm

Ok.

Nice script to keep using the GPIO functionality. :D
User avatar
odroid
Site Admin
 
Posts: 28697
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to 3.5inch LCD Shield

Who is online

Users browsing this forum: No registered users and 1 guest