Skip to contentSkip to conversation

initramfs-debug: add simple init script for debugging

PATCH In review Dmitry Eremin-Solenikov 2 participants 4 messages Apr 2, 2015 – Apr 3, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 initramfs-debug: add simple init script for debugging

Add a tiny simple debug script that will mount all available virtual file systems and then execute a shell.

---
 .../recipes-bsp/initrdscripts/files/init-debug.sh  | 31 ++++++++++++++++++++++
 .../initrdscripts/initramfs-debug_1.0.bb           | 14 ++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh
 create mode 100644 meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb
meta-initramfs/recipes-bsp/initrdscripts/files/init-debug.sh new file +31 -0
new file mode 100644
index 0000000..7edbd70
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+do_mount_fs() {
+	grep -q "$1" /proc/filesystems || return
+	test -d "$2" || mkdir -p "$2"
+	mount -t "$1" "$1" "$2"
+}
+
+do_mknod() {
+	test -e "$1" || mknod "$1" "$2" "$3" "$4"
+}
+
+mkdir -p /proc
+mount -t proc proc /proc
+
+do_mount_fs sysfs /sys
+do_mount_fs debugfs /sys/kernel/debug
+do_mount_fs devtmpfs /dev
+do_mount_fs devpts /dev/pts
+do_mount_fs tmpfs /dev/shm
+
+mkdir -p /run
+mkdir -p /var/run
+
+do_mknod /dev/console c 5 1
+do_mknod /dev/null c 1 3
+do_mknod /dev/zero c 1 5
+
+exec sh </dev/console >/dev/console 2>/dev/console 
meta-initramfs/recipes-bsp/initrdscripts/initramfs-debug_1.0.bb new file +14 -0
new file mode 100644
index 0000000..b7defff
@@ -0,0 +1,14 @@
+SUMMARY = "Extremely basic live image init script"
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+SRC_URI = "file://init-debug.sh"
+
+S = "${WORKDIR}"
+
+do_install() {
+        install -m 0755 ${WORKDIR}/init-debug.sh ${D}/init
+}
+
+inherit allarch
+
+FILES_${PN} += " /init "
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/2 initramfs-debug-image: tiny debugging initramfs image

A tiny initramfs image suitable for initial bringup of the hardware.

---
 .../recipes-bsp/images/initramfs-debug-image.bb     | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb
meta-initramfs/recipes-bsp/images/initramfs-debug-image.bb new file +21 -0
new file mode 100644
index 0000000..8e87c19
@@ -0,0 +1,21 @@
+# Simple initramfs image. Mostly used for live images.
+DESCRIPTION = "Small image capable of booting a device. The kernel includes \
+the Minimal RAM-based Initial Root Filesystem (initramfs), which one can use \
+to check the hardware efficiently."
+
+PACKAGE_INSTALL = "initramfs-debug busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
+
+# Do not pollute the initrd image with rootfs features
+IMAGE_FEATURES = ""
+
+export IMAGE_BASENAME = "initramfs-debug-image"
+IMAGE_LINGUAS = ""
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}"
+inherit core-image
+
+IMAGE_ROOTFS_SIZE = "8192"
+
+BAD_RECOMMENDATIONS += "busybox-syslog"
Signature · 1 line
2.1.4
#2 lore raw

Re: [meta-initramfs][PATCH 2/2] initramfs-debug-image: tiny debugging initramfs image

Quoted 3 lines · Dmitry Eremin-Solenikov

A tiny initramfs image suitable for initial bringup of the hardware.

I've been using core-image-minimal for this purpose. What you think is missing there?

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750
#3 lore raw
In reply to Dmitry Eremin-Solenikov

Hello,

Quoted 4 lines · Dmitry Eremin-Solenikov

Add a tiny simple debug script that will mount all available virtual file systems and then execute a shell.

I think this is easy to be accomplished with a module for initramfs-framework[1].

1. http://git.openembedded.org/openembedded-core/tree/meta/recipes-core/initrdscripts

When we designed it at O.S. Systems we tried to make it very easy to extend and we use it with some products with good success. It also includes a debug module which allow for fancy stuff like to support to dynamic debugging of initramfs using bootparam in following format:

shell : starts a shell before and after each module
shell=before:<module> : starts a shell before <module> is loaded and run shell=after:<module> : starts a shell after <module> is loaded and run

shell-debug : run set -x as soon as possible
shell-debug=before:<module> : run set -x before <module> is loaded and run shell-debug=after:<module> : run set -x after <module> is loaded and run

The missing aspect is the debugfs which is not mounted but could be added as a module.

Please take a look on it as avoid work duplication is a health effort :)

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750