summaryrefslogtreecommitdiffstats
path: root/meta-yocto/recipes-core
diff options
context:
space:
mode:
authorDarren Hart <dvhart@linux.intel.com>2012-06-13 21:05:17 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-06-26 15:34:40 +0100
commitbcc04b2880b44140176e1d2dcc955a3d3942c392 (patch)
treec1b4491208579707e5e2fa4dde0bb342f4225e87 /meta-yocto/recipes-core
parent20a426b975ab6131989fb99b455fec9a39439531 (diff)
downloadpoky-bcc04b2880b44140176e1d2dcc955a3d3942c392.tar.gz
tiny-init: Basic init mechanism for poky-tiny
Currently poky-tiny images will boot and run /bin/sh, which results in error messages to the console about being unable to open the tty and job control being disabled. The shell must be session leader to open the tty, and the tty must not be /dev/console (it should be a vt or a physical tty like ttyS0), the tty is required for job control (handling signals, etc.). The goals of poky-tiny are to be an initial starting point from which to build a distribution that does what you want, and NOTHING more. This patch results in a system that boots with the virtual filesystems mounted, the local network interface up, and a shell with job control running, and a hook (/etc/rc.local) for easy customization. Nothing else. Enabling the basic busybox init, including the ability to give the controlling console to commands starting with a dash in inittab results in a 5664 byte delta (compared with 2560 bytes for enabling setsid and cttyhack). Note that the help in busybox suggests the cttyhack may be more reliable than the init support for handing over the controlling terminal. So the difference between using a standard init and just enabling the two options is about 3k, but enabling setsid and cttyhack may enable others to things besides what I am looking to do. Enabling init in both DISTRO_FEATURES and busybox is fairly trivial to do, so I think it's better to leave that as something to add if needed, rather than something to remove, as that is more consistent with the goals of poky-tiny. Thanks to Tim Bird for his suggestion to include support for rc.local by default. (From meta-yocto rev: 5ae60ed46b34cbf4ab17fe7eab3d46e2f78ee7b8) Signed-off-by: Darren Hart <dvhart@linux.intel.com> CC: Tim Bird <tim.bird@am.sony.com> CC: Thomas Frydrych <tf+lists.yocto@r-finger.com> CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> CC: Paul Eggleton <paul.eggleton@linux.intel.com> CC: Phil Blundell <philb@gnu.org> CC: Khem Raj <raj.khem@gmail.com> CC: Koen Kooi <koen@dominion.thruhere.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-yocto/recipes-core')
-rw-r--r--meta-yocto/recipes-core/tiny-init/files/init21
-rw-r--r--meta-yocto/recipes-core/tiny-init/files/rc.local.sample23
-rw-r--r--meta-yocto/recipes-core/tiny-init/tiny-init.bb28
3 files changed, 72 insertions, 0 deletions
diff --git a/meta-yocto/recipes-core/tiny-init/files/init b/meta-yocto/recipes-core/tiny-init/files/init
new file mode 100644
index 0000000000..bf2817d099
--- /dev/null
+++ b/meta-yocto/recipes-core/tiny-init/files/init
@@ -0,0 +1,21 @@
1#!/bin/sh
2
3# Mount the Linux kernel virtual filesystems
4mount none -t proc /proc
5mount none -t sysfs /sys
6mkdir /dev/pts
7mount none -t devpts /dev/pts
8
9ifup lo
10
11# Allow for distro or local customizations
12if [ -f /etc/rc.local ] ; then
13 source /etc/rc.local
14fi
15
16# Become session leader and try to find a real tty (e.g. ttyS0)
17while true; do
18 setsid cttyhack sh
19 echo "Console sh exited with $?, respawning..."
20 sleep 1
21done
diff --git a/meta-yocto/recipes-core/tiny-init/files/rc.local.sample b/meta-yocto/recipes-core/tiny-init/files/rc.local.sample
new file mode 100644
index 0000000000..d9e198a200
--- /dev/null
+++ b/meta-yocto/recipes-core/tiny-init/files/rc.local.sample
@@ -0,0 +1,23 @@
1#!/bin/sh
2
3# Start services and customize the boot process here.
4echo "Running /etc/rc.local..."
5
6# Use init scripts included with packages such as dropbear
7#/etc/init.d/dropbear start
8
9# Spawn a getty manually
10#setsid /sbin/getty 115200 ttyS2
11
12# Print a banner
13#echo "You are running a poky-tiny image brought to you by the Yocto Project."
14
15# Setup a debugging environment
16#mkdir /debugfs
17#mount none -t debugfs /debugfs
18
19# Load modules (note: linux-yocto-tiny does not have module support by default)
20#modprobe yourdriver
21
22# DO NOT run any long running tasks or loops as these will delay
23# the /init script and the console shell.
diff --git a/meta-yocto/recipes-core/tiny-init/tiny-init.bb b/meta-yocto/recipes-core/tiny-init/tiny-init.bb
new file mode 100644
index 0000000000..f5892ed472
--- /dev/null
+++ b/meta-yocto/recipes-core/tiny-init/tiny-init.bb
@@ -0,0 +1,28 @@
1SUMMARY = "Poky-tiny init"
2DESCRIPTION = "Basic init system for poky-tiny"
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
5
6PR = "r0"
7
8RDEPENDS_${PN} = "busybox"
9
10SRC_URI = "file://init \
11 file://rc.local.sample \
12 "
13
14do_configure() {
15 :
16}
17
18do_compile() {
19 :
20}
21
22do_install() {
23 install -d ${D}${sysconfdir}
24 install -m 0755 ${WORKDIR}/init ${D}
25 install -m 0755 ${WORKDIR}/rc.local.sample ${D}${sysconfdir}
26}
27
28FILES_${PN} = "/init ${sysconfdir}/rc.local.sample"