免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3967 | 回复: 4
打印 上一主题 下一主题

[驱动] 各位大侠,at91sam9260的SPI调试时出现问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-08-13 15:11 |只看该作者 |倒序浏览
本帖最后由 kinfirge 于 2013-08-13 15:12 编辑

各位大侠,本人在at91sam9260调试系统自带SPI出现问题,内核版本2.6.24
由于要用到SPI,考虑到IO模拟SPI速率慢且占CPU资源,打算用自带的SPI驱动,make menuconfig,已经把SPI相关勾选上了,且将内核目录arch/arm/mach-at91/board-sam9260ek.c的static struct spi_board_info ek_spi_devices[] = 也已经修改。

但在驱动中调用 spi_sync()时,出现问题,具体跟进去,发现出错在
void dma_cache_maint(const void *start, size_t size, int direction)
{
        BUG_ON(!virt_addr_valid(start) || !virt_addr_valid(end - 1));   就出错在就这行代码
}

求做过SPI的大神指点,小弟先谢过。

具体错误打印如下:

kernel BUG at arch/arm/mm/consistent.c:487!
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c1d70000
[00000000] *pgd=21c3b031, *pte=00000000, *ppte=00000000
Internal error: Oops: 817 [#1]
Modules linked in: spi_esam wdt
CPU: 0    Not tainted  (2.6.24 #251)
PC is at __bug+0x24/0x30
LR is at release_console_sem+0x1cc/0x1e8
pc : [<c0028d74>]    lr : [<c0039a48>]    psr: 60000013
sp : c1d6fe58  ip : c1d6fd98  fp : c1d6fe64
r10: 00000008  r9 : 00000000  r8 : 00011008
r7 : c1d03200  r6 : 00000001  r5 : 00000008  r4 : 00011008
r3 : 00000000  r2 : c02bff98  r1 : 000073ad  r0 : 0000002f
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 0005317f  Table: 21d70000  DAC: 00000015
Process esam_main (pid: 350, stack limit = 0xc1d6e26
Stack: (0xc1d6fe58 to 0xc1d70000)
fe40:                                                       c1d6fe84 c1d6fe68
fe60: c002a88c c0028d60 c02bff5c c1d6ff04 c1d6fed8 c1d03518 c1d6feac c1d6fe88
fe80: c01835b4 c002a810 c1d6fed8 c1d6feb4 00000008 c1d6ff20 00000000 00000000
fea0: c1d6fed4 c1d6feb0 c01828e8 c01834f4 c004ff78 00000000 c1d6feb8 c1d6feb8
fec0: bf002e00 c1d6fed8 c1d6ff44 c1d6fed8 bf002178 c01828b0 c1d6ff20 c1d6ff20
fee0: c1d03200 00000000 c0182a6c c1d6feb4 00000000 00000000 00000000 00000000
ff00: 00000000 00011008 00000000 00000008 ffffffff ffffffff 00000000 00000000
ff20: c1d6fed8 c1d6fed8 00000008 c1c29620 00011008 c1d6ff70 c1d6ff6c c1d6ff48
ff40: c007eff0 bf002104 00000000 00000200 c1c29620 00011008 00000008 00000004
ff60: c1d6ffa4 c1d6ff70 c007f134 c007ef44 00000000 00000000 c002b4fc 00000000
ff80: 60000010 000000e4 00000140 401a0000 c0024f68 c1d6e000 00000000 c1d6ffa8
ffa0: c0024dc0 c007f100 000000e4 00000140 00000003 00011008 00000008 00011008
ffc0: 000000e4 00000140 401a0000 00000004 00000000 00000000 00008790 bea4ed4c
ffe0: 401a1b68 bea4ed28 000088f8 4003701c 60000010 00000003 00000000 00000000
Backtrace:
[<c0028d50>] (__bug+0x0/0x30) from [<c002a88c>] (dma_cache_maint+0x8c/0xdc)
[<c002a800>] (dma_cache_maint+0x0/0xdc) from [<c01835b4>] (atmel_spi_transfer+0xd0/0x1ec)
r6:c1d03518 r5:c1d6fed8 r4:c1d6ff04 r3:c02bff5c
[<c01834e4>] (atmel_spi_transfer+0x0/0x1ec) from [<c01828e8>] (spi_sync+0x48/0x70)
[<c01828a0>] (spi_sync+0x0/0x70) from [<bf002178>] (esam_write+0x84/0xe4 [spi_esam])
r5:c1d6fed8 r4:bf002e00
[<bf0020f4>] (esam_write+0x0/0xe4 [spi_esam]) from [<c007eff0>] (vfs_write+0xbc/0x13
r7:c1d6ff70 r6:00011008 r5:c1c29620 r4:00000008
[<c007ef34>] (vfs_write+0x0/0x13 from [<c007f134>] (sys_write+0x44/0x70)
r7:00000004 r6:00000008 r5:00011008 r4:c1c29620
[<c007f0f0>] (sys_write+0x0/0x70) from [<c0024dc0>] (ret_fast_syscall+0x0/0x2c)
r9:c1d6e000 r8:c0024f68 r6:401a0000 r5:00000140 r4:000000e4
Code: e59f0010 e1a01003 eb09f737 e3a03000 (e5833000)
---[ end trace f40c5ded0f9921f6 ]---
Segmentation fault

论坛徽章:
0
2 [报告]
发表于 2013-08-13 16:05 |只看该作者
LZ是如何跟进去调试的?
LZ是用SPI的DMA方式、中断方式还是轮询方式。
看似像虚拟地址跟物理地址转换的问题。

论坛徽章:
0
3 [报告]
发表于 2013-08-13 16:13 |只看该作者
本帖最后由 kinfirge 于 2013-08-13 16:20 编辑

看了下atmel_spi.c,用的是SPI的DMA方式。
通过在各级函数调用都printk,发现执行到我标的那一行,没有执行下去,打印出一大堆错误信息。
驱动调用spi_sync或spi_write之后,接下去调用的层级函数关系是atmel_spi_transfer()——》atmel_spi_dma_map_xfer()——》dma_map_single()——》dma_cache_maint()
在执行到dma_cache_maint()函数里的BUG_ON(!virt_addr_valid(start) || !virt_addr_valid(end - 1));这行代码,出错!
通过google搜了一下,http://permalink.gmane.org/gmane.linux.ports.arm.general/10903,有人通过给mtdblock.c加几行补丁,如下

+#ifdef CONFIG_BSE_TWEAKS // BSE fix for dataflash/spi DMA mapping
+               mtdblk->cache_data = kmalloc(mtdblk->mtd->erasesize, GFP_KERNEL);
+#else
                mtdblk->cache_data = vmalloc(mtdblk->mtd->erasesize);
+#endif

但这个参数CONFIG_BSE_TWEAKS,在我的内核以及2.6.25内核都找不到这个配置,不懂了,这个系统SPI怎么那么难弄的,觉得不应该啊


回复 2# 2879618


   

论坛徽章:
0
4 [报告]
发表于 2013-08-13 16:50 |只看该作者
我也不太懂
LZ用SPI连接什么设备。

论坛徽章:
0
5 [报告]
发表于 2013-08-14 08:55 |只看该作者
本帖最后由 kinfirge 于 2013-08-14 08:56 编辑

通过SPI和加密芯片通信;


求做过SPI的大神指点???
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP