LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices



Reply
 
Search this Thread
Old 10-23-2010, 09:39 AM   #1
raulapati
Member
 
Registered: May 2010
Posts: 51

Rep: Reputation: 0
Question how to interface ade7758 to at91sam9261 using spi


am trying to interface ade7758(adc) to at91sam9261...i have written a sample code which registers an spi driver and sends an address to ade7758 and receives a data...every thing is fine.My device is registered but kernel is giving a crash message....below is the message....



pl2303: Prolific PL2303 USB to serial adaptor driver
USB Serial support registered for TI USB 3410 1 port adapter
USB Serial support registered for TI USB 5052 2 port adapter
usbcore: registered new interface driver ti_usb_3410_5052
ti_usb_3410_5052: v0.9:TI USB 3410/5052 Serial Driver
udc: at91_udc version 3 May 2006
mice: PS/2 mouse device common for all mice
gpio-keys: failed to configure input direction for GPIO 0, error -22
gpio-keys: probe of gpio-keys failed with error -22
ads7846 spi0.2: touchscreen, irq 29
input: ADS784x Touchscreen as /class/input/input0
i2c /dev entries driver
input: adp5588-keys as /class/input/input1
adp5588-keys 0-0034: Rev.2 keypad, irq 46
i2c-gpio i2c-gpio: using pins 39 (SDA) and 40 (SCL)
rx8025 0-0032: a power voltage drop was detected, you may have to readjust the clock
loaded driver for RX-8025 SA/NB on addr 50
**********
ADC spi Driver is registered
******************************
Misc driver for ADC is registered
***********RBuf[0]= 00TBuf[0]= 48

RBuf[0]=00----------********************


***********************************inwrite***********


-------------after spi_message_init------>

After msg add----------------><2>kernel BUG at arch/arm/mm/dma-mapping.c:495!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 805 [#1] PREEMPT
Modules linked in:
CPU: 0 Not tainted (2.6.28-ATIL-H10 #109)
PC is at __bug+0x20/0x2c
LR is at vprintk+0x360/0x3b4
pc : [<c002e98c>] lr : [<c0043a8c>] psr: 20000013
sp : c3817da0 ip : c3817cf8 fp : c3817dac
r10: ffffffff r9 : 00000000 r8 : c3a46e00
r7 : c39f1540 r6 : c3a41360 r5 : 00000048 r4 : c3a4138c
r3 : 00000000 r2 : c3816000 r1 : c3816000 r0 : 00000030
Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 0005317f Table: 20004000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3816268)
Stack: (0xc3817da0 to 0xc3818000)
7da0: c3817dbc c3817db0 c0030518 c002e97c c3817de4 c3817dc0 c01df8bc c00304bc
7dc0: c3a41360 c3817dec 00000000 00000000 00000000 00000000 c3817e14 c3817de8
7de0: c01de968 c01df828 c0043b08 00000000 c3817df0 c3817df0 c3817e34 c3a41360
7e00: c05fb750 c3a46e00 c3817e34 c3817e18 c0218908 c01de930 c3817e64 c05fb774
7e20: c05fb76c c05fb748 c3817e64 c3817e38 c001efcc c0218878 00000001 c0025758
7e40: c3817e64 c03ddba4 c0025758 00000000 c001ef28 00000001 c3817fdc c3817e68
7e60: c002a318 c001ef38 00000104 00000104 c3817eb4 c3817e80 c3817ecc 00000000
7e80: c38035a4 a0000013 c3817edc 00000000 c38035a4 a0000013 c3817ec4 c3817ea8
7ea0: c008faf8 c01626d8 c38035a4 0000010e c38035a0 00000000 c3817f24 c3817ec8
7ec0: c01591f4 c008fae4 c3817ef4 c3817f44 00000000 00000000 000000d0 c3811e30
7ee0: 00000000 a0000013 c3817f1c c3817ef8 c0159454 c02eea0c 000000d0 c3816000
7f00: c38345c0 c38336e0 c03e5f90 c3817f44 00000000 00000000 c3817f34 c3817f28
7f20: c0159228 00000000 c3817f6c c3817f38 c00d105c c02eea0c c3834618 c00d0e20
7f40: c03c0584 0000010e c3817f96 c38345c0 c03c0584 0000007f c03e5f90 00000000
7f60: c3817f8c c3817f70 c00d11c4 c00d0ea8 c3817f8c c38336e0 c00d1200 c3817f96
7f80: c3817fbc c3817f90 c006d7ec c00d1154 c3817fac 32312060 00000037 00000000
7fa0: 000000c0 c03c14c0 c03be7bc 00000000 c3817fdc c3817fc0 c006d858 c002567c
7fc0: c0025758 00000000 00000000 00000000 c3817ff4 c3817fe0 c00088d8 c002a2c8
7fe0: 00000000 00000000 00000000 c3817ff8 c0045bd8 c0008874 ffffffff ffffffff
Backtrace:
[<c002e96c>] (__bug+0x0/0x2c) from [<c0030518>] (dma_cache_maint+0x6c/0x98)
[<c00304ac>] (dma_cache_maint+0x0/0x98) from [<c01df8bc>] (atmel_spi_transfer+0xa4/0x1b0)
[<c01df818>] (atmel_spi_transfer+0x0/0x1b0) from [<c01de968>] (spi_sync+0x48/0x6c)
[<c01de920>] (spi_sync+0x0/0x6c) from [<c0218908>] (Format_spi_write_data+0xa0/0xd8)
r6:c3a46e00 r5:c05fb750 r4:c3a41360
[<c0218868>] (Format_spi_write_data+0x0/0xd8) from [<c001efcc>] (ADE7758_init+0xa4/0xec)
r6:c05fb748 r5:c05fb76c r4:c05fb774
[<c001ef28>] (ADE7758_init+0x0/0xec) from [<c002a318>] (__exception_text_end+0x60/0x190)
r8:00000001 r7:c001ef28 r6:00000000 r5:c0025758 r4:c03ddba4
[<c002a2b8>] (__exception_text_end+0x0/0x190) from [<c00088d8>] (kernel_init+0x74/0xdc)
r8:00000000 r7:00000000 r6:00000000 r5:c0025758 r4:c002567c
[<c0008864>] (kernel_init+0x0/0xdc) from [<c0045bd8>] (do_exit+0x0/0x79c)
r5:00000000 r4:00000000
Code: e1a01000 e59f000c eb005455 e3a03000 (e5833000)
---[ end trace 03c78116ca73337f ]---
Kernel panic - not syncing: Attempted to kill init!






can any body please help meeeee..........
 
Old 10-23-2010, 06:05 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
You probably have a bug somewhere around sending a SPI command. Is the code long?
 
Old 10-25-2010, 09:46 AM   #3
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
abd

Last edited by raulapati; 03-14-2012 at 06:19 AM.
 
Old 10-25-2010, 03:47 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
1. Check if bus is NULL.
2. You have more printk() than those in the code you show.
3. The crash is in functions called from spi_sync(). But you have commented the function out. Does the code correspond to the crash?
 
Old 10-26-2010, 12:45 AM   #5
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
yes this is the code which leads to kernel crash....when i call spi_write_then_read()internally it calls spi_sync()...
 
Old 10-26-2010, 02:15 AM   #6
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
**********
ADC spi Driver is registered
******************************
Misc driver for ADC is registered
*************************IN SPI_READ FROM DEVICE****************
After spi_message_init
After print_buf---013<1>Unable to handle kernel NULL pointer dereference at virtual address 00000013
pgd = c0004000
[00000013] *pgd=00000000
Internal error: Oops: 5 [#1] PREEMPT
Modules linked in:
CPU: 0 Not tainted (2.6.28-ATIL-H10 #251)
PC is at memcpy+0xc0/0x330
LR is at spi_write_then_read+0xc0/0x130
pc : [<c01579a0>] lr : [<c01df118>] psr: 80000013
sp : c3817da4 ip : c3817db0 fp : c3817e2c
r10: 00000000 r9 : c05fb771 r8 : 00000013
r7 : 00000001 r6 : 00000002 r5 : c3817df8 r4 : c3801c40
r3 : c05fa770 r2 : 80000000 r1 : 00000013 r0 : c3801c40
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 0005317f Table: 20004000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3816268)
Stack: (0xc3817da4 to 0xc3818000)
7da0: c3801c40 c3801c40 c01df118 c3817df8 c3817df8 00000000 00000000
7dc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
7de0: 00000000 00000002 00000000 00000000 00000000 00000000 c3817db0 c3817db0
7e00: c0043b08 c3a41360 c05fb770 00000000 c001ef18 00000001 00000000 00000000
7e20: c3817e4c c3817e30 c021881c c01df068 00000001 c3817e50 c05fb771 00000000
7e40: c3817e64 c3817e50 c001ef60 c0218778 c03ddba4 c00256e8 c3817fdc c3817e68
7e60: c002a318 c001ef28 c0047f44 c0047dc8 00000001 c03ba958 c3817ecc 00000000
7e80: c38035a4 a0000013 c3817edc 00000000 c38035a4 a0000013 c3817ec4 c3817ea8
7ea0: c008faf8 c01626d8 c38035a4 0000010e c38035a0 00000000 c3817f24 c3817ec8
7ec0: c01591f4 c008fae4 c3817ef4 c3817f44 00000000 00000000 000000d0 c3811e30
7ee0: 00000000 a0000013 c3817f1c c3817ef8 c0159454 c02ee95c 000000d0 c3816000
7f00: c38345c0 c38336e0 c03e5f90 c3817f44 00000000 00000000 c3817f34 c3817f28
7f20: c0159228 00000000 c3817f6c c3817f38 c00d105c c02ee95c c3834618 c00d0e20
7f40: c03c0584 0000010e c3817f96 c38345c0 c03c0584 0000007f c03e5f90 00000000
7f60: c3817f8c c3817f70 c00d11c4 c00d0ea8 c3817f8c c38336e0 c00d1200 c3817f96
7f80: c3817fbc c3817f90 c006d7ec c00d1154 c3817fac 32312060 00000037 00000000
7fa0: 000000c0 c03c14c0 c03be7bc 00000000 c3817fdc c3817fc0 c006d858 c002560c
7fc0: c00256e8 00000000 00000000 00000000 c3817ff4 c3817fe0 c00088d8 c002a2c8
7fe0: 00000000 00000000 00000000 c3817ff8 c0045bd8 c0008874 ffffffff ffffffff
Backtrace:
[<c01df058>] (spi_write_then_read+0x0/0x130) from [<c021881c>] (Format_spi_read_data+0xb4/0x124)
[<c0218768>] (Format_spi_read_data+0x0/0x124) from [<c001ef60>] (ADE7758_init+0x48/0x84)
r5:00000000 r4:c05fb771
[<c001ef18>] (ADE7758_init+0x0/0x84) from [<c002a318>] (__exception_text_end+0x60/0x190)
r5:c00256e8 r4:c03ddba4
[<c002a2b8>] (__exception_text_end+0x0/0x190) from [<c00088d8>] (kernel_init+0x74/0xdc)
r8:00000000 r7:00000000 r6:00000000 r5:c00256e8 r4:c002560c
[<c0008864>] (kernel_init+0x0/0xdc) from [<c0045bd8>] (do_exit+0x0/0x79c)
r5:00000000 r4:00000000
Code: e4808004 e480e004 e8bd01e0 e1b02f82 (14d13001)
---[ end trace 7f84daede1ee30bc ]---
Kernel panic - not syncing: Attempted to kill init!
 
Old 10-26-2010, 02:17 AM   #7
raulapati
Member
 
Registered: May 2010
Posts: 51

Original Poster
Rep: Reputation: 0
ABOVE IS THE RESULT OF KERNEL CRASH DUE TO FOLLOWING CODE ..ACA ANY BODY PLEASE TELL MEE WHAT MIGHT BE THE REASON.............


void Format_spi_read_data(struct device *dev)
{
struct spi_device *spi = to_spi_device(dev);
struct adc_bus *bus = kzalloc(sizeof *bus,GFP_KERNEL);
printk("**************IN SPI_READ FROM DEVICE****************");
TBuf[0] = ADE_CFNUM;
spi_message_init(&bus->adc_msg);
printk("\nAfter spi_message_init");
bus->adcxfer.tx_buf = TBuf[0];
printk("\nAfter print_buf---%03x",TBuf[0]);
bus->adcxfer.len =2;
spi_message_add_tail(&bus->adcxfer,&bus->adc_msg);
CS_CHANGE(bus->adcxfer);
status=spi_write_then_read(adc_spi,TBuf[0],2,RBuf,1);
CS_CHANGE(bus->adcxfer);
printk("\n***************adcxfer.tx_buf %04d and rx_buf %04d ------->\n",bus->adcxfer.tx_buf,bus->adcxfer.rx_buf);



}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
driver for ADE7758 ADC raulapati Programming 11 10-13-2010 12:59 AM
how to interface ade7758 to at91sam9261 by SPI protocol raulapati Linux - Hardware 1 10-11-2010 08:45 AM
SPI interface with AT91SAM9261 sunr2007 Linux - Embedded & Single-board computer 0 08-03-2009 04:43 AM
ALPS touchpad with SPI interface can not work in relative mode!!! fromker Linux - Embedded & Single-board computer 0 02-24-2009 10:27 PM


All times are GMT -5. The time now is 10:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration