免费注册 查看新帖 |

Chinaunix

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

[硬件及驱动] 关于dataflash的内核读写问题。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-07-01 20:14 |只看该作者 |倒序浏览
本帖最后由 saiwenth 于 2013-07-01 20:17 编辑

看了几天论坛,这里比较热闹,放在这里看有没有人有建议。感谢大家。

环境是9260ek的板子,spi dataflash 8MB挂在cs0上。dataflash 的page大小是0x420.

在uboot中mtdparts 传参如下:
root=/dev/mtdblock2 mtdparts=spi0.1-ATDB542x:264k(boot)ro,2112k(kernel), -(root) rw rootfstype=cramfs
希望通过uboot的方式将分区传入内核中。

内核在启动的最后输出如下
List of all partitions:
1f00  mtdblock0 driver: mtd_dataflash
1f01 2112 mtdblock1 driver: mtd_dataflash
1f02 6072 mtdblock2 driver: mtd_dataflash
No filesystem could mount root, tired: cramfs
kernel panic - not syncing: VFS: Unable to mount root fs on unkown-block(31,2)

不管是什么格式的分区,只要通过/dev/mtdblock2的方式挂载都挂不了,错误和上面的类似,无法识别分区。已经尝试过cramfs,jffs2,squashfs都不行。
当前,能正常启动的方式有两种:
1.能通过nfs网络启动。
2.mtd2相应的地址里用samba写ext2格式的ramfs,并在uboot里通过cp.b的方式找地址挂载到内核默认的bootline参数地址里是能启动。

使用nfs网络启动后发现通过cat cramfs.bin > /proc/mtd2的方式写入cramfs的文件系统,再次用nfs启动发现,kernel的数据部分被覆盖了,启动失败。
(补充,也不是每次都会覆盖kernel,具有一定的随机性,后续用flash_erase擦出flash时发现也有随机的flash地址没有擦写成0XFF)

nfs网络启动后,运行命令
cat /proc/mtd
dev:   size   erasesize  name
mtd0: 0042000 00000420 "boot"
mtd1: 00210000 00000420 "kernel"
mtd2: 00533000 00000420 "root"

在网络文件系统中执行mtd_debug命令:

  1. mtd_debug info /dev/mtdblock0
  2. mtdblock_open

  3. MTD_NEED_ERASE, cache_size:1056
  4. ok
  5. MEMGEmtdblock_release
  6. Tok
  7. INFO: Inappropriate ioctl for device
  8. # mtd_debug info /dev/mtd0     
  9. MTD_open
  10. MTD_ioctl
  11. MTD_ioctl
  12. mtd.type = MTD_DATAFLASH
  13. MTD_close
  14. mtd.flags = MTD_CAP_ROM
  15. mtd.size = 270336 (264K)
  16. mtd.erasesize = 1056 (1K)
  17. mtd.writesize = 1056 (1K)
  18. mtd.oobsize = 0
  19. regions = 0
  20. #mtd_debug read /dev/mtdblock0 0 0x1000 a
  21. mtdblock_open

  22. MTD_NEED_ERASE, cache_size:1056
  23. ok
  24. mtdblock: read on "boot" at 0x0, size 0x200
  25. spi0.1: read 0x0..0x200
  26. READ: (0) 0 0 0
  27. mtdblock: read on "boot" at 0x200, size 0x200
  28. spi0.1: read 0x200..0x400
  29. READ: (e8) 0 0 0
  30. mtdblock: read on "boot" at 0x400, size 0x200
  31. spi0.1: read 0x400..0x420
  32. READ: (e8) 0 2 0
  33. spi0.1: read 0x420..0x600
  34. READ: (e8) 0 4 0
  35. mtdblock: read on "boot" at 0x600, size 0x200
  36. spi0.1: read 0x600..0x800
  37. READ: (e8) 0 8 0
  38. mtdblock: read on "boot" at 0x800, size 0x200
  39. spi0.1: read 0x800..0x840
  40. READ: (e8) 0 9 e0
  41. spi0.1: read 0x840..0xa00
  42. READ: (e8) 0 b e0
  43. mtdblock: read on "boot" at 0xa00, size 0x200
  44. spi0.1: read 0xa00..0xc00
  45. READ: (e8) 0 10 0
  46. mtdblock: read on "boot" at 0xc00, size 0x200
  47. spi0.1: read 0xc00..0xc60
  48. READ: (e8) 0 11 c0
  49. spi0.1: read 0xc60..0xe00
  50. READ: (e8) 0 13 c0
  51. mtdblock: read on "boot" at 0xe00, size 0x200
  52. spi0.1: read 0xe00..0x1000
  53. READ: (e8) 0 18 0
  54. mtdblock: read on "boot" at 0x1000, size 0x200
  55. spi0.1: read 0x1000..0x1080
  56. READ: (e8) 0 19 a0
  57. Copiedspi0.1: read 0x1080..0x1200
  58. READ: (e8) 0 1b a0
  59. 4096 mtdblock: read on "boot" at 0x1200, size 0x200
  60. byspi0.1: read 0x1200..0x1400
  61. tREAD: (e8) 0 20 0
  62. es fromtdblock: read on "boot" at 0x1400, size 0x200
  63. m spi0.1: read 0x1400..0x14a0
  64. aREAD: (e8) 0 21 80
  65. ddrspi0.1: read 0x14a0..0x1600
  66. eREAD: (e8) 0 23 80
  67. ss 0xmtdblock: read on "boot" at 0x1600, size 0x200
  68. 00spi0.1: read 0x1600..0x1800
  69. 0READ: (e8) 0 28 0
  70. 00000 mtdblock: read on "boot" at 0x1800, size 0x200
  71. inspi0.1: read 0x1800..0x18c0
  72. READ: (e8) 0 29 60
  73. flaspi0.1: read 0x18c0..0x1a00
  74. sREAD: (e8) 0 2b 60
  75. h tomtdblock: read on "boot" at 0x1a00, size 0x200
  76. spi0.1: read 0x1a00..0x1c00
  77. READ: (e8) 0 30 0
  78. a
  79. mtdblock: read on "boot" at 0x1c00, size 0x200
  80. spi0.1: read 0x1c00..0x1ce0
  81. READ: (e8) 0 31 40
  82. spi0.1: read 0x1ce0..0x1e00
  83. READ: (e8) 0 33 40
  84. mtdblock: read on "boot" at 0x1e00, size 0x200
  85. spi0.1: read 0x1e00..0x2000
  86. READ: (e8) 0 38 0
  87. mtdblock: read on "boot" at 0x2000, size 0x200
  88. spi0.1: read 0x2000..0x2100
  89. READ: (e8) 0 39 20
  90. spi0.1: read 0x2100..0x2200
  91. READ: (e8) 0 3b 20
  92. mtdblock: read on "boot" at 0x2200, size 0x200
  93. spi0.1: read 0x2200..0x2400
  94. READ: (e8) 0 40 0
  95. mtdblock: read on "boot" at 0x2400, size 0x200
  96. spi0.1: read 0x2400..0x2520
  97. READ: (e8) 0 41 0
  98. spi0.1: read 0x2520..0x2600
  99. READ: (e8) 0 43 0
  100. mtdblock: read on "boot" at 0x2600, size 0x200
  101. spi0.1: read 0x2600..0x2800
  102. READ: (e8) 0 48 0
  103. mtdblock: read on "boot" at 0x2800, size 0x200
  104. spi0.1: read 0x2800..0x2940
  105. READ: (e8) 0 48 e0
  106. spi0.1: read 0x2940..0x2a00
  107. READ: (e8) 0 4a e0
  108. mtdblock: read on "boot" at 0x2a00, size 0x200
  109. spi0.1: read 0x2a00..0x2c00
  110. READ: (e8) 0 50 0
  111. mtdblock: read on "boot" at 0x2c00, size 0x200
  112. spi0.1: read 0x2c00..0x2d60
  113. READ: (e8) 0 50 c0
  114. spi0.1: read 0x2d60..0x2e00
  115. READ: (e8) 0 52 c0
  116. mtdblock: read on "boot" at 0x2e00, size 0x200
  117. spi0.1: read 0x2e00..0x3000
  118. READ: (e8) 0 58 0
  119. mtdblock: read on "boot" at 0x3000, size 0x200
  120. spi0.1: read 0x3000..0x3180
  121. READ: (e8) 0 58 a0
  122. spi0.1: read 0x3180..0x3200
  123. READ: (e8) 0 5a a0
  124. mtdblock: read on "boot" at 0x3200, size 0x200
  125. spi0.1: read 0x3200..0x3400
  126. READ: (e8) 0 60 0
  127. mtdblock: read on "boot" at 0x3400, size 0x200
  128. spi0.1: read 0x3400..0x35a0
  129. READ: (e8) 0 60 80
  130. spi0.1: read 0x35a0..0x3600
  131. READ: (e8) 0 62 80
  132. mtdblock: read on "boot" at 0x3600, size 0x200
  133. spi0.1: read 0x3600..0x3800
  134. READ: (e8) 0 68 0
  135. mtdblock: read on "boot" at 0x3800, size 0x200
  136. spi0.1: read 0x3800..0x39c0
  137. READ: (e8) 0 68 60
  138. spi0.1: read 0x39c0..0x3a00
  139. READ: (e8) 0 6a 60
  140. mtdblock: read on "boot" at 0x3a00, size 0x200
  141. spi0.1: read 0x3a00..0x3c00
  142. READ: (e8) 0 70 0
  143. mtdblock: read on "boot" at 0x3c00, size 0x200
  144. spi0.1: read 0x3c00..0x3de0
  145. READ: (e8) 0 70 40
  146. spi0.1: read 0x3de0..0x3e00
  147. READ: (e8) 0 72 40
  148. mtdblock: read on "boot" at 0x3e00, size 0x200
  149. spi0.1: read 0x3e00..0x4000
  150. READ: (e8) 0 78 0
  151. mtdblock_release
  152. ok
  153. # hexdump -C a
  154. 00000000  0d 00 00 ea 05 00 00 ea  05 00 00 00 00 00 00 00  |................|
  155. 00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  156. *
  157. 00000200  0e 3f 48 10 24 00 00 00  00 00 00 00 00 00 00 00  |.?H.$...........|
  158. 00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  159. *
  160. 00000400  00 3c 00 e5 01 80 88 e2  14 50 85 e2 00 30 95 e5  |.<.......P...0..|
  161. 00000410  00 00 53 e3 a1 ff ff 1a  08 00 a0 e1 f0 81 bd e8  |..S.............|
  162. 00000420  00 00 a0 e3 f0 81 bd e8  30 40 2d e9 01 40 a0 e1  |........0@-..@..|
  163. 00000430  00 50 a0 e1 84 ff ff eb  00 30 e0 e3 5f 00 50 e3  |.P.......0.._.P.|
  164. 00000440  08 00 00 8a 1f 20 05 e2  01 30 a0 ff ff ff ff ff  |..... ...0......|
  165. 00000450  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  166. *
  167. 00000600  01 30 83 e2 00 30 8d ff  ff ff ff ff ff ff ff ff  |.0...0..........|
  168. 00000610  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  169. *
  170. 00000800  00 60 a0 e1 08 d0 4d ff  ff ff ff ff ff ff ff ff  |.`....M.........|
  171. 00000810  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  172. *
  173. 00000840  1c 30 9f e5 03 00 55 e1  01 50 85 e2 ee ff ff 1a  |.0....U..P......|
  174. 00000850  04 00 a0 e1 00 00 00 ea  01 00 a0 e3 08 d0 8d e2  |................|
  175. 00000860  70 80 bd e8 80 96 98 00  f0 4f 2d e9 00 c0 a0 e3  |p........O-.....|
  176. 00000870  8b df 4d e2 00 40 a0 e1  01 90 a0 e1 00 00 00 00  |..M..@..........|
  177. 00000880  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  178. *
  179. 00000a00  05 00 a0 e1 ee ff ff 1a  00 00 00 00 00 00 00 00  |................|
  180. 00000a10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  181. *
  182. 00000c00  a2 2f a0 e1 00 00 00 00  00 00 00 00 00 00 00 00  |./..............|
  183. 00000c10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  184. *
  185. 00000c60  0a 00 00 2a 01 00 00 ea  01 30 50 e5 01 30 41 e5  |...*.....0P..0A.|
  186. 00000c70  01 20 42 e2 01 00 72 e3  01 00 80 e2 01 10 81 e2  |. B...r.........|
  187. 00000c80  f8 ff ff 1a 1e ff 2f e1  00 30 dc e7 01 30 cc ff  |....../..0...0..|
  188. 00000c90  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  189. *
  190. 00001000
  191. #mtd_debug read /dev/mtdblock0 0 0x1000 a
  192. # hexdump -C a
  193. 00000000  00 00 00 00 00 00 63 ff  ff ff ff ff ff ff ff ff  |......c.........|
  194. 00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  195. *
  196. 00000200  0e 3f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |.?..............|
  197. 00000210  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  198. *
  199. 00000400  00 3c 00 e5 01 80 88 e2  14 50 85 e2 00 30 95 e5  |.<.......P...0..|
  200. 00000410  00 00 53 e3 a1 ff ff ff  ff ff ff ff ff ff ff ff  |..S.............|
  201. 00000420  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  202. *
  203. 00000600  01 30 83 e2 00 30 8d e5  00 20 9d e5 94 30 9f e5  |.0...0... ...0..|
  204. 00000610  03 00 52 e1 f8 ff ff ff  ff ff ff ff ff ff ff ff  |..R.............|
  205. 00000620  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  206. *
  207. 00000800  00 60 a0 e1 08 ff ff ff  ff ff ff ff ff ff ff ff  |.`..............|
  208. 00000810  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  209. *
  210. 00000840  1c 30 9f e5 03 00 55 e1  01 50 85 e2 ee ff ff 1a  |.0....U..P......|
  211. 00000850  04 00 a0 ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  212. 00000860  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  213. *
  214. 00000a00  05 00 a0 e1 ee ff ff 1a  7b ff ff ff ff ff ff ff  |........{.......|
  215. 00000a10  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
  216. *
  217. 00000c00  a2 2f a0 e1 00 00 00 00  00 00 00 00 00 00 00 00  |./..............|
  218. 00000c10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  219. *
  220. 00000c60  0a 00 00 2a 01 00 00 ea  00 00 00 00 00 00 00 00  |...*............|
  221. 00000c70  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
  222. *
  223. 00001000
复制代码
也就是说每次读取dataflash的数据都不相同。上述本来是读取flash中的bootstrap二进制的。正常数据见附件。
连续两次读写的、和正常bootstrap的数据见压缩包。 bin.zip (2.55 KB, 下载次数: 1)
有谁碰到过这样的问题吗?或者分享一个思路。
感谢。


论坛徽章:
0
2 [报告]
发表于 2013-07-01 20:22 |只看该作者
本帖最后由 saiwenth 于 2013-07-01 20:23 编辑

initramfs启动时的串口输出:
  1. Starting kernel ...

  2. Uncompressing Linux.................................................................................................................................................................................................................................................................... done, booting the kernel.
  3. Linux version 2.6.32.61 (root@localhost) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) ) #23 Fri Jun 28 16:20:50 CST 2013
  4. CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
  5. CPU: VIVT data cache, VIVT instruction cache
  6. Machine: Atmel AT91SAM9260-EK
  7. Memory policy: ECC disabled, Data cache writeback
  8. Clocks: CPU 198 MHz, master 99 MHz, main 18.432 MHz
  9. Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
  10. Kernel command line: console=ttyS0,115200 mtdparts=spi0.1-AT45DB642x:264k(boot)ro,2112k(kernel),-(root) rw
  11. PID hash table entries: 256 (order: -2, 1024 bytes)
  12. Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
  13. Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
  14. Memory: 64MB = 64MB total
  15. Memory: 56544KB available (2744K code, 258K data, 5316K init, 0K highmem)
  16. Hierarchical RCU implementation.
  17. NR_IRQS:192
  18. AT91: 96 gpio irqs in 3 banks
  19. Console: colour dummy device 80x30
  20. console [ttyS0] enabled
  21. Calibrating delay loop... 98.91 BogoMIPS (lpj=494592)
  22. Mount-cache hash table entries: 512
  23. CPU: Testing write buffer coherency: ok
  24. NET: Registered protocol family 16
  25. AT91: Power Management
  26. AT91: Starting after software reset
  27. bio: create slab <bio-0> at 0
  28. SCSI subsystem initialized
  29. usbcore: registered new interface driver usbfs
  30. usbcore: registered new interface driver hub
  31. usbcore: registered new device driver usb
  32. Switching to clocksource tcb_clksrc
  33. Slow work thread pool: Starting up
  34. Slow work thread pool: Ready
  35. FS-Cache: Loaded
  36. NET: Registered protocol family 2
  37. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
  38. TCP established hash table entries: 2048 (order: 2, 16384 bytes)
  39. TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
  40. TCP: Hash tables configured (established 2048 bind 2048)
  41. TCP reno registered
  42. NET: Registered protocol family 1
  43. RPC: Registered udp transport module.
  44. RPC: Registered tcp transport module.
  45. RPC: Registered tcp NFSv4.1 backchannel transport module.
  46. NetWinder Floating Point Emulator V0.97 (double precision)
  47. squashfs: version 4.0 (2009/01/31) Phillip Lougher
  48. JFFS2 version 2.2. (NAND) (SUMMARY)  漏 2001-2006 Red Hat, Inc.
  49. msgmni has been set to 110
  50. alg: No test for stdrng (krng)
  51. io scheduler noop registered
  52. io scheduler anticipatory registered (default)
  53. atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
  54. atmel_usart.1: ttyS1 at MMIO 0xfffb0000 (irq = 6) is a ATMEL_SERIAL
  55. atmel_usart.2: ttyS2 at MMIO 0xfffb4000 (irq = 7) is a ATMEL_SERIAL
  56. brd: module loaded
  57. loop: module loaded
  58. slram: not enough parameters.
  59. atmel_spi atmel_spi.0: Atmel SPI Controller at 0xfffc8000 (irq 12)
  60. spi0.1: OTP, sector protect
  61. mtd_dataflash spi0.1: AT45DB642x (8448 KBytes) pagesize 1056 bytes (OTP)
  62. 3 cmdlinepart partitions found on MTD device spi0.1-AT45DB642x
  63. Creating 3 MTD partitions on "spi0.1-AT45DB642x":
  64. 0x000000000000-0x000000042000 : "boot"
  65. mtd: Giving out device 0 to boot
  66. 0x000000042000-0x000000252000 : "kernel"
  67. mtd: Giving out device 1 to kernel
  68. 0x000000252000-0x000000840000 : "root"
  69. mtd: Giving out device 2 to root
  70. MACB_mii_bus: probed
  71. eth0: Atmel MACB at 0xfffc4000 irq 21 (00:01:00:01:00:01)
  72. eth0: attached PHY driver [Davicom DM9161A] (mii_bus:phy_addr=ffffffff:00, irq=-1)
  73. ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  74. at91_ohci at91_ohci: AT91 OHCI
  75. at91_ohci at91_ohci: new USB bus registered, assigned bus number 1
  76. at91_ohci at91_ohci: irq 20, io mem 0x00500000
  77. usb usb1: configuration #1 chosen from 1 choice
  78. hub 1-0:1.0: USB hub found
  79. hub 1-0:1.0: 2 ports detected
  80. Initializing USB Mass Storage driver...
  81. usbcore: registered new interface driver usb-storage
  82. USB Mass Storage support registered.
  83. usbcore: registered new interface driver usbserial
  84. usbserial: USB Serial Driver core
  85. udc: at91_udc version 3 May 2006
  86. mice: PS/2 mouse device common for all mice
  87. rtc-at91sam9 at91_rtt.0: rtc core: registered at91_rtt as rtc0
  88. IRQ 1/rtc0: IRQF_DISABLED is not guaranteed on shared IRQs
  89. rtc-at91sam9 at91_rtt.0: rtc0: SET TIME!
  90. TCP cubic registered
  91. NET: Registered protocol family 17
  92. rtc-at91sam9 at91_rtt.0: hctosys: unable to read the hardware clock
  93. Freeing init memory: 5316K
复制代码
对比uboot而言,可见,dataflash在硬件上是可以正常工作的。
哦,现在的内核是2.6.32.61,是linux内核的那个长期支持版本。
用过2.6.30 atmel官方的patch,问题还是这样。

原帖见:http://bbs.chinaunix.net/thread-4087465-1-1.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP