"Kernel access of bad area" in kernel module

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

"Kernel access of bad area" in kernel module

1,213 Views
jackrubby
Contributor II

Hi,

I want to set/reset GPIO registers in freescale p1022 processor. I saw a

hello-mod kernel module in yocto and I added it to my image and it worked.

According to hello-mod kernel module, I created GPIO module like hello-mod.

But it GPIO module failed when I run it in kernel level. I checked several

times addresses of registers and it seems accurate.

My code is here :

#include <linux/module.h>

int init_module(void)

{

volatile uint32_t * Guts_Pmuxcr;

volatile uint32_t * Gpio3_Gpdir;

volatile uint32_t * Gpio3_Gpdat;

// e500 Core View To Power Architecture CCSR: 0x0_FF70_0000

  // GUTS_PMUXCR:Alternate Function Signal Multiplex Control Register

Guts_Pmuxcr = (volatile uint32_t *)(0xFF7E0060);

  // GPIO3_GPDIR: GPIO3 direction register

Gpio3_Gpdir = (volatile uint32_t *)(0xFF70F200);

  // GPIO3_GPDAT: GPIO3 data register

Gpio3_Gpdat = (volatile uint32_t *)(0xFF70F208);

// Enable GPIO3[10]: IRQ_DEBUG1_GPIO FIELD [BIT 26] set to "1"

*(Guts_Pmuxcr) = 0x00000010;

// Set Direction for GPIO3[10] to Output: FIELD DR10 [BIT 10] set to '1'

*(Gpio3_Gpdir) = 0x00200000;

// Set GPIO3[10] to '0': FIELD D10 [BIT 10] set to '0'

*(Gpio3_Gpdat) = 0x00000000;

printk("Hello World!\n");

return 0;

}

void cleanup_module(void)

{

printk("Goodbye Cruel World!\n");

}

MODULE_LICENSE("GPL");

When I write insmod GPIO.ko in the terminal I get error these errors:

Unable to handle kernel paging request for data at address 0xff7e0060

faulting instruction address: 0xf107e05c

Oops: Kernel access of bad area, sig: 11 [#1]

..........

.........

How can I solve this problem?

Labels (1)
Tags (5)
0 Kudos
2 Replies

424 Views
jackrubby
Contributor II

It wasn't any help??!! Any comment??!!

0 Kudos

424 Views
alanwang
NXP Employee
NXP Employee

Hello Jack,

With Linux, the kernel address is under protection and a physical address cannot be used directly to access the specified register or memory. In general, the address space should be remaped with ioremap() function to get its corresponding remaped address, then this address can be used to access the specified register or memory.

0 Kudos