Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14405
  • 博文数量: 5
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: -10
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-25 13:15
文章分类
文章存档

2015年(5)

我的朋友

分类: LINUX

2015-05-15 22:16:56

今晚根据《Mini2440_Linux移植开发实战指南》一文进行nandflash驱动
的移植出现了不少问题。不知道是我操作失误还是该文编写出现错漏导致的。
    第一步,在linux源代码目录下修改Makefile,第183和184行
  
 
 
   第二步,执行make s3c2410_defconfig,使用缺省内核配置文件,s3c2410_defconfig 是SMDK2440 的
缺省配置文件。
   第三步,将/opt/FriendlyARM/mini2440/linux-2.6.32.27/arch/arm/mach-s3c2440
目录下的mach-mini2440.c文件删除,将mach-smdk2440.c复制一份到mach-mini2440.c,直接执行命令cp mach-smdk2440.c mach-mini2440.c.
   第四步,在176行,修改MACHINE_START(MINI2440, "FriendlyARM Mini2440 board for Liupeng 2011-10-22")
开发板运行后,在命令行终端输入:cat /proc/cpuinfo 可以看到我们添加的开发板信息,别的估计没什么用。
   第五步,在163行修改开发板时钟频率为12M,在173行,把此函数屏蔽掉。
   第六步,可以使用批处理命令修改,在vim 的命令模式下输入:
             %s/smdk2440/mini2440/g
          上面这句的意思是:把所有和“smdk2440”匹配的字符串全部替换为“mini2440”,前
           面的“%s“代表字符串匹配,最后的“g”代表global,是全局的意思。
  到此,内核移植就搞定了。接下来是移植Nand驱动。
    首先按照步骤修改相关信息之后执行make zImage出现了不少错误,找了好多资料才弄好,但是为什么那么弄不知道原因。
    1、增加头文件:
   
  1. #include <linux/mtd/mtd.h>
  2.  #include <linux/mtd/nand.h>
  3.  #include <linux/mtd/nand_ecc.h>
  4.  #include <linux/mtd/partitions.h>
  5.  #include <plat/nand.h>
    2、增加文档中说的三个结构:
   
  1. static struct mtd_partition mini2440_default_nand_part[] = {
  2.     [0] = {
  3.         .name    = "supervivi",
  4.         .size    = 0x00040000,
  5.         .offset    = 0,
  6.     },
  7.     [1] = {
  8.         .name    = "param",
  9.         .offset = 0x00040000,
  10.         .size    = 0x00020000,
  11.     },
  12.     [2] = {
  13.         .name    = "Kernel",
  14.         .offset = 0x00060000,
  15.         .size    = 0x00500000,
  16.     },
  17.     [3] = {
  18.         .name    = "root",
  19.         .offset = 0x00560000,
  20.         .size    = 1024 * 1024 * 1024, //
  21.     },
  22.     [4] = {
  23.         .name    = "nand",
  24.         .offset = 0x00000000,
  25.         .size    = 1024 * 1024 * 1024, //
  26.     }
  27. };
  28. static struct s3c2410_nand_set mini2440_nand_sets[] = {
  29.     [0] = {
  30.         .name        = "NAND",
  31.         .nr_chips    = 1,
  32.         .nr_partitions    = ARRAY_SIZE(mini2440_default_nand_part),
  33.         .partitions    = mini2440_default_nand_part,
  34.     },
  35. };
  36. static struct s3c2410_platform_nand mini2440_nand_info = {
  37.     .tacls        = 20,
  38.     .twrph0        = 60,
  39.     .twrph1        = 20,
  40.     .nr_sets    = ARRAY_SIZE(mini2440_nand_sets),
  41.     .sets        = mini2440_nand_sets,
  42.     .ignore_unset_ecc = 1,
  43. };
3、增加这三个结构之后修改如下代码
  1. static struct platform_device *mini2440_devices[] __initdata = {
  2.     &s3c_device_ohci,
  3.     &s3c_device_lcd,
  4.     &s3c_device_wdt,
  5.     &s3c_device_i2c0,
  6.     &s3c_device_iis,
  7.     &s3c_device_nand, //增加部分
  8. };

4、最后在在修改如下结构

 

  1. static void __init mini2440_map_io(void)
  2. {
  3.     s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
  4.     s3c24xx_init_clocks(12000000);
  5.     s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
  6.     s3c_device_nand.dev.platform_data = &mini2440_nand_info; //增加的部分
  7. }

 

最后一编译果然通过了

  1. [root@localhost linux-2.6.35.13]# make zImage
  2.   CHK include/linux/version.h
  3.   CHK include/generated/utsrelease.h
  4. make[1]: “include/generated/mach-types.h”是最新的。
  5.   CALL scripts/checksyscalls.sh
  6.   CHK include/generated/compile.h
  7.   CC arch/arm/mach-s3c2440/mach-mini2440.o
  8.   LD arch/arm/mach-s3c2440/built-in.o
  9.   LD vmlinux.o
  10.   MODPOST vmlinux.o
  11. WARNING: modpost: Found 3 section mismatch(es).
  12. To see full details build your kernel with:
  13. 'make CONFIG_DEBUG_SECTION_MISMATCH=y'
  14.   GEN .version
  15.   CHK include/generated/compile.h
  16.   UPD include/generated/compile.h
  17.   CC init/version.o
  18.   LD init/built-in.o
  19.   LD .tmp_vmlinux1
  20.   KSYM .tmp_kallsyms1.S
  21.   AS .tmp_kallsyms1.o
  22.   LD .tmp_vmlinux2
  23.   KSYM .tmp_kallsyms2.S
  24.   AS .tmp_kallsyms2.o
  25.   LD vmlinux
  26.   SYSMAP System.map
  27.   SYSMAP .tmp_System.map
  28.   OBJCOPY arch/arm/boot/Image
  29.   Kernel: arch/arm/boot/Image is ready
  30.   GZIP arch/arm/boot/compressed/piggy.gzip
  31.   AS arch/arm/boot/compressed/piggy.gzip.o
  32.   SHIPPED arch/arm/boot/compressed/lib1funcs.S
  33.   AS arch/arm/boot/compressed/lib1funcs.o
  34.   LD arch/arm/boot/compressed/vmlinux
  35.   OBJCOPY arch/arm/boot/zImage
  36.   Kernel: arch/arm/boot/zImage is ready

之后将编译好的内核下载到开发板运行

 

  1. ##### FriendlyARM BIOS 2.0 for 2440 #####
  2. [x] format NAND FLASH for Linux
  3. [v] Download vivi
  4. [k] Download linux kernel
  5. [y] Download root_yaffs image
  6. [a] Absolute User Application
  7. [n] Download Nboot for WinCE
  8. [l] Download WinCE boot-logo
  9. [w] Download WinCE NK.bin
  10. [d] Download & Run
  11. [z] Download zImage into RAM
  12. [g] Boot linux from RAM
  13. [f] Format the nand flash
  14. [b] Boot the system
  15. [s] Set the boot parameters
  16. [u] Backup NAND Flash to HOST through USB(upload)
  17. [r] Restore NAND Flash from HOST through USB
  18. [q] Goto shell of vivi
  19. [i] Version: 0945-2K
  20. Enter your selection: b
  21. Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00500000 ... done
  22. zImage magic = 0x016f2818
  23. Setup linux parameters at 0x30000100
  24. linux command line is: "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0"
  25. MACH_TYPE = 1999
  26. NOW, Booting Linux......
  27. Uncompressing Linux... done, booting the kernel.
  28. Linux version 2.6.35.13 (root@localhost.localdomain) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #4 Fri Oct 14 23:28:12 CST 2011
  29. CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
  30. CPU: VIVT data cache, VIVT instruction cache
  31. Machine: FriendlyARM Mini2440 development board for LiuPeng
  32. ATAG_INITRD is deprecated; please update your bootloader.
  33. Memory policy: ECC disabled, Data cache writeback
  34. CPU S3C2440A (id 0x32440001)
  35. S3C24XX Clocks, Copyright 2004 Simtec Electronics
  36. S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
  37. CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
  38. Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
  39. Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0
  40. PID hash table entries: 256 (order: -2, 1024 bytes)
  41. Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
  42. Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
  43. Memory: 64MB = 64MB total
  44. Memory: 60532k/60532k available, 5004k reserved, 0K highmem
  45. Virtual kernel memory layout:
  46.     vector : 0xffff0000 - 0xffff1000 ( 4 kB)
  47.     fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
  48.     DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
  49.     vmalloc : 0xc4800000 - 0xe0000000 ( 440 MB)
  50.     lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
  51.     modules : 0xbf000000 - 0xc0000000 ( 16 MB)
  52.       .init : 0xc0008000 - 0xc0029000 ( 132 kB)
  53.       .text : 0xc0029000 - 0xc03c9000 (3712 kB)
  54.       .data : 0xc03e8000 - 0xc0411080 ( 165 kB)
  55. SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
  56. Hierarchical RCU implementation.
  57.     RCU-based detection of stalled CPUs is disabled.
  58.     Verbose stalled-CPUs detection is disabled.
  59. NR_IRQS:85
  60. irq: clearing subpending status 00000003
  61. irq: clearing subpending status 00000002
  62. Console: colour dummy device 80x30
  63. console [ttySAC0] enabled
  64. Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
  65. pid_max: default: 32768 minimum: 301
  66. Mount-cache hash table entries: 512
  67. CPU: Testing write buffer coherency: ok
  68. gpiochip_add: gpios 288..303 (GPIOK) failed to register
  69. gpiochip_add: gpios 320..334 (GPIOL) failed to register
  70. gpiochip_add: gpios 352..353 (GPIOM) failed to register
  71. NET: Registered protocol family 16
  72. S3C2440: Initialising architecture
  73. S3C2440: IRQ Support
  74. S3C24XX DMA Driver, Copyright 2003-2006 Simtec Electronics
  75. DMA channel 0 at c4808000, irq 33
  76. DMA channel 1 at c4808040, irq 34
  77. DMA channel 2 at c4808080, irq 35
  78. DMA channel 3 at c48080c0, irq 36
  79. S3C244X: Clock Support, DVS off
  80. bio: create slab <bio-0> at 0
  81. usbcore: registered new interface driver usbfs
  82. usbcore: registered new interface driver hub
  83. usbcore: registered new device driver usb
  84. s3c-i2c s3c2440-i2c: slave address 0x10
  85. s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
  86. s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
  87. Advanced Linux Sound Architecture Driver Version 1.0.23.
  88. NET: Registered protocol family 2
  89. IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
  90. TCP established hash table entries: 2048 (order: 2, 16384 bytes)
  91. TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
  92. TCP: Hash tables configured (established 2048 bind 2048)
  93. TCP reno registered
  94. UDP hash table entries: 256 (order: 0, 4096 bytes)
  95. UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
  96. NET: Registered protocol family 1
  97. RPC: Registered udp transport module.
  98. RPC: Registered tcp transport module.
  99. RPC: Registered tcp NFSv4.1 backchannel transport module.
  100. JFFS2 version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
  101. ROMFS MTD (C) 2007 Red Hat, Inc.
  102. msgmni has been set to 118
  103. alg: No test for stdrng (krng)
  104. io scheduler noop registered
  105. io scheduler deadline registered
  106. io scheduler cfq registered (default)
  107. Console: switching to colour frame buffer device 60x53
  108. fb0: s3c2410fb frame buffer device
  109. s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
  110. s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
  111. s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
  112. brd: module loaded
  113. S3C24XX NAND Driver, (c) 2004 Simtec Electronics
  114. s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
  115. s3c24xx-nand s3c2440-nand: NAND soft ECC
  116. NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
  117. Scanning device for bad blocks
  118. Bad eraseblock 89 at 0x000000b20000
  119. Bad eraseblock 520 at 0x000004100000
  120. Bad eraseblock 1445 at 0x00000b4a0000
  121. Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
  122. 0x000000000000-0x000000040000 : "supervivi"
  123. uncorrectable error :
  124. 0x000000040000-0x000000060000 : "param"
  125. 0x000000060000-0x000000560000 : "Kernel"
  126. uncorrectable error :
  127. 0x000000560000-0x000040560000 : "root"
  128. mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
  129. ftl_cs: FTL header not found.
  130. 0x000000000000-0x000040000000 : "nand"
  131. mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000
  132. uncorrectable error :
  133. dm9000 Ethernet Driver, V1.31
  134. ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  135. s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
  136. s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
  137. s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
  138. hub 1-0:1.0: USB hub found
  139. hub 1-0:1.0: 2 ports detected
  140. usbcore: registered new interface driver libusual
  141. mice: PS/2 mouse device common for all mice
  142. S3C24XX RTC, (c) 2004,2006 Simtec Electronics
  143. i2c /dev entries driver
  144. S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
  145. s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
  146. cpuidle: using governor ladder
  147. sdhci: Secure Digital Host Controller Interface driver
  148. sdhci: Copyright(c) Pierre Ossman
  149. usbcore: registered new interface driver hiddev
  150. usbcore: registered new interface driver usbhid
  151. usbhid: USB HID core driver
  152. No device for DAI UDA134X
  153. No device for DAI s3c24xx-i2s
  154. ALSA device list:
  155.   No soundcards found.
  156. TCP cubic registered
  157. NET: Registered protocol family 17
  158. drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
  159. List of all partitions:
  160. 1f00 256 mtdblock0 (driver?)
  161. 1f01 128 mtdblock1 (driver?)
  162. 1f02 5120 mtdblock2 (driver?)
  163. 1f03 256640 mtdblock3 (driver?)
  164. 1f04 262144 mtdblock4 (driver?)
  165. No filesystem could mount root, tried: ext3 cramfs vfat msdos romfs
  166. Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
  167. [<c002e574>] (unwind_backtrace+0x0/0xec) from [<c02e75c0>] (panic+0x54/0xe4)
  168. [<c02e75c0>] (panic+0x54/0xe4) from [<c0008ed8>] (mount_block_root+0x1d0/0x210)
  169. [<c0008ed8>] (mount_block_root+0x1d0/0x210) from [<c0009170>] (prepare_namespace+0x164/0x1bc)
  170. [<c0009170>] (prepare_namespace+0x164/0x1bc) from [<c0008470>] (kernel_init+0x10c/0x14c)
  171. [<c0008470>] (kernel_init+0x10c/0x14c) from [<c002a818>] (kernel_thread_exit+0x0/0x8)
这样就能看到移植的Nand的一些信息了,到此内核就移植好了,下一步学习移植yaffs2,还不知道这是个什么东东呢?
阅读(1234) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:编译linux内核模块出错

给主人留下些什么吧!~~