All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anders Darander <anders@chargestorm.se>
To: Jack <jackrubby2010@gmail.com>,
	"yocto@yoctoproject.org" <yocto@yoctoproject.org>
Subject: Re: "Kernel access of bad area" in kernel module
Date: Tue, 1 Oct 2013 16:39:44 +0200	[thread overview]
Message-ID: <4607a605-12cd-476d-92fa-47ded39e2905@email.android.com> (raw)
In-Reply-To: <loom.20131001T154728-532@post.gmane.org>



Jack <jackrubby2010@gmail.com> wrote:
>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); 

You should generally a of trying to dereference physical addresses, or you should explicitly declare them as such. 

If suggest looking for some info on using GPIO on your CPU. Unfortunately, I've not used the p1022, so I can't really help you. 

http://linuxppc.10917.n7.nabble.com/Re-GPIO-IRQ-on-P1022-td59356.html discusses some IRQ issues, though you should be able to use the codes as an example of the GPIO framework and how to use it. 

Cheers, 
Anders 

>
>	// 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?
>
>
>_______________________________________________
>yocto mailing list
>yocto@yoctoproject.org
>https://lists.yoctoproject.org/listinfo/yocto

-- 
Anders Darander
ChargeStorm AB          Tel: +46 702 44 84 36
Laxholmstorget 3        Email: anders@chargestorm.se
602 21 Norrköping       Web: www.chargestorm.se

Sent from my Android phone with K-9 Mail. Please excuse my brevity.


  reply	other threads:[~2013-10-01 14:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 14:24 "Kernel access of bad area" in kernel module Jack
2013-10-01 14:39 ` Anders Darander [this message]
2013-10-03  7:47   ` (No subject) Jack
2013-10-04 17:55     ` Anders Darander
2013-10-10  7:07       ` Jack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4607a605-12cd-476d-92fa-47ded39e2905@email.android.com \
    --to=anders@chargestorm.se \
    --cc=jackrubby2010@gmail.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.