This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[TDA4VM] Configuring and manipulating GPIO



Hi,

I would like to be able to configure and use I3C pins as GPIO in both ways described here:

  1. Using sysfs
    Problem: how do I get the number of a pin which I should put in export?
    According to EVM User Guide GPIO symbol of e.g. I3C0_SDA is GPIO1_6, but a "global" pin number is required (like 384).
  2. Using Device Tree
    I already found where *.dts files are stored and where should *.dtb files be placed, but what is the way of compiling and decompiling them?

Kind regards
Łukasz Gruszczelak

  • Hi,

    You can identify based on the gpiochip. I agree it is tedious, but there is no other way.

    Run following to find out which is the DT node for main_gpio1

    root@j7-evm:~# find /proc/device-tree/__symbols__/ | grep gpio
    /proc/device-tree/__symbols__/main_gpio_intr
    /proc/device-tree/__symbols__/main_gpio7
    /proc/device-tree/__symbols__/main_gpio5
    /proc/device-tree/__symbols__/wkup_gpio0
    /proc/device-tree/__symbols__/main_gpio3
    /proc/device-tree/__symbols__/main_gpio1
    /proc/device-tree/__symbols__/gpio_keys
    /proc/device-tree/__symbols__/wkup_gpio_intr
    /proc/device-tree/__symbols__/main_gpio6
    /proc/device-tree/__symbols__/wkup_gpio1
    /proc/device-tree/__symbols__/main_gpio4
    /proc/device-tree/__symbols__/main_gpio2
    /proc/device-tree/__symbols__/main_gpio0

    Read the content to find the path inside DT

     

    root@j7-evm:~# cat /proc/device-tree/__symbols__/main_gpio1
    /interconnect@100000/gpio@601000

    root@j7-evm:~#

     

    Now that you know that the gpiochip you are looking for is for the device gpio@601000

    You can check which gpiochip is registered with that platform device.

     

    root@j7-evm:~# ls -ls /sys/class/gpio/
    total 0
    0 --w------- 1 root root 65536 Oct 16 21:30 export
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip0 -> ../../devices/platform/interconnect@100000/interconnect@100000:interconnect@28380000/42110000.gpio/gpio/
    gpiochip0
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip212 -> ../../devices/platform/interconnect@100000/601000.gpio/gpio/gpiochip212
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip448 -> ../../devices/platform/interconnect@100000/2010000.i2c/i2c-4/4-0020/gpio/gpiochip448
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip456 -> ../../devices/platform/interconnect@100000/2060000.i2c/i2c-9/9-0020/gpio/gpiochip456
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip464 -> ../../devices/platform/interconnect@100000/2030000.i2c/i2c-6/6-0020/gpio/gpiochip464
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip472 -> ../../devices/platform/interconnect@100000/2000000.i2c/i2c-3/3-0022/gpio/gpiochip472
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip496 -> ../../devices/platform/interconnect@100000/2000000.i2c/i2c-3/3-0020/gpio/gpiochip496
    0 lrwxrwxrwx 1 root root 0 Oct 16 21:30 gpiochip84 -> ../../devices/platform/interconnect@100000/600000.gpio/gpio/gpiochip84
    0 --w------- 1 root root 65536 Oct 16 21:30 unexport

    Once you that the gpiochip212 is representing the main_gpio0, You can simply add 6 in the 212 and the find the pin number.

     

    echo 218 > /sys/class/gpio/export

    Above should export the GPIO and you can do read/writes.

    However, please make sure that the corresponding pinmux is configured in the DTS.

    Use pinmux tool to find out the exact register for programming. Recommendation is to add a devicetree entry for pinmux.

     

     

    Regards,

    Nikhil D

  • Also, to add more information.

    TI EVM has some GPIO expander devices (i2c peripherals), so the entries you see in /sys/class/gpio/ pointing to i2c instance represents those. Ignore them.

    By default, only wkup_gpio0, main_gpio0, and main_gpio1 are enabled in Kernel dts. Other gpio banks are disabled.
    If the pin you are planning to use falls under disabled gpio banks, you will have to update kernel dts to enable them.

  • Compiling dtb:
    Commands for building kernel components including dtb file is covered as part of PSDKLA release notes -- Section 3.2.1 (Kernel User Guide)


    Converting dtb back to dts:

    Use the dtc tool from kernel folder to convert dtb file back to dts
    ./scripts/dtc/dtc -I dtb -O dts arch/arm64/boot/dts/ti/k3-j721e-common-proc-board.dtb

  • Hi,

    I will try to describe all the problems I encountered:

    Pin number for export

    I would like to check if corresponding pinmux is configured in the DTS. How can I do that? Should the first parameter given to J271E_IOPAD in macro be the same number as for the export, but in hexadecimal? We can take SPI1_CS1 (GPIO0_117) as an example, cause there are entries for that pin in DTS.

    Pin number for export: 84+117 = 201
    Pin number for J271E_IOPAD macro: 0x1d8 = 472

    Pinmux tool

    There are no entries for TDA4 pins - at least for web application version.

    Compiling dtb

    Should I run make while being in the same directory as *.dts files are stored in? Because trying to run make on my DT files returns "Nothing to be done for [...]". 

    Kind regards
    Łukasz Gruszczelak

  • Hi,

    You have to add the register offset of the pinmux in the J721E_IOPAD macro.

    Check with the marketing contact about enabling you with right pinmux tool.

    Following is returned by pinmux tool for GPIO1_6

    &main_pmx0 {
    mygpio1_pins_default: mygpio1_pins_default {
    pinctrl-single,pins = <
    J721E_IOPAD(0x21c, PIN_INPUT, 7) /* (W1) I3C0_SDA.GPIO1_6 */
    >;
    };

    };

    Regards,

    NIkhil D

  • Hi Lukasz,

    Did the previous comment answer your question regarding dts changes?
    Building dtb needs to be done from root folder of Kernel.

    Regards,
    Vishal

  • Hi,

    Actually I still have problems with device trees compiling. Running it from root kernel folder gives me this error:

    make ARCH=arm64 CROSS_COMPILE=arm-linux-gnueabihf- k3-j721e-common-proc-board.dtb
    Makefile:590: include/config/auto.conf: No such file or directory
    Makefile:621: include/config/auto.conf.cmd: No such file or directory
    ./scripts/gcc-version.sh: line 26: arm-linux-gnueabihf-gcc: command not found
    ./scripts/gcc-version.sh: line 27: arm-linux-gnueabihf-gcc: command not found
    make: arm-linux-gnueabihf-gcc: Command not found
    /bin/sh: 1: arm-linux-gnueabihf-gcc: not found
    /bin/sh: 1: arm-linux-gnueabihf-gcc: not found
    YACC scripts/kconfig/zconf.tab.c
    /bin/sh: 1: bison: not found
    scripts/Makefile.lib:196: recipe for target 'scripts/kconfig/zconf.tab.c' failed
    make[2]: *** [scripts/kconfig/zconf.tab.c] Error 127
    Makefile:534: recipe for target 'syncconfig' failed
    make[1]: *** [syncconfig] Error 2
    Makefile:633: recipe for target 'include/config/auto.conf.cmd' failed
    make: *** [include/config/auto.conf.cmd] Error 2

    I assume that the toolchain is not properly configured. However, in Kernel User Guide there is an instruction 
    export PATH=<sdk path>/linux-devkit/sysroots/x86_64-arago-linux/usr/bin:$PATH
    but I cannot see any linux-devkit folder in sdk folder. How should I proceed?

    Kind regards,
    Łukasz

  • HI,

    You should be providing aarch64 version of the compiler for 64bit ARM CPUs.

    Also, you should have run the sdk-install.sh

    Follow the documentation section 1.1.3

    Regards,

    Nikhil D

  • Hi,

    Does using aarch64 compiler version mean modifying make command to this?
    make ARCH=arm64 CROSS_COMPILE=aa64rch-linux-gnu- k3-j721e-common-proc-board.dtb

    Unfortunately that does not change a lot - even after using sdk-install.sh and setup.sh from section 1.1.3:

    Makefile:590: include/config/auto.conf: No such file or directory
    Makefile:621: include/config/auto.conf.cmd: No such file or directory
    YACC scripts/kconfig/zconf.tab.c
    /bin/sh: 1: bison: not found
    scripts/Makefile.lib:196: recipe for target 'scripts/kconfig/zconf.tab.c' failed
    make[2]: *** [scripts/kconfig/zconf.tab.c] Error 127
    Makefile:534: recipe for target 'syncconfig' failed
    make[1]: *** [syncconfig] Error 2
    Makefile:633: recipe for target 'include/config/auto.conf.cmd' failed
    make: *** [include/config/auto.conf.cmd] Error 2

    I have a feeling that I miss something fundamental.

    Kind regards
    Łukasz

  • The bison not found message message is something which is seen if some of the packages are not installed. It may be a proxy setup was wrong and some initial packages did not install.  For a kernel build, you can do a manual setup or you let the installer try and set things up.

    You can manually making sure you have bits needed for a kernel build by doing "sudo apt install build-essential libncurses5-dev gcc libssl-dev bc flex bison".  Maybe that helps build the dtbs, but you may have other gaps also.  There are other packages (like u-boot utils) which will be needed for a full kernel build.