The kernel has two differing code paths when handling a built-in cpio versus a cpio passed to the kernel from a boot loader. When the kernel is booted with the built-in cpio it expects the /dev/console node to exist and will panic if it does not exist.
Kernel panic - not syncing: /dev/console is missing or not a character device! When the cpio is passed to the kernel via a bootloader, this behaviour is not observed. To resolve this issue, ensure any cpio that is built into the kernel is prepared with a /dev/console node. This is done by appending to the copied cpio of the INITRAMFS_IMAGE. In order to create the node to append, the task must be executed with root permission (to run mknod). As such this change creates and intermediate _prepare task between the existing _bundle and _copy tasks. Note: The default/minimal initramfs that the kernel sources gen_initramfs_list.sh generates contains this device node. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/usr/gen_initramfs_list.sh?h=master#n55 Signed-off-by: Nathan Rossi <[email protected]> --- meta/classes/kernel-initramfs.bbclass | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/meta/classes/kernel-initramfs.bbclass b/meta/classes/kernel-initramfs.bbclass index b23fb51495..135f4c8949 100644 --- a/meta/classes/kernel-initramfs.bbclass +++ b/meta/classes/kernel-initramfs.bbclass @@ -16,7 +16,8 @@ python __anonymous () { if image and bundle: # add all the tasks bb.build.addtask('do_initramfs_copy', 'do_initramfs_bundle', 'do_install', d) - bb.build.addtask('do_initramfs_bundle', 'do_deploy', 'do_initramfs_copy', d) + bb.build.addtask('do_initramfs_prepare', 'do_initramfs_bundle', 'do_initramfs_copy', d) + bb.build.addtask('do_initramfs_bundle', 'do_deploy', 'do_initramfs_prepare', d) # make the do_initramfs_copy task depend on the image do_image_complete task d.appendVarFlag('do_initramfs_copy', 'depends', ' ${INITRAMFS_IMAGE}:do_image_complete') @@ -67,6 +68,18 @@ do_initramfs_copy () { echo "Finished copy of initramfs into ./usr" } +do_initramfs_prepare[dirs] = "${B}" +fakeroot do_initramfs_prepare () { + echo "Preparing initramfs by creating required /dev/ nodes" + # append a /dev/console node, this node must be created in the rootfs + # for built-in initramfs cpios otherwise it will error with: + # Kernel panic - not syncing: /dev/console is missing or not a character device! + rm -rf ${B}/usr/append + mkdir -p ${B}/usr/append/dev + mknod -m 600 ${B}/usr/append/dev/console c 5 1 + (cd ${B}/usr/append && echo "./dev/console" | cpio -oA -H newc -F ${B}/usr/${INITRAMFS_IMAGE_NAME}.cpio) +} + do_initramfs_bundle[dirs] = "${B}" do_initramfs_bundle () { echo "Creating a kernel image with a bundled initramfs..." --- 2.19.1 -- _______________________________________________ Openembedded-core mailing list [email protected] http://lists.openembedded.org/mailman/listinfo/openembedded-core
