原创 BusyBox v1.4.1 移植 s3c2410

2008-12-28 23:04 2312 2 2 分类: MCU/ 嵌入式

2007-02-04




init started:  BusyBox v1.4.1 (2007-02-03 10:47:43 CST) multi-call binary
Starting pid 743, console /dev/console: '/etc/init.d/rcS'


Please press Enter to activate this console.
Starting pid 753, console /dev/console: '/bin/sh'


BusyBox v1.4.1 (2007-02-03 10:47:43 CST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.


-sh: can't access tty; job control turned off
Set search library path int /etc/profile
Set user path in /etc/profile
#
可恶的shell终于出来拉...


      搞了两天,原来又犯老毛病--粗心...自从数据结构成绩出来后,心情一直都不好,那么简单的卷子分数竟然这么垃圾,还以为老师故意为难...直到前两天才发现,原来是自己粗心,做错三题,没什么好说的,只能怪自己。月满自亏,水满自溢,人满容易跌倒...人真奇怪,越是提醒,越是容易忘记。以此为训,不要在同一个地方跌倒多次!


      哈哈,牢骚发完,该总结以下移植过程了:


1.制作 ramdisk 。本打算直接用NFS挂文件系统的,可惜网卡驱动还没完全ok... 该部分内容可以参考Linux系统移植 (十分感谢前辈的共享) 和  http://www.hhcn.com/cgi-bin/topic.cgi?forum=3&topic=816 。


        #dd if="/dev/zero" of="/dev/ram1" bs="1k" count="8000"


        # losetup /dev/loop2 ramdisk


        # mkfs.ext2 /dev/loop2


        #mkdir ram


        # mount -t ext2 /dev/loop2 ram 


        #cd ram


        #mkdir bin dev etc lib mnt proc sbin sys tmp root usr


        #mkdir mnt/etc


        #mkdir usr/bin usr/lib usr/sbin


        #mknod -m 660 dev/console c 5 1


        #mknod -m 660 dev/null c 1 3


        #touch linuxrc  (至此,空ramdisk制作完毕)


当然,lib里面还要拷入一些库文件,为了方便,我将交叉编译的库全放进去。


        #cp -rfd /usr/local/arm/3.4.1/arm-linux/lib/* ./  (注意-d,保持库文件的链接关系)


2.下载,当然是最新版的 BusyBox 1.4.1 (stable)  。解压,修改Makefile:


        ARCH            ?= arm
        CROSS_COMPILE   ?= /usr/local/arm/3.4.1/bin/arm-linux-


接着便是make menuconfig 。如果不确定选哪些的话,可以用make depconfig 。值得注意的是 shell 的选择,在 Choose your default shell (none) 这一项回车后选择 ash , 否则,你会想我一样头疼大半天,make 后bin目录下就是没有sh ,而默认shell命令就是sh。错误提示如下:


Please press Enter to activate this console.
Starting pid 739, console /dev/console: '/bin/sh'
sh: applet not found
Process '-/bin/sh' (pid 739) exited.  Scheduling it for restart.



关于Build Options 的 Build BusyBox as a static binary (no shared libs) 静态编译,我用3.4.1版的交叉编译怎么都不通过,提示 glibc 有问题:


applets/applets.c:20:2: #warning Static linking against glibc produces buggy executables
applets/applets.c:21:2: #warning (glibc does not cope well with ld --gc-sections).
applets/applets.c:22:2: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
applets/applets.c:23:2: #warning Note that glibc is unsuitable for static linking anyway.
applets/applets.c:24:2: #warning If you still want to do it, remove -Wl,--gc-sections
applets/applets.c:25:2: #warning from top-level Makefile and remove this warning


2.95.3更加不行,唯有选用 Build shared lib busybox 。这样,就需要往 ram/lib 目录拷入相关的库文件。make , make install 后就出来 _install 目录,全拷到 ram 目录下。



        #gzip -9c ramdisk > ramdisk.image.gz


      到这里,基本的都已搞定,可以 reset 开发板看看。下面是常见的错误:


Failed to execute /linuxrc.


      如果传给内核的参数 init="/linuxrc" 没错的话,就要看看linuxrc文件是否正确,是否有权限运行。刚开始,由于没有选中 ash shell ,bin 目录下还没有 sh ,而我修改的 linuxrc 第一句的内容是 #!/bin/sh ,根本就不能解析。后来改为 #!/bin/ash ,能解析了,也高兴了一下,可惜提示 sh: applet not found 。选中默认的shell后问题解决。关于Linux的启动详细过程,可以参考 Linux 初始 RAM 磁盘(initrd)概述 、Linux Root Filesystem Primer 这两篇文章。Linux2.6 还引入了新的ram文件系统,配置起来相对简单,有机会尝试一下...


Warning: unable to open an initial console


      新的ramdisk不行,我换回原来的ramdisk,发现可以跑,只是提示找不到终端。于是,对比我和其它网友的串口输出。发现我的Linux-2.6.19.2没有 Mounted devfs on /dev 这项。大段大段的搜索后发现,这个devfs已被提出内核,而替代者udev在嵌入式方面还没有一点资料...网上的资料全都说从fs/Kconfig添加:


onfig DEVFS_FS
        bool "/dev file system support (OBSOLETE)"
        default y
config DEVFS_MOUNT


        bool "Automatically mount at boot"
        default y
        depends on DEVFS_FS


可是,一点用处都没有...从Linux-2.6.18开始,包括文档在内已没有一点devfs的使用信息。而网上移植的Linux版本都比较低,所以...本想尝试从旧版本中移植相关代码过来(有点奇怪^_^),幸好当我对比新旧ramdisk时发现旧的ramdisk dev目录下缺少 console ,mknod 后可以进入旧版的 busybox 0.6 ...


      最后是BusyBox的编译问题,使用3.4.1带的libc库编译,很容易出现与BusyBox里的程序不兼容现象。如:


modutils/lib.a(insmod.o)(.text.insmod_main+0x444): In function `insmod_main':
: undefined reference to `query_module'


miscutils/readahead.c: In function `readahead_main':


miscutils/taskset.c:17: error: parse error before '*' token
miscutils/taskset.c:18: warning: function declaration isn't a prototype
miscutils/taskset.c: In function `__from_cpuset':
......


最根本的解决办法是换一个libc库,可是现在还不知道哪个库最合适,唯有暂时将有问题的命令关掉...


      两个星期过得真快,我的系统也终于跑起来,虽然还有很多问题,但总算有点收获 ^_^

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
我要评论
0
2
关闭 站长推荐上一条 /1 下一条