Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: AT91SAM9263ek SPI problem
PostPosted: Tue Mar 08, 2011 11:28 am 
Offline

Joined: Tue Mar 08, 2011 10:58 am
Posts: 3
Hi,

I'm working on a custom hardware running Linux kernel 2.6.32.3. The hardware is based on the AT91SAM9263-ek evaluation board and have touch screen attached to it. The touch screen controller is ads7846 and is connected to SPI.

I'm in some trouble using the SPI (driver: atmel_spi).

ads7846 have two extra inputs that I want to use. The problem is that when reading these inputs from sysfs I get a lot of zeroes when it should read ( when no sensor is connected) ~3300 mV, e.g.
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0
~# cat /sys/bus/spi/devices/spi0.1/in0_input
3299 <-- This one is correct.
~# cat /sys/bus/spi/devices/spi0.1/in0_input
0

I have measured the input and it's stable at 3.3V.

Do anyone know why I read so many zeroes?


The second problem is a kernel krasch. The process adreader is reading the sys/bus/spi/devices/spi0.1/in0_input and /sys/bus/spi/devices/spi0.1/in1_input every second. After about 5 days the kernel krasched dumping the following message to the consol:

[425375.800000] Unable to handle kernel NULL pointer dereference at virtual address 00000016
[425375.810000] pgd = c3084000
[425375.810000] [00000016] *pgd=23051031, *pte=00000000, *ppte=00000000
[425375.810000] Internal error: Oops: 17 [#1] PREEMPT
[425375.810000] last sysfs file: /sys/devices/platform/atmel_spi.0/spi0.1/in0_input
[425375.810000] Modules linked in: atmel_pwm_bl
[425375.810000] CPU: 0 Not tainted (2.6.32.3E1219BSpitfire #1)
[425375.810000] PC is at atmel_spi_interrupt+0x64/0x218
[425375.810000] LR is at atmel_spi_interrupt+0x14/0x218
[425375.810000] pc : [<c017b188>] lr : [<c017b138>] psr: 20000013
[425375.810000] sp : c3065d70 ip : c3065db8 fp : c3065e4c
[425375.810000] r10: c389a350 r9 : c3064000 r8 : 00000000
[425375.810000] r7 : c389a2a0 r6 : c389a370 r5 : 00000000 r4 : c389a358
[425375.810000] r3 : 00000202 r2 : c4890000 r1 : c4890000 r0 : c389a358
[425375.810000] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[425375.810000] Control: 0005317f Table: 23084000 DAC: 00000015
[425375.810000] Process adreader (pid: 1050, stack limit = 0xc3064270)
[425375.810000] Stack: (0xc3065d70 to 0xc3066000)
[425375.810000] 5d60: 00000000 00000041 c03031dc c39036a0
[425375.810000] 5d80: 0000000e 00000001 00000000 00000000 00000002 c0061f34 c02ee444 c39036a0
[425375.810000] 5da0: 0000000e 00000001 00000000 c0064630 0000000e 00000000 0000000e c002506c
[425375.810000] 5dc0: c3065dd4 ffffffff fefff000 c0025aa8 7fffffff c3065ed0 c38603e0 00000000
[425375.810000] 5de0: 00000000 00000000 7fffffff c3064018 c3065ecc c3258c08 00000002 c3065e4c
[425375.810000] 5e00: c3065e50 c3065e18 c02317a8 c0230e18 60000013 ffffffff c39036a0 0000000e
[425375.810000] 5e20: 00000002 00000000 00000000 7fffffff 7fffffff c3065ecc c3258c08 00000002
[425375.810000] 5e40: c3065ec4 c3065e50 c02317a8 c0230e14 23914000 00000018 c4890000 c3064000
[425375.810000] 5e60: c3258bec 60000013 c3258c08 c389a358 c389a0a0 00000000 00000000 c3064000
[425375.810000] 5e80: 7fffffff c023155c c002bcd4 00000001 c38603e0 c0039790 c3065ed0 c3065ed0
[425375.810000] 5ea0: c3258c08 c3065ecc 00000000 00000002 c389a0a0 c3258c00 c3add800 c3065ec8
[425375.810000] 5ec0: c017a124 c023146c c02ee994 00000001 c3065e98 c3065e98 c3258cbc c3258ce0
[425375.810000] 5ee0: c3258d04 c01a3a5c c39cd560 c389a0a0 c3add800 c3227000 c02f87f0 c3065f88
[425375.810000] 5f00: c39cd578 00000000 00001fff c01a3b34 c02fdf74 c39cd560 c3adcbd8 c0157d34
[425375.810000] 5f20: 00001fff c389a0a8 c39cd560 c00cdc08 c39cd560 00000000 c02f1dd4 00019258
[425375.810000] 5f40: 00000000 c32c0640 00019258 c3065f88 00000003 00001fff c3064000 00000000
[425375.810000] 5f60: be992bc4 c008bb0c 00000000 c32c0640 00000000 00000000 c32c0640 00000003
[425375.810000] 5f80: c0026048 c008befc 00000000 00000000 00017410 00000001 be992a9c 00001fff
[425375.810000] 5fa0: 00019258 c0025ea0 be992a9c 00001fff 00000007 00019258 00001fff fbad2488
[425375.810000] 5fc0: be992a9c 00001fff 00019258 00000003 be992a9c 00000f30 4013a000 be992bc4
[425375.810000] 5fe0: 00000000 be992980 40068aa0 40069084 80000010 00000007 00000000 00000000
[425375.810000] [<c017b188>] (atmel_spi_interrupt+0x64/0x218) from [<c0061f34>] (handle_IRQ_event+0x40/0x10c)
[425375.810000] [<c0061f34>] (handle_IRQ_event+0x40/0x10c) from [<c0064630>] (handle_level_irq+0xa0/0x168)
[425375.810000] [<c0064630>] (handle_level_irq+0xa0/0x168) from [<c002506c>] (asm_do_IRQ+0x6c/0x98)
[425375.810000] [<c002506c>] (asm_do_IRQ+0x6c/0x98) from [<c0025aa8>] (__irq_svc+0x48/0x8c)
[425375.810000] Exception stack(0xc3065dd0 to 0xc3065e18)
[425375.810000] 5dc0: 7fffffff c3065ed0 c38603e0 00000000
[425375.810000] 5de0: 00000000 00000000 7fffffff c3064018 c3065ecc c3258c08 00000002 c3065e4c
[425375.810000] 5e00: c3065e50 c3065e18 c02317a8 c0230e18 60000013 ffffffff
[425375.810000] [<c0025aa8>] (__irq_svc+0x48/0x8c) from [<c0230e18>] (schedule+0x14/0x370)
[425375.810000] [<c0230e18>] (schedule+0x14/0x370) from [<c02317a8>] (schedule_timeout+0x18/0x1c4)
[425375.810000] [<c02317a8>] (schedule_timeout+0x18/0x1c4) from [<c023155c>] (wait_for_common+0x100/0x1cc)
[425375.810000] [<c023155c>] (wait_for_common+0x100/0x1cc) from [<c017a124>] (spi_sync+0x44/0x58)
[425375.810000] [<c017a124>] (spi_sync+0x44/0x58) from [<c01a3a5c>] (ads7846_read12_ser+0x160/0x1b8)
[425375.810000] [<c01a3a5c>] (ads7846_read12_ser+0x160/0x1b8) from [<c01a3b34>] (in0_input_show+0x20/0x48)
[425375.810000] [<c01a3b34>] (in0_input_show+0x20/0x48) from [<c0157d34>] (dev_attr_show+0x24/0x4c)
[425375.810000] [<c0157d34>] (dev_attr_show+0x24/0x4c) from [<c00cdc08>] (sysfs_read_file+0xb4/0x130)
[425375.810000] [<c00cdc08>] (sysfs_read_file+0xb4/0x130) from [<c008bb0c>] (vfs_read+0xac/0x158)
[425375.810000] [<c008bb0c>] (vfs_read+0xac/0x158) from [<c008befc>] (sys_read+0x3c/0x68)
[425375.810000] [<c008befc>] (sys_read+0x3c/0x68) from [<c0025ea0>] (ret_fast_syscall+0x0/0x28)
[425375.810000] Code: e5813018 e5902000 e59f31a4 e5823120 (e1d501b6)
[425376.240000] ---[ end trace 5f66d043b00bc2c9 ]---
[425376.250000] Kernel panic - not syncing: Fatal exception in interrupt


Have anyone experienced similar problem or can help me in the right direction to fix this issue?

Please let me know if I should attach more information.

Best regards,
Niclas


Top
 Profile  
 
 Post subject: Re: AT91SAM9263ek SPI problem
PostPosted: Tue Mar 08, 2011 2:54 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Check what it's doing in atmel_spi_interrupt() about 18-20% into the code.

I suspect you'll find it's accessing a structure who's pointer is a NULL. Add a sanity check for the pointer, and try to figure out why it would be zero.


Top
 Profile  
 
 Post subject: Re: AT91SAM9263ek SPI problem
PostPosted: Tue Mar 08, 2011 6:52 pm 
Offline

Joined: Tue Mar 08, 2011 10:58 am
Posts: 3
Update:
The pointer which is NULL and causing the kernel to crash is xfer in atmel_spi_interrupt(). This is the same pointer as as->current_transfer.

The crash occur when derefering at line 459:

/* REVISIT: udelay in irq is unfriendly */
if (xfer->delay_usecs)
udelay(xfer->delay_usecs);

To get to this part of the code a SPI overrun must have taken place.

Havn't found out why as->current_transfer is NULL.


Top
 Profile  
 
 Post subject: Re: AT91SAM9263ek SPI problem
PostPosted: Tue Apr 12, 2011 5:27 pm 
Offline

Joined: Tue Mar 08, 2011 10:58 am
Posts: 3
Regarding all the zeros I get when reading the in0_input and in1_input, e.g. cat /sys/bus/spi/devices/spi0.1/in0_input
In the driver for the touchscreen ADC (ads7846.c), function ads7846_read12_ser(...) is called when doing cat on the sysfs file. It seems like status = spi_sync(spi, &req->msg); returns before the PDC has moved data from the SPI to the supplied &req->sample. Hence the sample is zero. If I add a printk() or a small delay after the call to spi_sync() the value is read correct (the PDC get som extra time to get the data to the req->sample buffer). Any hints how to fix this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: