From 0536cea1e0321e5fe0a05f427c45e77c1a704f82 Mon Sep 17 00:00:00 2001 From: Nora Björklund Date: Tue, 1 Mar 2016 10:20:02 +0100 Subject: pramfs-init: add recipe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pramfs-init is a RRECCOMMEND to pramfs, that helps mount FS to PRAM. Signed-off-by: Nora Björklund Signed-off-by: Martin Borg --- recipes-kernel/pramfs-init/files/pramfs_init | 74 +++++++++++++++++++++++++++ recipes-kernel/pramfs-init/pramfs-init_1.0.bb | 20 ++++++++ 2 files changed, 94 insertions(+) create mode 100644 recipes-kernel/pramfs-init/files/pramfs_init create mode 100644 recipes-kernel/pramfs-init/pramfs-init_1.0.bb diff --git a/recipes-kernel/pramfs-init/files/pramfs_init b/recipes-kernel/pramfs-init/files/pramfs_init new file mode 100644 index 0000000..a3314f5 --- /dev/null +++ b/recipes-kernel/pramfs-init/files/pramfs_init @@ -0,0 +1,74 @@ +#!/bin/sh +#set -e + +echo "Setting up pramfs" + +# ensure the required binaries are present +#[ -x /sbin/modprobe ] || exit 1 +[ -x /bin/mount ] || exit 1 +[ -x /bin/grep ] || exit 1 +[ -x /bin/cat ] || exit 1 +[ -x /bin/sed ] || exit 1 + +#modprobe pramfs +mkdir -p /mnt/pram + +case "$1" in + start) + # Figure out RAM for pramfs + # This requires a kernel cmdline resevation of PRAMFS physmem + # in format memmap=16M$0x7000000 + grep memmap /proc/cmdline > /dev/null + if [ $? -eq 0 ]; then + addr=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\2/' < /proc/cmdline) + size=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\1/' < /proc/cmdline) + + if [ -d /seed ]; then + echo "Init new pramfs" + mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 + cp /seed/* /mnt/pram + echo "0" > /mnt/pram/kcount + else + echo "Mounting old pramfs" + mount -t pramfs -o physaddr=$addr,bs=1k none /mnt/pram > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "Mounting old pramfs failed, zeroing" + mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 + if [ $? -ne 0 ]; then + echo "All attempts to mount pramfs has failed, exiting" + rm -fr /mnt/pram + exit 1 + fi + echo "0" > /mnt/pram/kcount + fi + fi + + # echo "* Setting up kexec" + # kexec -l --reuse-cmdline --initrd=/mnt/pram/initramfs.cpio.gz /mnt/pram/vmlinuz + + # Calculate number of boots + export KCOUNT=$(expr $(cat /mnt/pram/kcount) + 1) + echo $KCOUNT > /mnt/pram/kcount + else + KCOUNT="no-mem" + echo "Can't find memory area for pram fs" + rm -fr /mnt/pram + fi + + echo "PRAMFS boot count: $KCOUNT" + # echo "kexec -e to kexec and keep persistent files in /mnt/pram" + ;; + stop) + echo + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 { start | stop | restart }" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/recipes-kernel/pramfs-init/pramfs-init_1.0.bb b/recipes-kernel/pramfs-init/pramfs-init_1.0.bb new file mode 100644 index 0000000..d9b36a7 --- /dev/null +++ b/recipes-kernel/pramfs-init/pramfs-init_1.0.bb @@ -0,0 +1,20 @@ +DESCRIPTION = "Pramfs init scripts" +SECTION = "init" +LICENSE = "BSD" +SRC_URI = "file://pramfs_init" +PR = "r0" + +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ + file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +PACKAGE_ARCH = "all" + +do_install() { + install -d ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/pramfs_init ${D}${sysconfdir}/init.d/pramfs_init +} + +inherit update-rc.d + +INITSCRIPT_NAME = "pramfs_init" +INITSCRIPT_PARAMS = "start 99 5 2 . stop 19 0 1 6 ." -- cgit v1.2.3-54-g00ecf