嵌入式 linux busybox,#嵌入式Linux最小系统移植# busybox分析和移植记录

//busybox/init.c

1.init_main过程分析

init_main

parse_inittab();

file = fopen(INITTAB, "r"); //#define INITTAB "/etc/inittab" /* inittab file location */

new_init_action(a->action, command, id); //1.创建一个init-action结构,填充

//2.加入init_action_list链表

run_actions(SYSINIT);

waitfor(a, 0);

run(a);

waitpid(runpid, &status, 0);

delete_init_action(a);

run_actions(WAIT);

waitfor(a, 0);

run(a);

waitpid(runpid, &status, 0);

delete_init_action(a);

run_actions(ONCE);

run(a);

delete_init_action(a);

while (1) {

run_actions(RESPAWN);

if (a->pid == 0) {

a->pid = run(a);/

run_actions(ASKFIRST);

if (a->pid == 0) {

a->pid = run(a);

"

Please press Enter to activate this console. ";

wpid = wait(NULL);

while (wpid > 0) {

a->pid = 0;

}

}

}

2.new_init_action举例分析

new_init_action(ASKFIRST, bb_default_login_shell, VC_2);

new_init_action(ASKFIRST, "-/bin/sh", "/dev/tty2");

//查找init_action_list中是否已经存在要添加的init_action结构

//存在,则覆盖

for (a = last = init_action_list; a; a = a->next) {

/* don't enter action if it's already in the list,

* but do overwrite existing actions */

if ((strcmp(a->command, command) == 0)

&& (strcmp(a->terminal, cons) == 0)

) {

a->action = action;

return;

}

last = a;

}

//不存在,则创建

new_action = xzalloc(sizeof(struct init_action));

if (last) {

last->next = new_action;

} else {

init_action_list = new_action;

}

#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"

const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL;

# define VC_2 "/dev/tty2"

#define ASKFIRST 0x004

3.inittab格式

# Format for each entry: :::

# :The contents of this field are appended to "/dev/" and used as-is.

# : Valid actions include: sysinit, respawn, askfirst, wait, once,

# restart, ctrlaltdel, and shutdown.

# : Specifies the process to be executed and its command line.

4.编译、安装busybox

#make menuconfig

出错:提示Makefile:1449: *** mixed implicit and normal rules. Stop.

解决:/*翻译为中文:混合的和隐含普通规则

是由于我的系统的make工具太新(系统:fedora15),make的旧版规则已经无法兼容新版。

按照以下方式,问题得到解决:

修改前:416行 config %config: scripts_basic outputmakefile FORCE

修改后:416 行 %config: scripts_basic outputmakefile FORCE

修改前:1449 行 / %/: prepare scripts FORCE

修改后:1449 行 %/: prepare scripts FORCE*/

出错:error: field 'in' has incomplete type

解决:arm-linux 交叉编译工具链

在 usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h 头文件的开头

添加缺少的头文件:

#include

出错:undefined reference to `__cpu_to_be16

解决:修改 networking/libiproute/iptunnel.c文件

在#include

后面加上

#include

#make CONFIG_PREFIX=/home/invoker/busybox/myfilesystem/ install

#cd /home/invoker/busybox/myfilesystem/

#ls

bin linuxrc sbin usr

# mkdir dev

# cd dev/

# ls /dev/console /dev/null -l

crw-------. 1 root root 5, 1 12月 4 11:51 /dev/console

crw-rw-rw-. 1 root root 1, 3 12月 4 11:50 /dev/null

# mknod console c 5 1

# mknod null c 1 3

[root@localhost dev]# ls // dev/console /dev/null

console null

//安装gibc库

[root@localhost myfilesystem]# mkdir lib

[root@localhost myfilesystem]# ls

bin dev etc lib linuxrc sbin usr

[root@localhost myfilesystem]# cd /home/invoker/tools/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/lib

[root@localhost lib]# cp *.so* /home/invoker/busybox/myfilesystem/lib -d

//到此可以生成最小文件系统

//制作yaffs2文件系统

出错:starting pid 755, tty '': '/etc/init.d/rcS' 一直卡在/etc/init.d/rcS

解决:使用Busybox默认配置,Open(etc/inittab) = NULL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值