空闲时间做了内核的移植工作,将linux2.6.25内核移植到mini2440,下面是我成功移植后总结的笔记,希望对初学此方面的博友有帮助。
一.开发环境的建立
1.系统为VMware5.5 + Red hat linux 9.0
2.交叉编译器版本为arm-linux-gcc-3.4.5
在命令行执行:
cd /xx/xx/xx/ "此目录为你暂时存放编译器压缩文件的目录"
tar zxvf arm-linux-gcc-3.4.5.tgz -C /,将编译器解压并安装到/usr/local/arm目录中(具体解压到哪个目录要看你压缩包的原目录是什么了,你也可以指定目录)。
二.移植内核
1.下载内核源码到下面网站下载:
2.建立工作目录
在命令行执行:mkdir –p /opt/FriendlyARM/mini2440
此目录是我的工作目录,名称你可以随意修改,如果修改下面的路径也需要做相应的修改
3.解压系统源码
假如将内核源码存放在/xx/xx/ 下面。则执行:
cd /xx/xx/
tar jxvf(如果以gzip方式压缩的则为zxvf)linux-2.6.25.tar.bz2 –C /opt/FriendlyARM/mini2440/,将其解压到PC 的“/opt/FriendlyARM/mini2440/”目录下。
4、在系统中添加对ARM 的支持及设置好编译器
进到内核源码:cd /opt/FriendlyARM/mini2440/linux-2.6.25.8
修改顶层“Makefile ”文件,
ARCH ? =arm
CROSS_COMPILE ?=/usr/local/arm/3.4.5/bin/arm-linux- 然后保存。
5、修改平台输入时钟
修改平台的时钟频率,修改内核源码“arch/arm/machs3c2440/
mach-smdk2440.c”,把16934400 改为12000000,因为我们的开发板上为12M
6、修改机器类型ID号
Supervivi的机器码是782,所以这里需要修改机器码,否则会出现不能启动的
情况。修改内核源码的“arch/arm/tools/mach-types”文件,在大概379 行,把原来的362 改为782
7、Nand Flash 驱动移植
linux 里面已经做好了Nand Flash 的驱动,我们只需要进行简单的修改即可
以使用了。
1.修改内核源码“arch/arm/plat-s3c24xx/common-smdk.c”文件,这个是NAND FLASH分区的信息。
内核MTD分区必须与vivi分区相一致。因为,vivi分区中的地址是引导程序、内核映像及文件系统下载到Nand Flash的真正地址;而内核启动时,内核并不是去读vivi分区中的地址,而是去读内核MTD分区设定的地址;所以,如果内核MTD分区与vivi分区不相同,很可能导致不能正常启动内核及读取文件系统,根据vivi的分区信息进行如下修改。
static struct mtd_partition smdk_default_nand_part[] = {
[0] = { .name = "vivi",
.size = 0x00020000,
.offset = 0X00000000,
},
[1] = { .name = "kernel_linux2.6.25",
.offset = 0x00050000,
.size = 0x00200000,
},
[2] = { .name = "root_yaffs2",
.offset =0x00250000,
.size =0x03dac000,
}
};
8、制作配置文件
第一次配置,推荐调用自带的一个默认配置单,该配置单在内核源码的“arch/arm/configs/
s3c2410_defconfig”,该配置文件里面选择了几乎所有的和S3C24XX 系列CPU 相关的
配置选项,可以在该配置单的基础上进行修改自己的配置。当然您也可以自行配置,具体配置方法,建议摸索及参考网上资料。
首先到内核根目录下,输入make menuconfig将打开配置窗口。
在配置菜单中选择选项:“Load an Alternate Configuration File”,然后调用上面说到的那个配置文件,也就是在配置文件名对话框中输入下面的信息。
arch/arm/configs/s3c2410_defconfig
输入完毕后按回车返回到配置界面,进入到“System Type”选项下的配置单:
选中下面的配置项。
System Type --->
[*] S3C2410 DMA support
[*] support ARM920T processor
然后配置平台:
S3C2410 Machines --->
[*] SMDK2410/A9M2410
S3C2440 Machines --->
[*] SMDK2440
[*] SMDK2440 with S3C2440 CPU module
添加对应的NANDFLASH驱动配置
配置如下所示:
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
< > RedBoot partition table parsing
[ ] Command line partition table parsing
<*> NAND Device Support --->
<*> NAND Flash support for S3C2410/S3C2440 SoC
配置完毕这些之后,保存配置单。其它没涉及到的可以保留原配置,也可以根据你的需要修改。
配置完毕后,回到主菜单。然后选择选项:“Save an Alternate Configuration File”,
将其保存为:“.config”文件,因为编译系统时会调用该文件。
保存为“.config”文件后,退出配置单。
你也可以保存为你自己想要的配置名称像config_yourselfname,因为当你执行了#make distclean 命令后,将会清除所有生成的文件。包括配置文件。而你执行make distclean 命令后,在命令行输入cp config_yourselfname .config(目的是将上次的配置复制为.config, 因为编译系统时会调用该文件)
即而就可以在原配置的基础上进行需要的修改。
9、编译镜像
到内核根目录,输入:#make zImage,就可以进行编译了,编译完毕后,会在内核源码的“arch/arm/boot/”目录下面生成名为“zImage”的镜像,然后将其烧写到开发板中,启动情况如下:
VIVI version 0.1.4 () (gcc version 2.95.3 20010315 (release)) #0.1.4 Mon Aug 18 21:35:37 CST 2008
MMU table base address = 0x33DFC000
Succeed memory mapping.
DIVN_UPLL0
MPLLVal [M:7fh,P:2h,S:1h]
CLKDIVN:dh
+---------------------------------------------+
| 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)
Could not found stored vivi parameters. Use default 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 = 782
NOW, Booting Linux......
Uncompressing Linux................................................................................................... done,
booting the kernel.
Linux version 2.6.25.8 () (gcc version 3.4.5 (Sourcery G++ Lite 2008q3-72) ) #1 Mon Apr 27 21:02:49
CST 2009
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2440
ATAG_INITRD is deprecated; please update your bootloader.
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
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)
timer tcon=00000000, tcnt a4ca, tcfg 00000200,00000000, usec 00001e57
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: 61592KB available (2828K code, 289K data, 128K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 152 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 c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
S3C244X: Clock Support, DVS off
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
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
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 $Revision: 1.90 $ 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.30
Uniform Multi-Platform E-IDE driver
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
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":
0x00000000-0x00020000 : "supervivi" 此处为分区信息。
0x00050000-0x00250000 : "kernel_linux2.6.25"
0x00250000-0x03ffc000 : "yaffs2_root"
usbmon: debugfs is not available
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
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 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
List of all partitions:
0100 4096 ram0 (driver?)
0101 4096 ram1 (driver?)
0102 4096 ram2 (driver?)
0103 4096 ram3 (driver?)
0104 4096 ram4 (driver?)
0105 4096 ram5 (driver?)
0106 4096 ram6 (driver?)
0107 4096 ram7 (driver?)
0108 4096 ram8 (driver?)
0109 4096 ram9 (driver?)
010a 4096 ram10 (driver?)
010b 4096 ram11 (driver?)
010c 4096 ram12 (driver?)
010d 4096 ram13 (driver?)
010e 4096 ram14 (driver?)
010f 4096 ram15 (driver?)
1f00 128 mtdblock0 (driver?)
1f01 2048 mtdblock1 (driver?)
1f02 63152 mtdblock2 (driver?)
No filesystem could mount root, tried: ext3 ext2 cramfs msdos vfat romfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
说明:bootloader使用的是友善自带的supervivi.