热门关键字:  ubuntu  分区  函数  Fedora  linux系统进程

移植uClinux-2.6.9到S3C44B0的过程

来源: 作者: 时间:2007-12-21 Tag: 点击:
 
2、修改linux-2.6.x/arch/armnommu//kernel/vmlinux-lds.S, 添加romfs.o
78 *(.got) /* Global offset table */
79
80 romfs_start = .;
81 romfs.o
82 romfs_end = .;
 
3、修改linux-2.6.x/arch/armnommu/kernel/setup.c,添加变量romfs_start,romfs_end及设置default_command_line
64 extern int _stext, _text, _etext, _edata, _end;
65 extern int romfs_start,romfs_end;

682 char *from = default_command_line;
683 sprintf(default_command_line, "root=/dev/ram0 initrd=0x%08lx,%ldk console-ttyS0,115200", (unsigned long)&romfs_start,((unsigned long)&romfs_end - (unsigned long)&romfs_start)>>10);
 
试运行,结果:
 Inode-cache hash table entries: 1024 (order: 0, 4096 bytes) Linux............................................... done,
Memory: 8MB = 8MB totaloint:  0c008000ompressi
Memory: 6624KB available (1274K code, 122K data, 56K init)booting
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
checking if image is initramfs...it isn't (ungzip failed); looks like an initrd
NET: Registered protocol family 16
init_module
Samsung S3C44B0 Rtl8019as driver version 0.1 (2002-02-20) <hzh12@163.net>
init
eth0: 12:34:56:78:90:ab
get_stats
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize
loop: loaded (max 8 devices)
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 512)
NET: Registered protocol family 1
NET: Registered protocol family 17
RAMDISK: romfs filesystem found at block 0
RAMDISK: Loading 120KiB [1 disk] into ram disk... done.
VFS: Mounted root (romfs filesystem) readonly.
Mounted devfs on /dev
Freeing init memory: 56K
Warning: unable to open an initial console.
是不打开控制台,这下应该是串口驱动没有导致的。
 
增加串口驱动
内核源代码中只带了44b0的简易串口驱动。要自己编写串口驱动程序:
(1), 增加文件。(文件可参考4510的串口驱动,要注意很多细节)
linux-2.6.x/drivers/serial/serial_s3c44b0.c
    linux-2.6.x/include/asm-armnommu/arch-s3c44b0x/uart.h
 (2),修改linux-2.6.x/drivers/serial/Kconfig,添加44B0X串口相关内容
config SERIAL_S3C44B0X
bool 'S3C44B0X Serial Support'
       default y
       select SERIAL_CORE
       help
       Samsung S3C44B0X Chips has built-in serial controler
config SERIAL_S3C44B0X_CONSOLE
       bool "Support for console on S3C44B0X Serial port"
       depends on SERIAL_S3C44B0X=y
       select SERIAL_CORE_CONSOLE
       help
          Allow selection of the S3C44B0X on-board serial ports for use as
          an virtual console.
 (3),修改linux-2.6.x/drivers/serial/Makefile,添加44B0x的相关内容:
  obj-$(CONFIG_SERIAL_S3C44B0X) += serial_s3c44b0.o
(4),修改linux-2.6.x/include/linux/serial_core.h,在其中加入PORT_S3C44B0的定义:
 #define PORT_S3C44B0   62
(5),修改linux-2.6.x/arch/armnommu/mach-s3c44b0x/driverMakefileKconfig文件,注释掉原来与简易串口相关的内容。
(6)linux-2.6.x/drivers/serial/serial_s3c44b0.c中将有
    CONFIG_SERIAL_S3C44B0_CONSOLE改为:CONFIG_SERIAL_S3C44B0X_CONSOLE
   
并设置波特率为正确的值。
 (7)记得要根据自己板子配置serial_s3c44b0.c中的static void __s3c44b0_init(struct uart_port *port, int baud)函数中的寄存器的值。
8、在linux-2.6.x/include/asm-armnomn/arch-s3c44b0x/s3c44b0x.h中增加:
#define INT_ENABLE(n) INTMSK  &=~(1<<(n))
#define INT_DISABLE(n) INTMSK  |=(1<<(n))
9、修改serial_s3c44b0.c相应函数,增加#define CONFIG_SERIAL_S3C44b0_CONSOLE
 
终于可以启动了,不过运行中,还有以下问题:
U-Boot 1.1.4 (Jan 22 2007 - 16:40:53)
U-Boot code: 0C700000 -> 0C719EF8  BSS: -> 0C71E99C
RAM Configuration:
 Bank #0: 0c000000  8 MB
Flash:  2 MB
In:    serial 
Out:   serial            
Err:   serial            
Hit any key to stop autoboot:  0                               
## Booting image at 00040000 ...                               
   Image Name:   Linux-2.6.9                           
   Created:      2007-01-26   2:50:16 UTC                                        
   Image Type:   ARM Linux Kernel Image (uncompressed)                                                     
   Data Size:    659816 Bytes = 644.4 kB                                       
   Load Address: 0c008000                        
   Entry Point:  0c008000                        
   Verifying Checksum ... OK                           
OK 
Starting kernel ...                  
Uncompressing Linux................................................ done, booting the kernel.  Linux version 2.6.9-hsc0 (root@localhost.localdomain) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #48 Fri Jan 26 10:  
 47:23 CST 2007             
CPU: Samsung-S3C44B0x [44b07700] revision 0 (ARMv4T)                                                   
Machine: S3C44B0X Development Board                                  
Built 1 zonelists                
Kernel command line: root=/dev/ram0 initrd=0x0c13c53c,120k console=ttyS0,115200   
PID hash table entries: 64 (order: 6, 1024 bytes)                                                
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)                                                           
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)                                                          
Memory: 8MB = 8MB total                      
Memory: 6592KB available (1297K code, 132K data, 56K init)                                                         
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)                                                         
checking if image is initramfs...it isn't (ungzip failed); looks like an initrd  Freeing initrd memory: 120K                          
NET: Registered protocol family 16                                 
init_module          
Samsung S3C44B0 Rtl8019as driver version 0.1 (2002-02-20) <
hzh12@163.net
init   
eth0: 12:34:56:78:90:ab                      
get_stats        
devfs: 2004-01-31 Richard Gooch (
rgooch@atnf.csiro.au)                                                     
devfs: boot_options: 0x1
ttyS0 at I/O 0x1d00000 (irq = 3) is a Samsung S3C44B0 Internal UART 
ttyS1 at I/O 0x1d04000 (irq = 2) is a Samsung S3C44B0 Internal UART 
RAMDISK driver initialized: 16 RAM disks of 1024K size 1024 blocksize 
loop: loaded (max 8 devices)                           
Using anticipatory io scheduler                              
nbd: registered device at major 43                                 
NET: Registered protocol family 2                                
IP: routing cache hash table of 512 buckets, 4Kbytes                                                   
TCP: Hash tables configured (established 512 bind 512)                                                     
NET: Registered protocol family 1                                
NET: Registered protocol family 17                                 
RAMDISK: romfs filesystem found at block 0                                         
RAMDISK: Loading 120KiB [1 disk] into ram disk... done.                                                      
VFS: Mounted root (romfs filesystem) readonly.                                             
Mounted devfs on /dev                    
Freeing init memory: 56K                       
Shell invoked to run file: /etc/rc                                 
Command: hostname Samsung                        
Command: /bin/expand /etc/ramfs.img /dev/ram1                                            
/bin/expand: Bad command or file name                                    
Command: mount -t proc proc /proc                                
Command: mount -t ext2 /dev/ram1 /var                                    
mount failed: No such file or directory                                      
Command: mkdir /var/config                         
/var/config: Read-only file system                                 
Command: mkdir /var/tmp                      
/var/tmp: Read-only file system                              
Command: mkdir /var/log                      
/var/log: Read-only file system                              
Command: mkdir /var/run                      
/var/run: Read-only file system                              
Command: mkdir /var/lock                       
/var/lock: Read-only file system                               
Command: mkdir /var/empty                        
/var/empty: Read-only file system                                
Command: cat /etc/motd                     
Welcome to         
          ____ _  _                  
         /  __| ||_|                   
    _   _| |  | | _ ____  _   _  _  _                                    
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|
For further information check:
http://www.uclinux.org/
Command: ifconfig lo 127.0.0.1
ifconfig: Bad command or file name
Command: route add -net 127.0.0.0 netmask 255.255.255.0 lo
route: Bad command or file name
Command: dhcpcd &
dhcpcd: Bad command or file name
sh 10: Child 14 died
[14]
Execution Finished, Exiting
init: exec rc failed
init: /bin/firewall failed!init: exec rc failed
Sash command shell (version 1.1.1)
/>init: /bin/sh respawning too fast
init: /bin/sh respawning too fast
 
不断地出现init: /bin/sh respawning too fast,在控制台无法输入。文件系统还是有问题。这个问题给折腾了一周多。想尽一切办法,还做了ramdisk。在这里我把制作ramdisk的过程也写下来:
dd if=/dev/zero of=/dev/ram bs=1k count=2048
这条命令建立了一个2M字节的ramdisk,并将其清空。
mke2fs –vm0 /dev/ram 2048 或者 mke2fs -vm0 -Onone /dev/ram0 2048
对该块设备进行格式化,把它做成一个ext2fs
-Onone:由于我们使用的是uClinux的内核,所以一些附加的ext2fs功能并不支持,用该选项屏蔽这些功能;
-v:执行时提供更多调试信息;
-m0:缺省时文件系统会为超级用户提供5%的保留空间,而我们的系统是单用户模式,无需考虑这一点。所以把5%变成0%
1024:指明格式化的块数目。
可以使用可选的命令来调节ext2fs的使用过程:
tune2fs -i 0 /dev/ram0
-i
选项将保证不会依据时间长短对文件系统作检查。
mount –t ext2 /dev/ram /mnt   把刚做的ramdisk挂到/mnt下。
cp romfs/*的所有东东到/mnt中。
umount /mnt
dd if=/dev/ram bs=1k count=2048 | gzip –v9 > /ram_image.gz
这样就在redhat/下得到ram_image.gz文件了。
还是要用u-boot工具,命令:
./mkimage –n “Ramdisk” –A arm –O linux –T ramdisk –C gzip –a 0x0c600000 –e 0x0c600000 –d /ram_image.gz initrd
就得到initrd,烧到flash或者ram中。运行结果,如:
U-Boot 1.1.4 (Jan 22 2007 - 16:40:53)

U-Boot code: 0C700000 -> 0C719EF8  BSS: -> 0C71E99C
RAM Configuration:
Bank #0: 0c000000  8 MB
Flash:  2 MB
In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
=>  bootm 40000 140000
## Booting image at 00040000 ...
   Image Name:   Linux-2.6.9
   Created:      2007-02-02  18:21:43 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    605444 Bytes = 591.3 kB
   Load Address: 0c008000
   Entry Point:  0c008000
   Verifying Checksum ... OK
OK
## Loading Ramdisk Image at 00140000 ...
   Image Name:   Ramdisk
   Created:      2007-02-02  19:02:09 UTC
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    77798 Bytes = 76 kB
   Load Address: 0c600000
   Entry Point:  0c600000
   Verifying Checksum ... OK

Starting kernel ...

Uncompressing Linux............................................ done, booting the kernel.
Linux version 2.6.9-hsc0 (root@localhost.localdomain) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #62 Fri Feb 2 13:08:52 EST 2007
CPU: Samsung-S3C44B0x [44b07700] revision 0 (ARMv4T)
Machine: S3C44B0X Development Board
Built 1 zonelists
Kernel command line: root=/dev/ram0 rw initrd=0x0c600000,800k console=ttyS0,115200
PID hash table entries: 64 (order: 6, 1024 bytes)
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 8MB = 8MB total
Memory: 5864KB available (1194K code, 164K data, 56K init)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
checking if image is initramfs...it isn't (no cpio magic); looks like an initrd
Freeing initrd memory: 800K
NET: Registered protocol family 16
init_module
Samsung S3C44B0 Rtl8019as driver version 0.1 (2002-02-20) <hzh12@163.net>
init
eth0: 12:34:56:78:90:ab
get_stats
devfs: 2004-01-31 Richard Gooch (rgooch@atnf.csiro.au)
devfs: boot_options: 0x1
ttyS0 at I/O 0x1d00000 (irq = 3) is a Samsung S3C44B0 Internal UART
ttyS1 at I/O 0x1d04000 (irq = 2) is a Samsung S3C44B0 Internal UART
RAMDISK driver initialized: 16 RAM disks of 2048K size 1024 blocksize
loop: loaded (max 8 devices)
Using anticipatory io scheduler
nbd: registered device at major 43
NET: Registered protocol family 2
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 512)
NET: Registered protocol family 1
NET: Registered protocol family 17
RAMDISK: Compressed image found at block 0
VFS: Mounted root (ext2 filesystem).
Mounted devfs on /dev
Freeing init memory: 56K
Shell invoked to run file: /etc/rc
Command: hostname Samsung
Command: /bin/expand /etc/ramfs.img /dev/ram1
Can't open expanded file /dev/ram1
pid 11: failed 768
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram1 /var
mount failed: No such file or directory
Command: mkdir /var/config
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: mkdir /var/empty
Command: cat /etc/motd
Welcome to
          ____ _  _
         /  __| ||_|                 
    _   _| |  | | _ ____  _   _  _  _
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

For further information check:
http://www.uclinux.org/

Command: ifconfig lo 192.168.1.8
ifconfig: Bad command or file name
Command: route add -net 192.168.1.1 netmask 255.255.255.0 lo
route: Bad command or file name
Execution Finished, Exiting

Sash command shell (version 1.1.1)
/> init: /bin/sh respawning too fast
这文件系统的问题,实在让我快绝望了,就想到这步了还不行吗?太郁闷。试了多方法,结果一样。最后也不知道试什么了,但是在网上看到有人也遇到过这样的问题,说是和配置内核有关,于是把uClinux-dist/vendor/Samsung/44b0x下的config.linux-2.6.x load到内核配置中,同时也把44b0x下的config.vendor-2.4.x改名为config.vendor-2.6.x也把它load到内核的应用配置中,结果,文件系统没有错了,shell也没有init: /bin/sh respawning too fast这行出来了,但是shell怎么都不能输入字符。先到网搜一搜,看看这种情况的多不多,结果也没有什么相关的文章,就想可能是串口驱动问题,因为串口驱动是自己加上的。经过细心地阅读串口驱动代码,发现接收中断的入口错了,port->irq+1这是4510的入口。4510的发送和接收中断是相邻的,所以只加1即可,但是44b0是差4个字节,故把port->irq+1改为port->irq+4,退出,保存,重新编译,一切果然OK
最新评论共有 4 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册