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.

PROCESSOR-SDK-AM335X: Reading a GPIO from logo.c

Part Number: PROCESSOR-SDK-AM335X


Hi,

I am using an SDK03.03 linux build.

I enabled the logo in the kernel config and can see it is correctly put on the screen.

I want to modify the logo.c file to read a GPIO and depending on a value load one or the other logo.

If I try to include 

#include <linux/gpio.h>

and use:

gpio_get_value(67);

I get errors during kernel load 

[ 0.997713] Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa1ac134

and a lot of weired prints:

[ 0.997848] 7980: c02cca2c c02d0204 00000000 00000018 cf0479b4 cf0479a0 c0630070 c02cc9f8
[ 0.997856] 79a0: cf3a4800 00000018 cf0479d4 cf0479b8 c030aab8 c0630034 cf006800 cf3a4800
[ 0.997864] 79c0: cf3a0e00 00000720 cf047a24 cf0479d8 c0303288 c030aa30 cf3a7500 00000000
[ 0.997872] 79e0: cf047a0c cf0479f0 c0370f50 cf006800 cf3a4800 0000003c 00000000 cf006800

until it stops:

[ 0.998933] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00
00000b

Is this because I am using function incorrectly?

Or is it because I cant use this yet because something is not initialised yet?

Kind regards,

Ugnius

  • Hello,

    The gpios on the recent kernel are dynamically allocated and not statically. If you do "cat /sys/kernel/debug/gpio" you will see the gpio's allocated with their numbers, even if the gpio number is allocated the same it might happen that the GPIO controller driver itself has not been done.

    So the proper solution is to pass the gpio pin to logo.c via device tree. (hint: see other drivers how they accept gpio pins)

    Cheers,
    --Prabhakar Lad
  • Hi Prabhakar,

    Thanks for a quick reply. I will try to check how other drivers get it from device tree.

    Kind regards,
    Ugnius
  • Hi,

    I added:
    check_ok = gpio_request(67, "button0");

    before using:
    gpio_val = gpio_get_value(67);

    This is working fine.
    If I have gpio_free(67) before gpio_get_value, then it crashed.

    So the way I understand it, the gpio_request() creates access to the GPIO.
    So that I can use functions on it.
    And gpio_free() releases it.

    Kind regards,
    Ugnius