Chinaunix首页 | 论坛 | 博客
  • 博客访问: 119377
  • 博文数量: 24
  • 博客积分: 616
  • 博客等级: 中士
  • 技术积分: 375
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-01 10:54
文章分类
文章存档

2012年(24)

我的朋友

分类: LINUX

2012-04-05 14:18:26

LINUX2.6.32.2已经自带了大部分NANDFLASH的驱动,在linux2.6.32.2/drivers/mtd/nand/nand_ids.c文件中。

1.本人开发板上的NANDFLASH型号为:K9F2G08U0B,如果在网络中搜索它的DATASHEET可以搜索K9F2G08X0B.
 
2.在DATASHEET中查找此芯片的ID号位 0XDA
3.在linux2.6.32.2/drivers/mtd/nand/nand_ids.c寻找是否已经支持了此型号nandflash,经过查找发现,目前的LINUX内核已经支持了此型号nandflash,下图就是在此文件中找到的相关代码。
 
     通过上图可发现NAND 256Mib 3.3v 8-bit 就是适合本人开发板NANDFLASH的相关程序

4.修改nandflash分区表
   修改LINUX内核下的arch/arm/s3c2440/mach-mini2440.c文件添加如下代码
 
 
以上代表五个分区,其中最后一个实际上市涵盖了整个NANDFLASH。其他四个分区作用如下:
    (1)boot区,用来存放U-boot或者SUPERVIVI等启动代码
     (2)启动代码参数区,也可以用来弥补由于某些启动代码过大而造成存储启动代码的区域空间不够用的缺陷,这样不会使U-BOOT代码存储到LINUX内核代码区域
      (3)存放内核代码
      (4)文件系统分区


5.将nandflash设备注册到系统中
6.按照友善之臂的说法到此就可以结束了,就可以make zImage了,谁知道我一make 报出来了许多错误,最后通过网络论坛的查询,需要给mach-mini2440.c文件添加几个头文件,本人图省事就找MINI2440内核源码,然后从里面将所有的头文件都COPY过来了。如果暂时用不到某
个头文件也无所谓的呵呵。需要添加的头文件如下:

 #include  
#include  
#include  
#include  
#include 

7.这个时候编译可以成功了,下载到开发板中厚,从超级终端得到的信息是并没有发现nandflash,不行啊,只能继续查网络得到如下结论,还是需要对mach-mini2440.c文件进行修改,将指定函数改为如下代码:
 
 static void __init mini2440_machine_init(void)
{
  s3c_i2c0_set_platdata(NULL);
 s3c_device_nand.dev.platform_data = &mini2440_nand_info; 
 platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
 //smdk_machine_init();
}
8.保存退出
9.make distclean
10.make mini2440_defconfig
11.make zImage
12.将文件通过DNW下载后,将norflash启动更改为nandflash启动,重新上电后,就可以在超级终端发现如下信息,证明nandflash移植成功

load Image of Linux...Uncompressing Linux................................................................................................................................. done, booting the kernel.
Linux version 2.6.32.2 (root@xubin-desktop) (gcc version 4.2.3 (Sourcery G++ Lite 2008q1-126)) #1 Thu Apr 5 11:27:45 CST 2012
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: FriendlyARM Mini2440 development board
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, (c) 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60596KB available (3584K code, 417K data, 132K init, 0K highmem)
SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Hierarchical RCU implementation.
NR_IRQS:85
irq: clearing subpending status 00000002
Console: colour dummy device 80x30
console [ttySAC0] enabled
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4808000, irq 33
DMA channel 1 at c4808040, irq 34
DMA channel 2 at c4808080, irq 35
DMA channel 3 at c48080c0, irq 36
S3C244X: Clock Support, DVS off
bio: create slab at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c: slave address 0x10
s3c-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 118
alg: No test for stdrng (krng)
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
s3c2410-lcd s3c2410-lcd: no platform data for lcd, cannot attach
s3c2410-lcd: probe of s3c2410-lcd failed with error -22
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 807 at 0x0000064e0000
Bad eraseblock 893 at 0x000006fa0000
Bad eraseblock 2020 at 0x00000fc80000
Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000040000 : "boot"
0x000000040000-0x000000060000 : "param"
ftl_cs: FTL header not found.
0x000000060000-0x000000560000 : "Kernel"
uncorrectable error : 
0x000000560000-0x000040560000 : "root"
mtd: partition "root" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0xfaa0000
ftl_cs: FTL header not found.
0x000000000000-0x000040000000 : "nand"
mtd: partition "nand" extends beyond the end of device "NAND 256MiB 3,3V 8-bit" -- size truncated to 0x10000000
dm9000 Ethernet Driver, V1.31
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
i2c /dev entries driver
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
cpuidle: using governor ladder
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
usbcore: registered new interface driver hiddev
usbcore: registered new interface driver usbhid
usbhid: v2.6:USB HID core driver
Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI UDA134X
No device for DAI s3c24xx-i2s
ALSA device list:
  No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
List of all partitions:
1f00             256 mtdblock0 (driver?)
1f01             128 mtdblock1 (driver?)
1f02            5120 mtdblock2 (driver?)
1f03          256640 mtdblock3 (driver?)
1f04          262144 mtdblock4 (driver?)
No filesystem could mount root, tried:  ext3 cramfs vfat msdos romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
[] (unwind_backtrace+0x0/0xe0) from [] (panic+0x40/0x120)
[] (panic+0x40/0x120) from [] (mount_block_root+0x1c4/0x204)
[] (mount_block_root+0x1c4/0x204) from [] (prepare_namespace+0x160/0x1b8)
[] (prepare_namespace+0x160/0x1b8) from [] (kernel_init+0xd4/0x108)
[] (kernel_init+0xd4/0x108) from [] (kernel_thread_exit+0x0/0x8)
 
 
下一步:移植yaffs2
阅读(4616) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~