diff options
author | Nora Björklund <nora.bjorklund@enea.com> | 2016-03-01 10:20:02 +0100 |
---|---|---|
committer | Martin Borg <martin.borg@enea.com> | 2016-03-09 15:46:05 +0100 |
commit | 0536cea1e0321e5fe0a05f427c45e77c1a704f82 (patch) | |
tree | a19e2d7d6365f2a23684e1ee6a7098f1c208285e | |
parent | db78f81cae04e2d041bf8f7abe9ddb0431ef42ec (diff) | |
download | meta-enea-bsp-ppc-0536cea1e0321e5fe0a05f427c45e77c1a704f82.tar.gz |
pramfs-init: add recipe
pramfs-init is a RRECCOMMEND to pramfs, that helps mount FS to PRAM.
Signed-off-by: Nora Björklund <nora.bjorklund@enea.com>
Signed-off-by: Martin Borg <martin.borg@enea.com>
-rw-r--r-- | recipes-kernel/pramfs-init/files/pramfs_init | 74 | ||||
-rw-r--r-- | recipes-kernel/pramfs-init/pramfs-init_1.0.bb | 20 |
2 files changed, 94 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/sh | ||
2 | #set -e | ||
3 | |||
4 | echo "Setting up pramfs" | ||
5 | |||
6 | # ensure the required binaries are present | ||
7 | #[ -x /sbin/modprobe ] || exit 1 | ||
8 | [ -x /bin/mount ] || exit 1 | ||
9 | [ -x /bin/grep ] || exit 1 | ||
10 | [ -x /bin/cat ] || exit 1 | ||
11 | [ -x /bin/sed ] || exit 1 | ||
12 | |||
13 | #modprobe pramfs | ||
14 | mkdir -p /mnt/pram | ||
15 | |||
16 | case "$1" in | ||
17 | start) | ||
18 | # Figure out RAM for pramfs | ||
19 | # This requires a kernel cmdline resevation of PRAMFS physmem | ||
20 | # in format memmap=16M$0x7000000 | ||
21 | grep memmap /proc/cmdline > /dev/null | ||
22 | if [ $? -eq 0 ]; then | ||
23 | addr=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\2/' < /proc/cmdline) | ||
24 | size=$(sed 's/.*memmap=\([^ ]*\)\$\([^ ]*\).*/\1/' < /proc/cmdline) | ||
25 | |||
26 | if [ -d /seed ]; then | ||
27 | echo "Init new pramfs" | ||
28 | mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
29 | cp /seed/* /mnt/pram | ||
30 | echo "0" > /mnt/pram/kcount | ||
31 | else | ||
32 | echo "Mounting old pramfs" | ||
33 | mount -t pramfs -o physaddr=$addr,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
34 | if [ $? -ne 0 ]; then | ||
35 | echo "Mounting old pramfs failed, zeroing" | ||
36 | mount -t pramfs -o physaddr=$addr,init=$size,bs=1k none /mnt/pram > /dev/null 2>&1 | ||
37 | if [ $? -ne 0 ]; then | ||
38 | echo "All attempts to mount pramfs has failed, exiting" | ||
39 | rm -fr /mnt/pram | ||
40 | exit 1 | ||
41 | fi | ||
42 | echo "0" > /mnt/pram/kcount | ||
43 | fi | ||
44 | fi | ||
45 | |||
46 | # echo "* Setting up kexec" | ||
47 | # kexec -l --reuse-cmdline --initrd=/mnt/pram/initramfs.cpio.gz /mnt/pram/vmlinuz | ||
48 | |||
49 | # Calculate number of boots | ||
50 | export KCOUNT=$(expr $(cat /mnt/pram/kcount) + 1) | ||
51 | echo $KCOUNT > /mnt/pram/kcount | ||
52 | else | ||
53 | KCOUNT="no-mem" | ||
54 | echo "Can't find memory area for pram fs" | ||
55 | rm -fr /mnt/pram | ||
56 | fi | ||
57 | |||
58 | echo "PRAMFS boot count: $KCOUNT" | ||
59 | # echo "kexec -e to kexec and keep persistent files in /mnt/pram" | ||
60 | ;; | ||
61 | stop) | ||
62 | echo | ||
63 | ;; | ||
64 | restart) | ||
65 | $0 stop | ||
66 | $0 start | ||
67 | ;; | ||
68 | *) | ||
69 | echo "usage: $0 { start | stop | restart }" >&2 | ||
70 | exit 1 | ||
71 | ;; | ||
72 | esac | ||
73 | |||
74 | 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 @@ | |||
1 | DESCRIPTION = "Pramfs init scripts" | ||
2 | SECTION = "init" | ||
3 | LICENSE = "BSD" | ||
4 | SRC_URI = "file://pramfs_init" | ||
5 | PR = "r0" | ||
6 | |||
7 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=4d92cd373abda3937c2bc47fbc49d690 \ | ||
8 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
9 | |||
10 | PACKAGE_ARCH = "all" | ||
11 | |||
12 | do_install() { | ||
13 | install -d ${D}${sysconfdir}/init.d/ | ||
14 | install -m 0755 ${WORKDIR}/pramfs_init ${D}${sysconfdir}/init.d/pramfs_init | ||
15 | } | ||
16 | |||
17 | inherit update-rc.d | ||
18 | |||
19 | INITSCRIPT_NAME = "pramfs_init" | ||
20 | INITSCRIPT_PARAMS = "start 99 5 2 . stop 19 0 1 6 ." | ||