[SOM APF8 - iMX28] file system gpio event crach board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[SOM APF8 - iMX28] file system gpio event crach board

565 Views
loicr
Contributor I

Hi,

When I configure sysfs gpio, for example :

cd /sys/class/gpio/

echo 45 > export

echo rising > edge // or falling or both

and use program after, my board crash.

When I configure the edge at "none", the poll is not blocking

Can you help me please?

Best Regards

Loïc

-----------------------------------------------------------------------------

#include <fcntl.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int main(int argc, char * argv[])
{
    int fd;
    struct pollfd  fds;
    char buffer[2];

    if (argc != 2) {
        fprintf(stderr, "usage: %s \n", argv[0]);
        exit(EXIT_FAILURE);
    }
    if ((fd = open(argv[1], O_RDONLY)) < 0) {
        perror(argv[1]);
        exit(EXIT_FAILURE);
    }
    while (1) {
        fds.fd = fd;
        fds.events = POLLPRI; // or POLLIN
        if (poll(& fds, 1, -1) < 0) {
            perror("poll");
            break;
        }
    printf("event\n");
        lseek(fd, 0, SEEK_SET);
        if (read(fd, & buffer, 2) != 2) {
            perror("read");
            break;
        }
        buffer[1] = '\0';
    }
    close(fd);
    return EXIT_SUCCESS;
}

Tags (3)
0 Kudos
Reply
1 Reply

507 Views
fabio_estevam
NXP Employee
NXP Employee

Which kernel version do you use? Can you try with a recent kernel, such as 4.14.13?

Regards,

Fabio Estevam

0 Kudos
Reply