phil123456789
phil123456789

Reputation: 41

Raspberry PI 3 - Kernel Driver - cannot access GPIO with ioremap()

I'm trying to write a kernel driver (module) that reads GPIO on a RPI3

I use ioremap to get access to the memory of the GPIO, but apparently it crashes.

I get an exception in the /var/log/messages log file

Aug  6 14:07:58 raspberrypi kernel: [  220.900252] Exception stack(0xa796ffa8 to 0xa796fff0)
Aug  6 14:07:58 raspberrypi kernel: [  220.900264] ffa0:                   fe5f5100 7eff8714 00000003 0002d064 00000000 00000004
Aug  6 14:07:58 raspberrypi kernel: [  220.900277] ffc0: fe5f5100 7eff8714 0003fce8 0000017b 007e47d8 00000000 00000002 00000000
Aug  6 14:07:58 raspberrypi kernel: [  220.900286] ffe0: 7eff8548 7eff8538 00022cb8 76cb9af0

Here is my module code:

#include <linux/module.h>
#include <linux/kernel.h>
#include <asm/io.h>

#define BCM2708_PERI_BASE        0x20000000
#define GPIO_BASE                (BCM2708_PERI_BASE + 0x200000) /* GPIO controller */

static int __init driver_init(void)
{
    if ((gpio = ioremap(GPIO_BASE, 0xB0)) == NULL) {
        printk(KERN_INFO "io remap failed\n");
        return -EBUSY;
    }

    return 0;
}

static void __exit driver_exit(void)
{
    iounmap(gpio);
}

module_init(driver_init);
module_exit(driver_exit);

Can someone tell me what I do wrong?

Is there a conflict with another driver? How can I check this?

Upvotes: 1

Views: 713

Answers (1)

phil123456789
phil123456789

Reputation: 41

base adress is 0x3F000000, not 0x2000000

Upvotes: 2

Related Questions