Kernel panic - not syncing: No working init found. Try passing init= option to kernel.

使用buildroot编译的文件系统烧写到nandflash中,提示错误:

 

 

 No working init found. Try passing init= option to kernel.

提示:参考“Documentation/init.txt”文档:

Some high-level reasons for failure (listed roughly in order of execution) to load the init binary are:
A) Unable to mount root FS 无法加载rootfs
B) init binary doesn't exist on rootfs init二进制文件不存在
C) broken console device 控制台设备断开
D) binary exists but dependencies not available 依赖项不存在
E) binary cannot be loaded 二级制文件无法被加载

Detailed explanations:
0) Set "debug" kernel parameter (in bootloader config file or CONFIG_CMDLINE)
to get more detailed kernel messages.
A) make sure you have the correct root FS type
(and root= kernel parameter points to the correct partition),
required drivers such as storage hardware (such as SCSI or USB!)
and filesystem (ext3, jffs2 etc.) are builtin (alternatively as modules,
to be pre-loaded by an initrd)
C) Possibly a conflict in console= setup --> initial console unavailable.
E.g. some serial consoles are unreliable due to serial IRQ issues (e.g.
missing interrupt-based configuration).
Try using a different console= device or e.g. netconsole= .
D) e.g. required library dependencies of the init binary such as
/lib/ld-linux.so.2 missing or broken. Use readelf -d <INIT>|grep NEEDED
to find out which libraries are required.
E) make sure the binary's architecture matches your hardware.
E.g. i386 vs. x86_64 mismatch, or trying to load x86 on ARM hardware.
In case you tried loading a non-binary file here (shell script?),
you should make sure that the script specifies an interpreter in its shebang
header line (#!/...) that is fully working (including its library
dependencies). And before tackling scripts, better first test a simple
non-script binary such as /bin/sh and confirm its successful execution.
To find out more, add code to init/main.c to display kernel_execve()s
return values.

我的问题是:文件系统下没有对应的init文件,内核启动找不到初始化入口,无法启动init进程

 

 解决办法:制作init的软链接文件

ln -s bin/busybox init

拓展:

init 程序是由内核启动的第一个用户空间程序(带有 PID 号 1),它负责启动用户空间服务和程序(例如:Web 服务器、图形应用程序、其他网络服务器等)。 Buildroot 允许使用三种不同类型的初始化系统,可以在“System configuration”选项下的 “Init system”进行选择:

  • 第一种是“BusyBox”。BusyBox 实现了基本的 init 程序,对于大多数嵌入式系统而言, 这已经足够了。启用“BR2_INIT_BUSYBOX”将确保 BusyBox 会生成并安装其 init 程序。这 是 Buildroot 的默认解决方案。BusyBox init 程序会在启动时去读取/etc/inittab 文件,以了解需 要处理的内容。 除了挂载一些重要的文件系统之外,默认的 inittab 的主要工作是启动/etc/init.d/rcS shell 脚本,并启动一个 getty 程序(提供登录提示)。
  • 第二种是“systemV”。该解决方案使用传统的 sysvinit 程序,位于 Buildroot 目录 packag e/sysvinit,这是大多数桌面 Linux 发行版使用的解决方案,直到它们被切换到更新的替代版本 (例如 Upstart 或 Systemd)。Sysvinit 同样使用 inittab 文件(其语法与 BusyBox 中的语法略有不 同)。与此 init 解决方案一起安装的默认 inittab 位于 package/sysvinit/inittab。
  • 第三种是“systemd”。systemd 是用于 Linux 的新一代 init 系统。它的功能远远超过传统 的 init 程序:强大的并行处理能力、使用 socket 和 D-Bus 激活启动服务、按需启动守护程序、 使用 Linux 控制组跟踪进程、支持对系统状态进行快照和还原等等。systemd 在相对复杂的嵌入 式系统上很有用,例如需要 D-Bus 和服务之间相互通信的系统。值得注意的是 systemd 带来了 大量的大型依赖项:dbus、udev 等。

 

 

 

 

 

 

 

posted @ 2022-08-05 16:10  不明白就去明白  阅读(4255)  评论(0编辑  收藏  举报