今晚根据《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、增加头文件:
- #include <linux/mtd/mtd.h>
- #include <linux/mtd/nand.h>
- #include <linux/mtd/nand_ecc.h>
- #include <linux/mtd/partitions.h>
- #include <plat/nand.h>
2、增加文档中说的三个结构:
- static struct mtd_partition mini2440_default_nand_part[] = {
- [0] = {
- .name = "supervivi",
- .size = 0x00040000,
- .offset = 0,
- },
- [1] = {
- .name = "param",
- .offset = 0x00040000,
- .size = 0x00020000,
- },
- [2] = {
- .name = "Kernel",
- .offset = 0x00060000,
- .size = 0x00500000,
- },
- [3] = {
- .name = "root",
- .offset = 0x00560000,
- .size = 1024 * 1024 * 1024, //
- },
- [4] = {
- .name = "nand",
- .offset = 0x00000000,
- .size = 1024 * 1024 * 1024, //
- }
- };
- static struct s3c2410_nand_set mini2440_nand_sets[] = {
- [0] = {
- .name = "NAND",
- .nr_chips = 1,
- .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
- .partitions = mini2440_default_nand_part,
- },
- };
- static struct s3c2410_platform_nand mini2440_nand_info = {
- .tacls = 20,
- .twrph0 = 60,
- .twrph1 = 20,
- .nr_sets = ARRAY_SIZE(mini2440_nand_sets),
- .sets = mini2440_nand_sets,
- .ignore_unset_ecc = 1,
- };
3、增加这三个结构之后修改如下代码
- static struct platform_device *mini2440_devices[] __initdata = {
- &s3c_device_ohci,
- &s3c_device_lcd,
- &s3c_device_wdt,
- &s3c_device_i2c0,
- &s3c_device_iis,
- &s3c_device_nand, //增加部分
- };
4、最后在在修改如下结构
- static void __init mini2440_map_io(void)
- {
- s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
- s3c24xx_init_clocks(12000000);
- s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
- s3c_device_nand.dev.platform_data = &mini2440_nand_info; //增加的部分
- }
最后一编译果然通过了
- [root@localhost linux-2.6.35.13]# make zImage
- CHK include/linux/version.h
- CHK include/generated/utsrelease.h
- make[1]: “include/generated/mach-types.h”是最新的。
- CALL scripts/checksyscalls.sh
- CHK include/generated/compile.h
- CC arch/arm/mach-s3c2440/mach-mini2440.o
- LD arch/arm/mach-s3c2440/built-in.o
- LD vmlinux.o
- MODPOST vmlinux.o
- WARNING: modpost: Found 3 section mismatch(es).
- To see full details build your kernel with:
- 'make CONFIG_DEBUG_SECTION_MISMATCH=y'
- GEN .version
- CHK include/generated/compile.h
- UPD include/generated/compile.h
- CC init/version.o
- LD init/built-in.o
- LD .tmp_vmlinux1
- KSYM .tmp_kallsyms1.S
- AS .tmp_kallsyms1.o
- LD .tmp_vmlinux2
- KSYM .tmp_kallsyms2.S
- AS .tmp_kallsyms2.o
- LD vmlinux
- SYSMAP System.map
- SYSMAP .tmp_System.map
- OBJCOPY arch/arm/boot/Image
- Kernel: arch/arm/boot/Image is ready
- GZIP arch/arm/boot/compressed/piggy.gzip
- AS arch/arm/boot/compressed/piggy.gzip.o
- SHIPPED arch/arm/boot/compressed/lib1funcs.S
- AS arch/arm/boot/compressed/lib1funcs.o
- LD arch/arm/boot/compressed/vmlinux
- OBJCOPY arch/arm/boot/zImage
- Kernel: arch/arm/boot/zImage is ready
之后将编译好的内核下载到开发板运行
- ##### FriendlyARM BIOS 2.0 for 2440 #####
- [x] format NAND FLASH for Linux
- [v] Download vivi
- [k] Download linux kernel
- [y] Download root_yaffs image
- [a] Absolute User Application
- [n] Download Nboot for WinCE
- [l] Download WinCE boot-logo
- [w] Download WinCE NK.bin
- [d] Download & Run
- [z] Download zImage into RAM
- [g] Boot linux from RAM
- [f] Format the nand flash
- [b] Boot the system
- [s] Set the boot parameters
- [u] Backup NAND Flash to HOST through USB(upload)
- [r] Restore NAND Flash from HOST through USB
- [q] Goto shell of vivi
- [i] Version: 0945-2K
- Enter your selection: b
- Copy linux kernel from 0x00060000 to 0x30008000, size = 0x00500000 ... done
- zImage magic = 0x016f2818
- Setup linux parameters at 0x30000100
- linux command line is: "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0"
- MACH_TYPE = 1999
- NOW, Booting Linux......
- Uncompressing Linux... done, booting the kernel.
- 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
- CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
- CPU: VIVT data cache, VIVT instruction cache
- Machine: FriendlyARM Mini2440 development board for LiuPeng
- ATAG_INITRD is deprecated; please update your bootloader.
- Memory policy: ECC disabled, Data cache writeback
- CPU S3C2440A (id 0x32440001)
- S3C24XX Clocks, Copyright 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: 60532k/60532k available, 5004k reserved, 0K highmem
- Virtual kernel memory layout:
- vector : 0xffff0000 - 0xffff1000 ( 4 kB)
- fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
- DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
- vmalloc : 0xc4800000 - 0xe0000000 ( 440 MB)
- lowmem : 0xc0000000 - 0xc4000000 ( 64 MB)
- modules : 0xbf000000 - 0xc0000000 ( 16 MB)
- .init : 0xc0008000 - 0xc0029000 ( 132 kB)
- .text : 0xc0029000 - 0xc03c9000 (3712 kB)
- .data : 0xc03e8000 - 0xc0411080 ( 165 kB)
- SLUB: Genslabs=11, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
- Hierarchical RCU implementation.
- RCU-based detection of stalled CPUs is disabled.
- Verbose stalled-CPUs detection is disabled.
- NR_IRQS:85
- irq: clearing subpending status 00000003
- irq: clearing subpending status 00000002
- Console: colour dummy device 80x30
- console [ttySAC0] enabled
- Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
- pid_max: default: 32768 minimum: 301
- Mount-cache hash table entries: 512
- CPU: Testing write buffer coherency: ok
- gpiochip_add: gpios 288..303 (GPIOK) failed to register
- gpiochip_add: gpios 320..334 (GPIOL) failed to register
- gpiochip_add: gpios 352..353 (GPIOM) failed to register
- NET: Registered protocol family 16
- S3C2440: Initialising architecture
- S3C2440: IRQ Support
- S3C24XX DMA Driver, Copyright 2003-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 <bio-0> 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
- Advanced Linux Sound Architecture Driver Version 1.0.23.
- 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
- UDP hash table entries: 256 (order: 0, 4096 bytes)
- UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
- 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 deadline registered
- io scheduler cfq registered (default)
- Console: switching to colour frame buffer device 60x53
- fb0: s3c2410fb frame buffer device
- 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 89 at 0x000000b20000
- Bad eraseblock 520 at 0x000004100000
- Bad eraseblock 1445 at 0x00000b4a0000
- Creating 5 MTD partitions on "NAND 256MiB 3,3V 8-bit":
- 0x000000000000-0x000000040000 : "supervivi"
- uncorrectable error :
- 0x000000040000-0x000000060000 : "param"
- 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
- uncorrectable error :
- 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
- 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: USB HID core driver
- 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)
- [<c002e574>] (unwind_backtrace+0x0/0xec) from [<c02e75c0>] (panic+0x54/0xe4)
- [<c02e75c0>] (panic+0x54/0xe4) from [<c0008ed8>] (mount_block_root+0x1d0/0x210)
- [<c0008ed8>] (mount_block_root+0x1d0/0x210) from [<c0009170>] (prepare_namespace+0x164/0x1bc)
- [<c0009170>] (prepare_namespace+0x164/0x1bc) from [<c0008470>] (kernel_init+0x10c/0x14c)
- [<c0008470>] (kernel_init+0x10c/0x14c) from [<c002a818>] (kernel_thread_exit+0x0/0x8)
这样就能看到移植的Nand的一些信息了,到此内核就移植好了,下一步学习移植yaffs2,还不知道这是个什么东东呢?
阅读(3182) | 评论(0) | 转发(2) |