本文共 1264 字,大约阅读时间需要 4 分钟。
前提:我所使用的 busybox 版本为 1.5.01. 如何设置时区?设置环境变量 TZ 即可。需要注意的有:(1) 如果要设置时区为东八区(CST), 可以将 TZ 设置为 UTC-8(不含双引号)。UTC -8 表示“本地时间-8 之后等于 UTC” 而不是“UTC 时间-8之后等于本地时间”。根据 info tzset。(2) 程序如果是从 /etc/inittab 中以 respawn 方式启动,则在 /etc/profile 中设置 TZ 对程序无效。我的解决方法是在程序开头用代码设置一下时区,调用 setenv 函数即可。info setenv 获得更多帮助信息。2. busybox /etc/inittab格式<id>:<runlevels>:<action>:<process>合法的 action 包括
sysinit, respawn, askfirst, wait, once, restart, ctrlaltdel, and shutdown.
执行顺序 sysinit: init 等待所有此类进程完成. wait : init 等待进程完成. once : init 不等待其完成. respawn : 当进程退出时,自动重新运行之。 所有的 action 依照其在 inittab 文件中出现的顺序运行。3. 如何使能/禁用 core dump 功能?启用:需要2个条件确一不可。 编译时通过 make menuconfig 指定在 init 选项下启用 CONFIG_FEATURE_INIT_COREDUMPS。 在根文件系统的根目录下创建名为 .init_enable_core 的空文件:touch /.init_enable_core。 重启系统后生效。 禁用 删去 /.init_enable_core 文件即可。重启系统后生效。 4. pthread_create 失败,说 Cannot allocate memory 这是什么原因?是因为内存不够用了。推荐使用 strace 工具来跟踪此类问题。busybox 默认的进程栈空间为 8 MB,从嵌入式应用的角度,这么大的进程栈空间有些太大了,在内存紧张的系统,很容易导致线程创建失败。修改方法有二:(1) 执行主进程前,执行命令 ulimit 来调整进程的栈空间大小:ulimit -s <栈空间大小,单位KB>(2) 直接修改 busybox 的 init.c 文件。参考 info getrlimit,或者 info setrlimit。5. 为什么 mount -t nfs 失败?请确认在 mout 选项中已经使能了 NFS 支持Location: │ │ -> Linux System Utilities │ │ -> mount (MOUNT [=y]) [*] Support mounting NFS file systems 转载地址:http://kssqi.baihongyu.com/