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.

AM3352: Setting GPIO values in kernel 6.1.46

Part Number: AM3352

Hello,

We have our own design based on the am3352. So far we have been using kernel from SDK 05.03.00.07, and now we are trying to upgrade to FW from SDK 09.01.00.00.

New kernel 6.1.46 is starting fine, drivers are loaded ...... everything seems to be fine, but I am having problems with a basic function, just trying to request and set a value for a GPIO. I am calling:

if (!gpio_is_valid(77)){
   printk(KERN_INFO "gpioChar: invalid 77\n");
   return:
}
gpio_request(77, "gpio2_13");
gpio_direction_output(77, 1);
gpio_export(77, false);

All functions return 0, but gpio2_13 is not set to 1. I try to change IO value after this initial configuration but I can not modify the output value.

I also tryed to modify output value from /sys/class/gpio/gpio77
echo 1 > value

cat value
1

but it does not work, output value is not changed

All this functions and commans do work fine with kernel 4.19.94. It seems as if I am missing any configuration.

This issue is not only with gpio2_13, it is the same problem with other gpio.


Could you please help me to solve this issue?

Best regards

Angel

  • Hi Angel,

    Can you check .config file to see if CONFIG_GPIO_SYSFS is enabled?

    Thanks,

    Anshu

  • Hi Anshu,

    Thank you for your answer.

    Yes, CONFIG_GPIO_SYSFS is enabled in our .config file.

    I have also tried compiling using the default configuration recommended in the SDK documentation,

    make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabihf- multi_v7_defconfig ti_multi_v7_prune.config no_smp.config

    and adding CONFIG_GPIO_SYSFS. Then:

    cd /sys/class/gpio/
    echo 77 > export
    cd gpio77
    echo out > direction
    echo 1 > value
    cat value
    1

    But output signal is not changed.

    Best regards

    Angel

  • Hello,

    More info in case it can help to find the solution.

    I have also tried using the gpiod tools and, again, it works with the previous kernel, but not with 6.1.46.

    Best regards and thank you

  • Hello,

    Finally I found the issue. The problem is that relation between HW gpioX port and /sys/class/gpio/gpiochipX node has changed. This is:

    Kernel 4.19.94

    gpio0 --> gpiochip0

    gpio1 --> gpiochip1

    gpio2 --> gpiochip2

    gpio3 --> gpiochip3

    In this case gpio2_13 is pin number 77

    Kernel 6.1.46

    gpio1 --> gpiochip0

    gpio2 --> gpiochip1

    gpio3 --> gpiochip2

    gpio0 --> gpiochip3

    In this case gpio2_13 is pin number 45

    The problem is that I would like to have the same relation for the FW to be compatible.

    So, could you please help us to change/overlay am33xx-l4.dtsi  so that we can get the same relation than before?

    Best regards and thank you

    Angel

  • Hi Angel,

    Glad you found the solution.

    so that we can get the same relation than before

    So you want the gpio->gpiochip definitions to match the older kernel?  I don't think thats possible since Linux will assign them one-by-one at boot time.

    Thanks,

    Anshu

  • Hello Anshu,

    You are right, Linux will assign them one by one at boot time, but would it be possible to change the order in which the driver is called when reading information from the .dtsi file?

    I do not know how to change custom .dts and/or cpu .dtsi files so node for gpio0 is called before nodes for gpio1, gpio2 and gpio3.

    Best regards and thank you

    Angel

  • Hello Anshu,

    The problem is not the sequence the driver is called for gpioX.

    gpio-omap driver is called first for gpio0, but error -517 is returned (Driver requests probe retry). After this, driver is called for gpio1 and gpiochip0 is assigned, it is called for gpio2 and gpiochip32 is assigend and called again for gpio3 and gpiochip64 assigned.

    Finally driver is called again for gpio0 and gpiochip96 is assigned.

    So the problem is that first time driver is called for gpio0 an error is returned. I have also checked this issue with a BeagleBone and the same problem is found.

    Do you know how we can solve this problem?

    Best regards and than you

    Angel

  • Hi Angel,

    Can you provide any bootlogs that contain this error?

    Best Regards,

    Anshu

  • Hi Anshu,

    I set some traces in the gpio-omap probe function and this is the result. If you need a specific log, just tell me what you need.

    As I said before, I also checked with a BeagleBlone and when updating to 6.1.x it is the same problem.

    root@A137K3:~# dmesg | grep omap_gpio_probe
    [ 0.390872] omap_gpio_probe() ENTER dev_name(44e07000.gpio)
    [ 0.391170] omap_gpio_probe() EXIT error(-517), dev_name(44e07000.gpio)
    [ 0.471686] omap_gpio_probe() ENTER dev_name(4804c000.gpio)
    [ 0.472645] omap_gpio_probe() EXIT OK dev_name(4804c000.gpio)
    [ 2.731180] omap_gpio_probe() ENTER dev_name(481ac000.gpio)
    [ 2.777495] omap_gpio_probe() EXIT OK dev_name(481ac000.gpio)
    [ 2.786386] omap_gpio_probe() ENTER dev_name(481ae000.gpio)
    [ 2.827491] omap_gpio_probe() EXIT OK dev_name(481ae000.gpio)
    [ 3.174192] omap_gpio_probe() OWASYS ENTER dev_name(44e07000.gpio)
    [ 3.193181] omap_gpio_probe() EXIT OK dev_name(44e07000.gpio)

    Best regards and thank you

    Angel

  • Hi Angel,

    I just booted SDK 9.1 on to my Beagle Bone Black and it seemed to assign things correctly & no error messages regarding devname.

    root@am335x-evm:~# gpiodetect
    gpiochip0 [gpio-0-31] (32 lines)
    gpiochip1 [gpio-32-63] (32 lines)
    gpiochip2 [gpio-64-95] (32 lines)
    gpiochip3 [gpio-96-127] (32 lines)
    root@am335x-evm:~# uname -a
    Linux am335x-evm 6.1.46-g1d4b5da681 #1 PREEMPT Thu Oct 19 10:19:08 UTC 2023 armv7l armv7l armv7l GNU/Linux
    

    Were there any debug statements you added to gpio-omap.c or any other driver?

    Best Regards,

    Anshu

  • Hi Anshu,

    gpiodetect is the same output for me, but please also check "ls -l /sys/class/gpio"

    gpiodetect
    gpiochip0 [gpio-0-31] (32 lines)
    gpiochip1 [gpio-32-63] (32 lines)
    gpiochip2 [gpio-64-95] (32 lines)
    gpiochip3[gpio-96-127] (32 lines)

    ls -l /sys/class/gpio/
    total 0
    --w------- 1 root root 4096 Feb 14 2019 export
    lrwxrwxrwx 1 root root 0 Feb 14 2019 gpiochip0 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4804c000.target-module/4804c000.gpio/gpio/gpiochip0
    lrwxrwxrwx 1 root root 0 Feb 14 2019 gpiochip32 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@100000/481ac000.target-module/481ac000.gpio/gpio/gpiochip32
    lrwxrwxrwx 1 root root 0 Feb 14 2019 gpiochip64 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@100000/481ae000.target-module/481ae000.gpio/gpio/gpiochip64
    lrwxrwxrwx 1 root root 0 Feb 14 2019 gpiochip96 -> ../../devices/platform/ocp/44c00000.interconnect/44c00000.interconnect:segment@200000/44e07000.target-module/44e07000.gpio/gpio/gpiochip96
    --w------- 1 root root 4096 Feb 14 2019 unexport

    4804c000.gpio corresponds to gpiochip0[gpio-0-31]  but HW gpio1

    481ac000.gpio corresponds to gpiochip1 [gpio-32-63]  but HW gpio2

    481ae000.gpio corresponds to gpiochip2 [gpio-64-95] but HW gpio3

    44e07000.gpio corresponds to gpiochip3[gpio-96-127]  but HW gpio0

    Yes, I added traces to gpio-omap.c to check if any error was returned.

    I have also double checked with BBB and it is the same problem. Please check both "gpiodetect" and "ls -l /sys/class/gpio" with your BBB, version 6.1.46 and any 5.x.x version. I did check with "Linux BeagleBone 5.10.168-ti-r77"

    root@BeagleBone:~# ls -l /sys/class/gpio/
    total 0
    --w--w---- 1 root gpio 4096 Jan 1 2000 export
    lrwxrwxrwx 1 root root 0 Jan 1 2000 gpiochip0 -> ../../devices/platform/ocp/44c00000.interconnect/44c00000.interconnect:segment@200000/44e07000.target-module/44e07000.gpio/gpio/gpiochip0
    lrwxrwxrwx 1 root root 0 Jan 1 2000 gpiochip32 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@0/4804c000.target-module/4804c000.gpio/gpio/gpiochip32
    lrwxrwxrwx 1 root root 0 Jan 1 2000 gpiochip64 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@100000/481ac000.target-module/481ac000.gpio/gpio/gpiochip64
    lrwxrwxrwx 1 root root 0 Jan 1 2000 gpiochip96 -> ../../devices/platform/ocp/48000000.interconnect/48000000.interconnect:segment@100000/481ae000.target-module/481ae000.gpio/gpio/gpiochip96
    --w--w---- 1 root gpio 4096 Jan 1 2000 unexport

    Best regards and thank you

    Angel

  • Hi Angel,

    Sorry for the delay. I was able to use cat /sys/kernel/debug/gpio since to see gpio0 get assigned to gpiochip3.

    I'm not familiar with gpio-omap.c since its for an older device, but I'll be looking into it further.

    Best Regards,

    Anshu