我正在尝试使用buildroot构建嵌入式系统。一切似乎都很好用。所有模块均已启动,系统运行稳定。问题是/etc/init.d/rcS在系统初始化期间没有启动。如果我手动运行它,一切都正常。我在我的inittab文件中有它。
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
null::sysinit:/bin/mount -t proc proc /proc
null::sysinit:/bin/mount -o remount,rw /
null::sysinit:/bin/mkdir -p /dev/pts
null::sysinit:/bin/mkdir -p /dev/shm
null::sysinit:/bin/mount -a
null::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
ttyFIQ0::respawn:/sbin/getty -L -n ttyFIQ0 115200 vt100 # GENERIC_SERIAL
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
null::shutdown:/etc/init.d/rcK
null::shutdown:/bin/umount -a -r
null::shutdown:/sbin/swapoff -a
你知道会出什么问题吗?
发布于 2018-05-31 18:41:19
初始化
你确定你在调用Busybox init吗?内核命令行是什么?如果没有向内核提供init=
选项,则内核将在/init
中查找可执行文件。
例如,如果busybox二进制文件驻留在/bin/busybox
中,则需要创建以下符号链接:
ln -s /bin/busybox /init
如果您希望您的初始化驻留在/sbin
中,以符合初始化选项卡,还可以在那里创建一个符号链接。请注意,如果您不挂载根目录,并且busybox仅在initramfs中运行,则内核将不会考虑init=
设置。
ln -s /bin/busybox /sbin/init
Inittab
此外,您可以尝试不使用inittab。您尝试从inittab运行的内容可能非常适合rcS
和任何后代脚本。在same source中,您可以找到示例inittab:
# Note: BusyBox init works just fine without an inittab. If no inittab is
# found, it has the following default behavior:
# ::sysinit:/etc/init.d/rcS
# ::askfirst:/bin/sh
# ::ctrlaltdel:/sbin/reboot
# ::shutdown:/sbin/swapoff -a
# ::shutdown:/bin/umount -a -r
# ::restart:/sbin/init
# tty2::askfirst:/bin/sh
# tty3::askfirst:/bin/sh
# tty4::askfirst:/bin/sh
rcS
确保/etc/init.d/rcS
是可执行的:
chmod +x chroot chroot /bin/busybox
并尝试使用:
#!/bin/busybox sh
echo "Hello world!"
请注意,这句话可能会隐藏在内核日志消息之间,因此您可能希望传递quiet
内核命令行选项来查看它是否出现。
Busybox符号链接
符号链接是否已安装到文件系统中?如果不是,那就不是灾难。确保/etc/init.d/rcS
以以下字符开头:
#!/bin/busybox sh
mkdir -pv /sbin
/bin/busybox --install -s
发布于 2019-07-06 19:10:02
除了脚本本身是可执行的并且具有正确的shebang行之外,还需要在启用CONFIG_BINFMT_SCRIPT
选项的情况下编译内核。
CONFIG_BINFMT_SCRIPT:
Say Y here if you want to execute interpreted scripts starting with
#! followed by the path to an interpreter.
You can build this support as a module; however, until that module
gets loaded, you cannot run scripts. Thus, if you want to load this
module from an initramfs, the portion of the initramfs before loading
this module must consist of compiled binaries only.
Most systems will not boot if you say M or N here. If unsure, say Y.
如果没有此选项,您可能会收到错误消息can't run '/etc/init.d/rcS': Exec format error
。
发布于 2014-11-26 16:29:08
从给出的信息来看,一切看起来都是正确的。
以下是一些值得尝试的东西:
检查您的rcS脚本的所有权。
注释掉rcS中的所有内容,并添加一些非常简单的内容:
echo "This worked“> /tmp/test
您的脚本中可能存在与启动竞争条件相关的内容,导致其退出。我还想知道您的脚本是否启动了syslogd。
https://stackoverflow.com/questions/27143885
复制相似问题