Page 1 of 1

[SOLVED] Available GPIOs when using the LCD shield

Posted: Fri Apr 14, 2017 8:26 pm
by mad_ady
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

Re: Available GPIOs when using the LCD shield

Posted: Sat Apr 15, 2017 12:22 am
by Bagman
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!

Re: Available GPIOs when using the LCD shield

Posted: Sat Apr 15, 2017 1:51 am
by mad_ady
I'll try next week (I access them via /sys) and report back

Re: Available GPIOs when using the LCD shield

Posted: Sat Apr 15, 2017 10:23 am
by odroid
You can't use GPIOs in J7 until you change the DT file to disable the I2S function.

Re: Available GPIOs when using the LCD shield

Posted: Sat Apr 15, 2017 12:34 pm
by Bagman
Ill assume that means i would need to do similar steps as

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

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 5:11 pm
by mad_ady
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?

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 5:18 pm
by odroid
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

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 5:48 pm
by mad_ady
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...

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 5:57 pm
by odroid
GPIOAO.BIT6 seems to be mapped to SPDIF output.
So you might need to find another item in the DT file.

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 6:04 pm
by mad_ady
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

Re: Available GPIOs when using the LCD shield

Posted: Thu Apr 20, 2017 6:09 pm
by mad_ady
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. :)

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

Posted: Thu Apr 20, 2017 7:10 pm
by odroid
Ok.

Nice script to keep using the GPIO functionality. :D

Re: Available GPIOs when using the LCD shield

Posted: Fri Jan 18, 2019 7:56 pm
by Manikandan
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?

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

Posted: Fri Jan 18, 2019 8:07 pm
by Manikandan
After Disabled how to enable it again.

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

Posted: Fri Jan 18, 2019 9:42 pm
by mad_ady
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.

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

Posted: Mon Jan 28, 2019 7:36 pm
by Manikandan
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.