移植linux2.6.29内核+yaffs2文件系统过程[转]
软件平台:vm(fodera 9)+arm-linux-gcc 4.3.2
参考资料:网上n多资料,在这里先谢谢这些无私贡献自己经验的前辈们。
<<嵌入式Linux应用开发完全手册>>作者:韦东山,书完全是根据作者的经验写的,
和2410 2440的板子比较配套,我觉得这是一本非常好的参考书,特别是用2410或者是2440的初学者.
现在开始移植了,bootloader我还是用的mini2440的supervivi,这个比较方便,功能十
分强大,u-boot就留给以后吧.2440的板子移植内核还是比较简单的,因为内核里面已经有了2410的配置文件,
简单的改一下,基本就可以了,再就是外设驱动的修改了.
1.修改顶层Makefile文件
直接将Makefile文件里面的 ln193
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
改为:
ARCH ?= arm
CROSS_COMPILE ?=arm-linux-
然后用S3C2410的默认配置文件
#make s3c2410_defconfig //此命令 configuration written to .config
//要先按上面方法修改完成Makefile文件才能执行这一步
#make menuconfig //只需修改下面几项
Enable loadable module support --->
Module unloading
Automatic kernel module loading
选择这两个,剩下的可以去掉
System Type ---->
S3C2410 DMA support
Support ARM920T processor
S3C2410 Machines --->
SMDK2410/A9M2410
S3C2440 Machines --->
SMDK2440
SMDK2440 with S3C2440 CPU module
**************************************************************************************************************
2.修改时钟,不修改超级终端中会出现乱码
修改Arch/arm/mach-s3c2440/mach-smdk2440.c ln163
S3c24xx_init_clocks(16934400);
改为:
S3c24xx_init_clocks(12000000);
3.修改mach-type
方法1:修改vivi的启动参数
从nandflash启动后,迅速按住SPACE键进入supervivi
Supervivi> menu,进入菜单vivi
##### FriendlyARM BIOS for 2440 #####
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[c] Download root_cramfs image
[n] Download Nboot
[e] Download Eboot
Download WinCE NK.nb0
[w] Download WinCE NK.bin
[d] Download & Run
[f] Format the nand flash
[p] Partition for Linux
Boot the system
[s] Set the boot parameters
[t] Print the TOC struct of wince
[q] Goto shell of vivi
Enter your selection: s
##### Parameter Menu #####
[r] Reset parameter table to default table
[s] Set parameter
[v] View the parameter table
[w] Write the parameter table to flash memeory
[q] Quit
Enter your selection: s
Enter the parameter's name(mach_type, media_type, linux_cmd_line, etc): mach_type
Enter the parameter's value(if the value contains space, enclose it with "): 362
Change 'mach_type' value. 0x0000030e(782) to 0x0000016a(362)
这一步有时候会卡很长时间,多试几遍就好了,不知道什么原因。
##### Parameter Menu #####
[r] Reset parameter table to default table
[s] Set parameter
[v] View the parameter table
[w] Write the parameter table to flash memeory
[q] Quit
Enter your selection: w
Found block size = 0x0000c000
Erasing... ... done
Writing... ... done
Written 49152 bytes
Saved vivi private data
##### Parameter Menu #####
[r] Reset parameter table to default table
[s] Set parameter
[v] View the parameter table
[w] Write the parameter table to flash memeory
[q] Quit
Enter your selection: v
Number of parameters: 9
name : hex integer
-------------------------------------------------------------
mach_type : 0000016a 362
media_type : 00000003 3
boot_mem_base : 30000000 805306368
baudrate : 0001c200 115200
xmodem : 00000001 1
xmodem_one_nak : 00000000 0
xmodem_initial_timeout : 000493e0 300000
xmodem_timeout : 000f4240 1000000
boot_delay : 01000000 16777216
Linux command line: noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200
##### Parameter Menu #####
[r] Reset parameter table to default table
[s] Set parameter
[v] View the parameter table
[w] Write the parameter table to flash memeory
[q] Quit
Enter your selection: q
方法2:修改内核文件
修改cpu ID,不修改将会出现无法进入内核由于CPU mach_type 不对应找不到对应的CPU。
arch/arm/tools/mach-types 这个文件打开修改 对应CPU 的ID
比如我修改 S3C2410 对应为 782(我的VIVI的ID)。这样就可以找到S3C2410了
***********************************************************************************************************************
4.修改MTD分区
MTD分区信息在arch/arm/plat-s3c24xx/common-smdk.c文件中修改. ln109
这个也比较简单,我是根据supervivi里面的分区信息来的,我的分区信息如下:
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "vivi",
.size = 0x00030000,
.offset = 0X00000000,
},
[1] = {
.name = "kernel",
.offset = 0x00050000,
.size = 0x00200000,
},
[2] = {
.name = "root",
.offset =0x00250000,
.size =0x03dac000,
}
};
有的文章介绍说这个文件还要修改smdk_nand_info如下:
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 0, //default is 20
.twrph0 = 30, //default is 60
.twrph1 = 0, //defualt is 20 changed by yangdk
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};
但查看友善之臂的内核发现并没有改,因此我也没有修改,最终也没出现问题
启动之后还是会现panci信息因为还没有写入文件系统.
5.内核增加yaffs2支持
到网上下载ysffs2源代码,解压之后进行如下修改:
./patch-ker.sh c /2440/linux-2.6.29
上面命令完成下面三件事情
(1)修改内核fs/Kconfig
增加一行:source "fs/yaffs2/Kconfig"
(2)修改内核fs/Kconfig
增加一行jb-$(CONFIG_YAFFS_FS) +=yaffs2/
(3)在内核fs/目录下创建yaffs2目录
将yaffs2源码目录下面的Makefile.kernel文件复制为内核fs/yaffs2/Makefie;
将yaffs2 源码目录的Kconfig文件复制到内核fs/yaffs2目录下;
将yaffs2源码目录下的*.c *.h文件复制到内核fs/yaffs2目录下.
在内核根目录下执行:
#make menuconfig 配置yaffs2文件支持
File systems --->
Miscellaneous filesystems --->
<*>YAFFS2 file system support
这里留着默认配置不知道可不可以,我在移植yaffs文件系统中由于出现问题一直找不到原因
后来将这里完全按照友善之臂的配置改了一下,但是并没有解决我的问题。
6.#make uImage 生成zImage
**********************************************************************************************************************
7.创建yaffs文件系统
具体移植过程如下:
1. 创建必须的文件夹及设备文件
# mkdir rootfs
# cd rootfs
# mkdir bin dev etc lib mnt proc sbin sys root
# mkdir /etc/var
# mkdir /etc/tmp
# ln -s /etc/var /var
# ln -s /etc/tmp /tmp
2. 创建设备文件系统
从 Linux-2.6.18开始,负责旧版本的设备管理系统devfs已被废除,但新
版本的udev是一个基于用户空间的设备管理系统。在内核启动时并不能
自动创建设备节点,固需手动创建console和null两个启动过程必须的设
备节点。我们将采用busybox中内置的mdev,一个简化的udev版本.
# mknod -m 660 dev/console c 5 1
# mknod -m 660 dev/null c 1 3
3. 建立动态运行库
由于linux只安装上了arm-linux-gcc 4.3.2没有glibc的库文件,只好把友善之臂提供的
yaffs2文件系统下的lib文件拷贝过来。
# cp -rfd /2440/root_qtopia/lib/* /2440/rootfs/lib/
拷贝经过交叉编译的库文件,参数-d,保持库文件的链接关系。
4. 交叉编译busybox
解压缩tar -zxf busybox1.13.3.tar
解压后修改Makefile,指明交叉编译器:
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-
5.执行make CONFIG_PREFIX=/2440/rootfs install
在/2440/rootfs目录下生成sbin,usr目录和linuxrc文件
6.创建etc目录下文件
在rootfs/etc目录下创建一个inittab文件
内容如下:
# /etc/inittab
::sysinit:/etc/init.d/rcS
s3c2410_serial0::askfirst:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
创建etc/init.d/rcS文件
#!/bin/sh
ifconfig eth0 192.168.1.17
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
最后还要改变它的属性使它能够执行。
chmod +x etc/init.d/rcS
创建etc/fstab文件
#device mount-point type options dump fack order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0
7.构建其他目录
mkdir proc mnt tmp sys root
8.使用mkyaffsimgae命令生成yaffs映像文件
mkyaffsimage rootfs rootfs.yaffs
9.通过supervivi将内核映像zImage和rootfs.yaffs下载到开发板上
启动内核出现
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 132K
Kernel panic - not syncing: Attempted to kill init!
后来对比友善之臂的menuconfig把Kernel Features改为
Kernel Features --->
Memory split...--->
[ ]preemptible Kernel...
Use the ARM EABI to compile the kernel
Allow old ABI binaries to run ......
Memory model (flatMemory)--->
[ ]Add lru list to tarck non-evictable pages
解决问题
以下为启动信息,可能还有点小问题以后解决
VIVI version 0.1.4 (root@capcross) (gcc version 2.95.3 20010315 (release)) #0.1.4 Mon Oct 27 10:18:15 CST 2008
MMU table base address = 0x33DFC000
Succeed memory mapping.
DIVN_UPLL0
MPLLVal [M:7fh,P:2h,S:1h]
CLKDIVN:5h
+---------------------------------------------+
| S3C2440A USB Downloader ver R0.03 2004 Jan |
+---------------------------------------------+
USB: IN_ENDPOINT:1 OUT_ENDPOINT:3
FORMAT: +++
NOTE: Power off/on or press the reset button for 1 sec
in order to get a valid USB device address.
NAND device: Manufacture ID: 0xec, Chip ID: 0x76 (Samsung K9D1208V0M)
Found saved vivi parameters.
Press Return to start the LINUX/Wince now, any other key for vivi
Copy linux kernel from 0x00050000 to 0x30008000, size = 0x00200000 ... done
zImage magic = 0x016f2818
Setup linux parameters at 0x30000100
linux command line is: "noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0"
MACH_TYPE = 362
NOW, Booting Linux......
Uncompressing Linux.......................................................................................................... done, booting the kernel.
Linux version 2.6.29 (root@LINUX) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #4 Wed Apr 15 10:29:11 HKT 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: SMDK2440
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/mtdblock2 init=/linuxrc console=ttySAC0
irq: clearing pending status 02000000
irq: clearing subpending status 00000002
PID hash table entries: 256 (order: 8, 1024 bytes)
Console: colour dummy device 80x30
console [ttySAC0] enabled
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: 61420KB available (3024K code, 270K data, 132K init)
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 716 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
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
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
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
NetWinder Floating Point Emulator V0.97 (extended precision)
yaffs Apr 15 2009 10:21:24 Installing.
msgmni has been set to 120
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 30x40
fb0: s3c2410fb frame buffer device
lp: driver loaded but no devices found
ppdev: user-space parallel port driver
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
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
loop: module loaded
dm9000 Ethernet Driver, V1.31
Uniform Multi-Platform E-IDE driver
ide-gd driver 1.18
ide-cd driver 5.00
Driver 'sd' needs updating - please use bus_type methods
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x000000000000-0x000000050000 : "vivi"
0x000000050000-0x000000250000 : "kernel"
0x000000250000-0x000003ffc000 : "rootfs"
usbmon: debugfs is not available
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
usbcore: registered new interface driver usbserial
USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
S3C24XX RTC, (c) 2004,2006 Simtec Electronics
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs filesystem) on device 31:2.
Freeing init memory: 132K
ifconfig: SIOCSIFADDR: No such device
Please press Enter to activate this console.
阅读(2243) | 评论(1) | 转发(0) |