[SOLVED] Available GPIOs when using the LCD shield

Post Reply
User avatar
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

[SOLVED] Available GPIOs when using the LCD shield

Unread post by 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.

Bagman
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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!

User avatar
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

Re: Available GPIOs when using the LCD shield

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

I'll try next week (I access them via /sys) and report back

User avatar
odroid
Site Admin
Posts: 32474
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 175 times
Been thanked: 343 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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.

Bagman
Posts: 27
Joined: Fri Jul 29, 2016 1:32 am
languages_spoken: english
Has thanked: 0
Been thanked: 0
Contact:

Re: Available GPIOs when using the LCD shield

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

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

http://forum.odroid.com/viewtopic.php?f ... le#p179328

User avatar
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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
odroid
Site Admin
Posts: 32474
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 175 times
Been thanked: 343 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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
odroid
Site Admin
Posts: 32474
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 175 times
Been thanked: 343 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by 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
odroid
Site Admin
Posts: 32474
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 175 times
Been thanked: 343 times
Contact:

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

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

Ok.

Nice script to keep using the GPIO functionality. :D

Manikandan
Posts: 52
Joined: Tue Feb 28, 2017 2:51 pm
languages_spoken: english
ODROIDs: ODROID C2
Has thanked: 0
Been thanked: 0
Contact:

Re: Available GPIOs when using the LCD shield

Unread post by Manikandan » Fri Jan 18, 2019 7:56 pm

mad_ady wrote:
Thu Apr 20, 2017 5:11 pm

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
How to disable the UART Function?

Manikandan
Posts: 52
Joined: Tue Feb 28, 2017 2:51 pm
languages_spoken: english
ODROIDs: ODROID C2
Has thanked: 0
Been thanked: 0
Contact:

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

Unread post by Manikandan » Fri Jan 18, 2019 8:07 pm

After Disabled how to enable it again.

User avatar
mad_ady
Posts: 6776
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 213 times
Been thanked: 163 times
Contact:

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

Unread post by mad_ady » Fri Jan 18, 2019 9:42 pm

You may need to recompile uboot with uart moved to a different set of pins, and change the kernel boot arguments to have it use a different console.

Manikandan
Posts: 52
Joined: Tue Feb 28, 2017 2:51 pm
languages_spoken: english
ODROIDs: ODROID C2
Has thanked: 0
Been thanked: 0
Contact:

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

Unread post by Manikandan » Mon Jan 28, 2019 7:36 pm

mad_ady wrote:
Fri Jan 18, 2019 9:42 pm
You may need to recompile uboot with uart moved to a different set of pins, and change the kernel boot arguments to have it use a different console.
Thank you for your support.

Post Reply

Return to “3.5inch LCD Shield”

Who is online

Users browsing this forum: No registered users and 4 guests