minix/releasetools/arm_sdimage.sh
Ben Gras 5acaa0814f 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
2013-03-07 14:29:27 +00:00

108 lines
2.4 KiB
Bash
Executable file

#!/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 <<END_FSTAB
/dev/c0d0p1s0 / mfs rw 0 1
/dev/c0d0p1s2 /usr mfs rw 0 2
/dev/c0d0p1s1 /home mfs rw 0 2
END_FSTAB
rm -f $DESTDIR/SETS.*
${CROSS_TOOLS}/nbpwd_mkdb -V 0 -p -d $DESTDIR $DESTDIR/etc/master.passwd
set -x
umount $MP_MINIX/home || true
umount $MP_MINIX/usr || true
umount $MP_MINIX || true
umount $MP_BOOT || true
losetup -d $LOOP || true
losetup $LOOP $IMG
${CROSS_TOOLS}/nbmkfs.mfs ${LOOP}p5
${CROSS_TOOLS}/nbmkfs.mfs ${LOOP}p6
${CROSS_TOOLS}/nbmkfs.mfs ${LOOP}p7
mkdir -p $MP_BOOT
mount ${LOOP}p1 $MP_BOOT
mkdir -p ${MP_MINIX}
mount ${LOOP}p5 ${MP_MINIX}
mkdir -p ${MP_MINIX}/home
mkdir -p ${MP_MINIX}/usr
mount ${LOOP}p6 ${MP_MINIX}/home
mount ${LOOP}p7 ${MP_MINIX}/usr
cp releasetools/uEnv.txt releasetools/cmdline.txt $MP_BOOT
${CROSS_PREFIX}objcopy ${OBJ}/kernel/kernel -O binary ${OBJ}/kernel.bin
cp ${OBJ}/kernel.bin $MP_BOOT
set -x
rsync -a $DESTDIR/ $MP_MINIX/
for f in vm rs pm sched vfs ds mfs pfs init
do
cp ${OBJ}/servers/$f/$f ${OBJ}/$f.elf
${CROSS_PREFIX}strip -s ${OBJ}/$f.elf
cp ${OBJ}/$f.elf $MP_BOOT
done
for f in tty memory log
do
cp ${OBJ}/drivers/$f/$f ${OBJ}/$f.elf
${CROSS_PREFIX}strip -s ${OBJ}/$f.elf
cp ${OBJ}/$f.elf $MP_BOOT
done
# Unmount disk image
sync
umount $MP_MINIX/home
umount $MP_MINIX/usr
umount $MP_MINIX
umount $MP_BOOT
losetup -d $LOOP
$QEMU -M beaglexm -drive if=sd,cache=writeback,file=$IMG -clock unix -serial pty -vnc :1 $*