From 5acaa0814f561557b94a693175a579d0f0fc9ef2 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Wed, 6 Mar 2013 19:27:47 +0100 Subject: [PATCH] kernel, ramdisk: some boot unification To use the new SD building script, Linux has to be configured with loop.max_part=15 on the command line (or set at module load time) to make the loopback device see the partitions. This commit removes a lot of differences between the ARM and x86 boot ramdisk and rc scripts. It changes the ARM build from running from ramdisk to requiring a full filesystem on the SD image and booting into it. . ramdisk: remove some arm-only utilities only used for running from the shell . remove ARM-only rc.arm, proto.arm.small, ttys and mylogin.sh boot-time ramdisk files . change kernel to add "arch" variable so userland knows what we're running on from sysenv . make ARM use the regular ramdisk rc file, changed to distinguish i386-only and ARM-only drivers; requires rootdevname to be set . change /etc/rc and /usr/etc/rc to start i386-only drivers only on i386 systems . change the kernel/arm to have a special case for the memory driver to load it higher so it can be bigger . add uEnv.txt, cmdline.txt and a for now highly linux-dependent SD preparation script arm_sdimage.sh to the git repository in releasetools/ Change-Id: I68910ba4e96ee80f7a12b65e48b5d39b43ca6397 --- docs/UPDATING | 7 ++ drivers/ramdisk/Makefile | 18 +++--- drivers/ramdisk/mylogin.sh | 4 -- drivers/ramdisk/proto | 13 +++- drivers/ramdisk/proto.arm.small | 40 ------------ drivers/ramdisk/proto.common.etc | 6 +- drivers/ramdisk/rc | 39 ++++++----- drivers/ramdisk/rc.arm | 18 ------ drivers/ramdisk/ttys | 44 ------------- etc/rc | 68 +++++++++++++------ etc/usr/rc | 24 +++++-- include/minix/const.h | 1 + kernel/arch/earm/pre_init.c | 14 +++- kernel/arch/i386/pre_init.c | 3 + releasetools/arm_sdimage.sh | 108 +++++++++++++++++++++++++++++++ releasetools/cmdline.txt | 1 + releasetools/uEnv.txt | 21 ++++++ 17 files changed, 265 insertions(+), 164 deletions(-) delete mode 100755 drivers/ramdisk/mylogin.sh delete mode 100644 drivers/ramdisk/proto.arm.small delete mode 100755 drivers/ramdisk/rc.arm delete mode 100755 drivers/ramdisk/ttys create mode 100755 releasetools/arm_sdimage.sh create mode 100644 releasetools/cmdline.txt create mode 100644 releasetools/uEnv.txt diff --git a/docs/UPDATING b/docs/UPDATING index 852355151..5913b9b96 100644 --- a/docs/UPDATING +++ b/docs/UPDATING @@ -1,3 +1,10 @@ +20130306: + For people building ARM images, the procedure has changed + a bit. You need a full FS to boot now. In short, you need + to use the new in-tree script to make a full SD image. See + http://wiki.minix3.org/en/DevelopersGuide/MinixOnARM + for details. + 20130201: Replace our native ln with NetBSD version. diff --git a/drivers/ramdisk/Makefile b/drivers/ramdisk/Makefile index 808885208..d34b27eb3 100644 --- a/drivers/ramdisk/Makefile +++ b/drivers/ramdisk/Makefile @@ -29,23 +29,25 @@ ETC= system.conf master.passwd EXTRA= rc PROTO_FILES= proto.common.etc proto.common.dynamic proto.dev PROG_DRIVERS= -PROG_COMMANDS= mount fsck.mfs sh service -PROG_SERVERS= mfs +PROG_COMMANDS= mount fsck.mfs sh service loadramdisk sysenv +PROG_SERVERS= mfs procfs PROG_BIN= PROG_SBIN= PROG_USR.BIN= PROG_USR.SBIN= +.if ${MKSMALL} != "yes" +RAMDISK_SMALL= 1 +.endif + .if ${MACHINE_ARCH} == "i386" ETC+= rs.single EXTRA+= PROG_DRIVERS+= at_wini floppy pci -PROG_COMMANDS+= cdprobe loadramdisk sysenv -PROG_SERVERS+= procfs +PROG_COMMANDS+= cdprobe PROG_USR.SBIN+= pwd_mkdb .if ${MKSMALL} != "yes" -RAMDISK_SMALL= 1 PROG_DRIVERS+= ahci PROG_DRIVERS+= virtio_blk PROG_SERVERS+= ext2 @@ -58,11 +60,7 @@ PROG_DRIVERS+= acpi .endif # ${MACHINE_ARCH} == "i386" .if ${MACHINE_ARCH} == "earm" -EXTRA+= rc.arm mylogin.sh ttys -PROG_DRIVERS+= fb mmc tty gpio -PROG_COMMANDS+= cp dd getty time sleep stty umount -PROG_BIN+= cat ls rm sync -PROTO= proto.arm.small +PROG_DRIVERS+= mmc .endif # ${MACHINE_ARCH} == "earm" .if ${LDSTATIC} == "-dynamic" diff --git a/drivers/ramdisk/mylogin.sh b/drivers/ramdisk/mylogin.sh deleted file mode 100755 index 621fb1b7a..000000000 --- a/drivers/ramdisk/mylogin.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -echo Welcome -export PATH=$PATH:/mnt/bin:/mnt/usr/bin -exec /bin/sh diff --git a/drivers/ramdisk/proto b/drivers/ramdisk/proto index 9ca3f192a..99659d46f 100644 --- a/drivers/ramdisk/proto +++ b/drivers/ramdisk/proto @@ -2,22 +2,29 @@ boot 0 0 d--755 0 0 bin d--755 0 0 +#ifdef __i386__ cdprobe ---755 0 0 cdprobe +#endif + sysenv ---755 0 0 sysenv #if RAMDISK_SMALL == 1 fsck.mfs ---755 0 0 fsck.mfs #endif mount ---755 0 0 mount sh ---755 0 0 sh service ---755 0 0 service - sysenv ---755 0 0 sysenv $ sbin d--755 0 0 +#ifdef __i386__ floppy ---755 0 0 floppy ahci ---755 0 0 ahci virtio_blk ---755 0 0 virtio_blk at_wini ---755 0 0 at_wini #if RAMDISK_SMALL == 1 ext2 ---755 0 0 ext2 +#endif +#endif +#ifdef __arm__ + mmc ---755 0 0 mmc #endif mfs ---755 0 0 mfs procfs ---755 0 0 procfs @@ -27,10 +34,12 @@ d--755 0 0 loadramdisk ---755 0 0 loadramdisk $ sbin d--755 0 0 +#ifdef __i386__ #if RAMDISK_INC_ACPI == 1 - acpi ---755 0 0 acpi + acpi ---755 0 0 acpi #endif pci ---755 0 0 pci +#endif $ $ dev d--755 0 0 diff --git a/drivers/ramdisk/proto.arm.small b/drivers/ramdisk/proto.arm.small deleted file mode 100644 index aebb616fc..000000000 --- a/drivers/ramdisk/proto.arm.small +++ /dev/null @@ -1,40 +0,0 @@ -boot -0 0 -d--755 0 0 - bin d--755 0 0 - mount ---755 0 0 mount - umount ---755 0 0 umount - sh ---755 0 0 sh - service ---755 0 0 service - getty ---755 0 0 getty - stty ---755 0 0 stty - cp ---755 0 0 cp - sync ---755 0 0 sync - sleep ---755 0 0 sleep - dd ---755 0 0 dd - time ---755 0 0 time - cat ---755 0 0 cat - ls ---755 0 0 ls - fsck.mfs ---755 0 0 fsck.mfs - $ - sbin d--755 0 0 - fb ---755 0 0 fb - mmc ---755 0 0 mmc - mfs ---755 0 0 mfs - gpio ---755 0 0 gpio - - $ - mnt d--755 0 0 - $ - gpio d--755 0 0 - $ - usr d--755 0 0 - bin d--755 0 0 - login ---755 0 0 mylogin.sh - $ - $ - dev d--755 0 0 -#include "proto.dev" - $ -#include "proto.common.etc" -$ diff --git a/drivers/ramdisk/proto.common.etc b/drivers/ramdisk/proto.common.etc index a4878c969..03b287005 100644 --- a/drivers/ramdisk/proto.common.etc +++ b/drivers/ramdisk/proto.common.etc @@ -4,12 +4,8 @@ pwd.db ---644 0 0 pwd.db spwd.db ---600 0 0 spwd.db master.passwd ---600 0 0 master.passwd -#if defined(__i386__) rc ---755 0 0 rc +#if defined(__i386__) rs.single ---755 0 0 rs.single -#endif -#if defined(__arm__) - rc ---755 0 0 rc.arm - ttys ---644 0 0 ttys #endif $ diff --git a/drivers/ramdisk/rc b/drivers/ramdisk/rc index 895f80d1b..fc8dd15ba 100755 --- a/drivers/ramdisk/rc +++ b/drivers/ramdisk/rc @@ -7,23 +7,32 @@ exec /dev/null diff --git a/drivers/ramdisk/rc.arm b/drivers/ramdisk/rc.arm deleted file mode 100755 index cda7e7740..000000000 --- a/drivers/ramdisk/rc.arm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# LSC FIXME quick hack, we should retink the rc script so we do not -# get two different script -set -e - - -exec >/dev/log -exec 2>/dev/log -exec &2 "Usage: $0 [-saf] start|stop|down" @@ -114,8 +124,17 @@ start) then . "$RC_TZ" fi - # Try to read the hardware real-time clock, otherwise do it manually. - readclock || intr date -q + if [ $ARCH = i386 ] + then + # Try to read the hardware real-time clock, otherwise do it manually. + readclock || intr date -q + fi + + if [ $ARCH = earm ] + then + date 201301010000 + fi + # Initialize files. >/etc/utmp # /etc/utmp keeps track of logins @@ -187,32 +206,39 @@ start) cp /usr/lib/em* /usr/lib/cpp* /lib esac - echo -n "Starting hotplugging infrastructure... " - rm -f /var/run/devmand.pid - devmand -d /etc/devmand -d /usr/pkg/etc/devmand & - echo "done." + if [ $ARCH = i386 ] + then + echo -n "Starting hotplugging infrastructure... " + rm -f /var/run/devmand.pid + devmand -d /etc/devmand -d /usr/pkg/etc/devmand & + echo "done." + fi # Things should be alright now. ;; down|stop) sync - if [ -f /var/run/devmand.pid ] + if [ $ARCH = i386 ] then - kill -INT `cat /var/run/devmand.pid` - # without this delay the following will - # be printed in the console - # RS: devman not running? - sleep 1 - fi - # - # usbd needs to be stopped exactly - # at this stage(before stopping devman - # and after stopping the services - # stated by devmand) - if [ -x /usr/pkg/etc/rc.d/usbd ] - then - /usr/pkg/etc/rc.d/usbd stop + if [ -f /var/run/devmand.pid ] + then + kill -INT `cat /var/run/devmand.pid` + # without this delay the following will + # be printed in the console + # RS: devman not running? + sleep 1 + fi + # + # usbd needs to be stopped exactly + # at this stage(before stopping devman + # and after stopping the services + # stated by devmand) + if [ -x /usr/pkg/etc/rc.d/usbd ] + then + /usr/pkg/etc/rc.d/usbd stop + fi fi + # Tell RS server we're going down. service shutdown ;; diff --git a/etc/usr/rc b/etc/usr/rc index 523ac9122..6c14e3e5d 100644 --- a/etc/usr/rc +++ b/etc/usr/rc @@ -3,6 +3,16 @@ RANDOM_FILE=/usr/adm/random.dat LOCAL_FILE=/usr/etc/rc.local +ARCH="`sysenv arch`" + +if [ ! "$ARCH" ] +then # Older kernels do not provide an arch sysenv variable. + # We assume we are on x86 then, as existing systems with + # kernel and userland (i.e. this script) unsynchronized + # will be x86. + ARCH=i386 +fi + # Get $SERVICES_DIRS . /etc/rc.conf @@ -139,12 +149,18 @@ start) else up inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE fi - up -n printer -dev /dev/lp -period 10HZ + up -n ipc - # start VirtualBox time sync driver if the device is there - if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then - up -n vbox -period 10HZ + + if [ $ARCH = i386 ] + then + up -n printer -dev /dev/lp -period 10HZ + # start VirtualBox time sync driver if the device is there + if grep '^[^ ]* [^ ]* 80EE:CAFE ' /proc/pci >/dev/null; then + up -n vbox -period 10HZ + fi fi + echo . # Network initialization. diff --git a/include/minix/const.h b/include/minix/const.h index 65378668c..2c9a2ec94 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -145,6 +145,7 @@ #define INVAL_GID ((gid_t) -1) /* invalid gid value */ #define SERVARNAME "cttyline" +#define ARCHVARNAME "arch" #define SERBAUDVARNAME "cttybaud" /* Bits for s_flags in the privilege structure. */ diff --git a/kernel/arch/earm/pre_init.c b/kernel/arch/earm/pre_init.c index 626aa6a53..af878ce3e 100644 --- a/kernel/arch/earm/pre_init.c +++ b/kernel/arch/earm/pre_init.c @@ -123,7 +123,16 @@ void setup_mbi(multiboot_info_t *mbi) int i; for (i = 0; i < MB_MODS_NR; ++i) { mb_modlist[i].mod_start = MB_MODS_BASE + i * MB_MODS_ALIGN; - mb_modlist[i].mod_end = mb_modlist[i].mod_start + MB_MODS_ALIGN - 1; mb_modlist[i].cmdline = 0; + mb_modlist[i].mod_end = mb_modlist[i].mod_start + MB_MODS_ALIGN - 1; + mb_modlist[i].cmdline = 0; + + if (i == 5) { + /* LSC HACK: Special case for memory, it is actually loaded at the + * end, so that it can grow without having to change the + * alignment of everything. currently reserving 64MiB */ + mb_modlist[i].mod_start = 0x96800000; + mb_modlist[i].mod_end = mb_modlist[i].mod_start + (0x04000000) - 1; + } } /* Final 'module' is actually a string holding the boot cmdline */ @@ -193,6 +202,9 @@ void get_parameters(u32_t ebx, kinfo_t *cbi) } } + /* let higher levels know what we are booting on */ + mb_set_param(cbi->param_buf, ARCHVARNAME, "earm", cbi); + /* round user stack down to leave a gap to catch kernel * stack overflow; and to distinguish kernel and user addresses * at a glance (0xf.. vs 0xe..) diff --git a/kernel/arch/i386/pre_init.c b/kernel/arch/i386/pre_init.c index 8701a21a7..c2531b166 100644 --- a/kernel/arch/i386/pre_init.c +++ b/kernel/arch/i386/pre_init.c @@ -153,6 +153,9 @@ void get_parameters(u32_t ebx, kinfo_t *cbi) } } + /* let higher levels know what we are booting on */ + mb_set_param(cbi->param_buf, ARCHVARNAME, "i386", cbi); + /* round user stack down to leave a gap to catch kernel * stack overflow; and to distinguish kernel and user addresses * at a glance (0xf.. vs 0xe..) diff --git a/releasetools/arm_sdimage.sh b/releasetools/arm_sdimage.sh new file mode 100755 index 000000000..720296d28 --- /dev/null +++ b/releasetools/arm_sdimage.sh @@ -0,0 +1,108 @@ +#!/bin/bash +set -e + +MP_MINIX=/tmp/minix +MP_BOOT=/tmp/minixboot + +: ${ARCH=evbearm-el} +: ${OBJ=../obj.arm} +: ${CROSS_TOOLS=${OBJ}/"tooldir.`uname -s`-`uname -r`-`uname -m`"/bin} +: ${CROSS_PREFIX=${CROSS_TOOLS}/arm-elf32-minix-} +: ${DESTDIR=${OBJ}/destdir.$ARCH} +: ${FSTAB=$DESTDIR/etc/fstab} +: ${LOOP=/dev/loop0} +: ${EMPTYIMG=minix_arm_sd_empty.img} +: ${IMG=minix_arm_sd.img} +: ${QEMU=/opt/bin/qemu-system-arm} + +BUILDSH=build.sh + +if [ ! -f $BUILDSH ] +then echo "Please invoke me from the root source dir, where $BUILDSH is." + exit 1 +fi + +if [ ! -f ${EMPTYIMG}.bz2 ] +then echo Retrieving $EMPTYIMG + wget http://www.minix3.org/arm/${EMPTYIMG}.bz2 +fi + +if [ ! -f $IMG ] +then echo decompressing $EMPTYIMG onto $IMG + bzip2 -d -k ${EMPTYIMG}.bz2 + mv $EMPTYIMG $IMG +fi + +# remove fstab and generated pw db +rm -rf $DESTDIR/etc + +sh build.sh -j4 -m$ARCH -O $OBJ -D $DESTDIR -u distribution + +cat >$FSTAB <