Memory mapped through gpio in beaglebone black

0

We are using beaglebone black through which data is taken. Temprature sensor dht11 is taken from the GPIO of beagle bone black.

Normal on and off (one way transmission) is done easily but when it comes to continuous data transmission we are getting memory mapped issue in android.

Below is the declaration part.

typedef struct {
unsigned int id; /**< FS: ID is the file for the pin */
unsigned char bank; /**< MMAP: GPIO bank determines register */
unsigned int mask; /**< MMAP: Mask determines bit in register */
} GPIOBit_t;
static const uint32_t gpioAddrs[] = { 0x44E07000, 0x4804C000, 0x481AC000,0x481AE000 }; /**< Register Bank addresses */
static uint32_t *mapGPIO[4]; /**< Variable for GPIO memory map */
#define GPIO_OE_REG           0x134     /**< GPIO OE register address */

Below is the function where issue is generated.

static void writeGPIOMmapdir(const GPIOBit_t *pinGPIO, const unsigned int value) {

fdGPIO = open("/dev/mem", O_RDWR);
/* mmap() the four GPIO bank registers */
int j;
for (j = 0; j < 4; j++) {

    mapGPIO[j] = (uint32_t *) mmap(NULL, getpagesize(),PROT_READ | PROT_WRITE, MAP_SHARED, fdGPIO, gpioAddrs[j]);

    unsigned int reg;
    reg = mapGPIO[1][GPIO_OE_REG / 4];
    if (value) {
        reg = reg | pinGPIO->mask;

        /* Set the appropriate OE register */
        //*****************ISSUE IS IN BELOW LINE*******************
        mapGPIO[pinGPIO->bank][GPIO_OE_REG / 4] = reg;
    } else {
        reg = reg & (0xFFFFFFFF - pinGPIO->mask);
        mapGPIO[pinGPIO->bank][GPIO_OE_REG / 4] = reg;
    }
}

Getting memory mapped issue in logcat. And then the whole application restarts itself.

01-01 00:19:30.814: A/libc(965): Fatal signal 11 (SIGSEGV) at 0x00000134 (code=1), thread 983 (Thread-56)

If possible can anyone help me on this.

Thanks :)

android
c
android-ndk
beagleboneblack
beagleboard
asked on Stack Overflow May 12, 2016 by sumit • edited May 12, 2016 by LPs

1 Answer

1

Shouldn't this :

reg = mapGPIO[1][GPIO_OE_REG / 4];

Be :

reg = mapGPIO[j][GPIO_OE_REG / 4];

?

answered on Stack Overflow May 12, 2016 by sheham • edited May 12, 2016 by LPs

User contributions licensed under CC BY-SA 3.0