Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/distrib/utils/embedded Adjust mkimage to handle RPI. From sk...
details: https://anonhg.NetBSD.org/src/rev/87148e02742a
branches: trunk
changeset: 783962:87148e02742a
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 13 20:57:18 2013 +0000
description:
Adjust mkimage to handle RPI. From skrll@
diffstat:
distrib/utils/embedded/conf/rpi.conf | 109 ++++++++++++++++++
distrib/utils/embedded/conf/usermode.conf | 78 +++++++++++++
distrib/utils/embedded/mkimage | 173 ++++++++++++++---------------
3 files changed, 271 insertions(+), 89 deletions(-)
diffs (truncated from 447 to 300 lines):
diff -r b1fd3c5229b3 -r 87148e02742a distrib/utils/embedded/conf/rpi.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/rpi.conf Sun Jan 13 20:57:18 2013 +0000
@@ -0,0 +1,109 @@
+# $NetBSD: rpi.conf,v 1.1 2013/01/13 20:57:18 christos Exp $
+# Raspberry PI customization script used by mkimage
+#
+image=$HOME/rpi.img
+
+firmwaredir=$src/external/broadcom/rpi-firmware/dist
+firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
+
+sets="base etc games man misc modules tests text"
+setsdir=$obj/evbarm/media
+kerneldir=$src/sys/arch/evbarm/compile/RPI
+specialdirs="/kern /proc"
+
+size=2048
+overhead=8
+
+tmp=/tmp/rpi.disklabel.$$
+
+make_filesystems() {
+ cat > ${tmp} << EOF
+type: SCSI
+disk: STORAGE DEVICE
+label: fictitious
+flags: removable
+bytes/sector: 512
+sectors/track: 32
+tracks/cylinder: 64
+sectors/cylinder: 2048
+cylinders: 7460
+total sectors: 2097152
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0 # microseconds
+track-to-track seek: 0 # microseconds
+drivedata: 0
+
+8 partitions:
+# size offset fstype [fsize bsize cpg/sgs]
+ a: 1449984 647168 4.2BSD 2048 16384 0 #
+ b: 524288 122880 swap #
+ d: 2097152 0 unused 0 0 #
+ e: 114688 8192 MSDOS #
+EOF
+ ${sudo} disklabel -R ${vnddev} ${tmp}
+ ${sudo} fdisk -f -u -0 -s 12/8192/114688 -F ${image}
+ ${sudo} newfs /dev/r${vnddev}a
+ ${sudo} newfs_msdos /dev/r${vnddev}e
+ ${sudo} mount /dev/${vnddev}a ${mnt}
+ ${sudo} mkdir ${mnt}/boot
+ ${sudo} mount_msdos /dev/${vnddev}e ${mnt}/boot
+}
+
+make_fstab() {
+${sudo} cat > ${mnt}/etc/fstab << EOF
+# NetBSD /etc/fstab
+# See /usr/share/examples/fstab/ for more examples.
+/dev/ld0a / ffs rw,log 1 1
+/dev/ld0b none swap sw 0 0
+/dev/ld0e /boot msdos rw 1 1
+kernfs /kern kernfs rw
+ptyfs /dev/pts ptyfs rw
+procfs /proc procfs rw
+EOF
+}
+
+customize() {
+
+ ${sudo} cat > ${mnt}/etc/rc.conf << EOF
+sshd=YES
+dhcpcd=YES
+mdnsd=YES
+wscons=YES
+EOF
+
+ ${sudo} cat > ${mnt}/boot/cmdline.txt << EOF
+console=fb
+#fb=1280x1024 # to select a mode, otherwise EDID will be tried and fallback to
+#fb=disable # to disable fb completely
+EOF
+
+ echo "${bar} installing firmware files ${bar}"
+ (cd ${mnt}/boot &&
+ for f in ${firmwarefiles}; do
+ echo $f
+ ${sudo} cp ${firmwaredir}/${f} .
+ done
+ )
+
+ if [ ! -f ${kerneldir}/kernel.img ]; then
+ echo ${PROG}: Missing ${kerneldir}/kernel.img 1>&2
+ exit 1
+ fi
+ echo "${bar} installing kernel ${bar}"
+ ${sudo} cp ${kerneldir}/kernel.img ${mnt}/boot
+
+ if [ ! -f ${mnt}/dev/MAKEDEV ]; then
+ echo ${PROG}: Missing ${mnt}/dev/MAKEDEV 1>&2
+ exit 1
+ fi
+ echo "${bar} running MAKEDEV ${bar}"
+ (cd ${mnt}/dev && ${sudo} sh MAKEDEV all)
+}
+
+cleanup() {
+ rm -f ${tmp}
+ ${sudo} umount ${mnt}/boot
+}
diff -r b1fd3c5229b3 -r 87148e02742a distrib/utils/embedded/conf/usermode.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/usermode.conf Sun Jan 13 20:57:18 2013 +0000
@@ -0,0 +1,78 @@
+# $NetBSD: usermode.conf,v 1.1 2013/01/13 20:57:18 christos Exp $
+# NetBSD/usermode customization script used by mkimage
+custom=custom
+image=usermode.img
+overhead=8 # in MB
+sets="base etc modules"
+setsdir=/usr/build/release/$(uname -m)/binary/sets
+size=0 # in MB
+specialdirs="/kern /proc"
+usermodedirs="/var.cow /etc.cow /root.cow /pkgs"
+
+make_filesystems() {
+ ${sudo} newfs /dev/r${vnddev}a
+ ${sudo} mount /dev/${vnddev}a ${mnt}
+}
+
+make_fstab() {
+${sudo} cat > ${mnt}/etc/fstab << EOF
+# NetBSD/usermode /etc/fstab
+/dev/ld0a / ffs ro 1 1
+/dev/ld1a /pkgs ffs ro 1 2
+kernfs /kern kernfs rw
+ptyfs /dev/pts ptyfs rw
+procfs /proc procfs rw
+# mount /root as tmpfs on top of existing dir
+tmpfs /root.cow tmpfs rw,-s2M 0 0
+/root.cow /root union rw,hidden 0 0
+# mount /etc as tmpfs on top of existing dir
+tmpfs /etc.cow tmpfs rw,-s12M 0 0
+/etc.cow /etc union rw,hidden 0 0
+# mount /var as tmpfs on top of existing dir
+tmpfs /var.cow tmpfs rw,-s32M 0 0
+/var.cow /var union rw,hidden - -
+tmpfs /tmp tmpfs rw,-s32M 0 0
+/dev/cd0a /cdrom cd9660 ro,noauto
+EOF
+}
+
+customize() {
+${sudo} cat > ${mnt}/etc/rc.conf << EOF
+# make sure we have the right rw filesystem at boot
+critical_filesystems_local="/var.cow /var /etc.cow /etc /root.cow /root"
+
+# Add local overrides below
+#
+dhcpcd=YES
+sshd=YES
+EOF
+
+echo "${bar} making extra directories ${bar}"
+for d in ${usermodedirs}; do
+ ${sudo} mkdir -p ${mnt}/${d}
+done
+
+echo "${bar} customising /var/tmp ${bar}"
+${sudo} rm -rf ${mnt}/var/tmp
+(cd ${mnt}/var && ${sudo} ln -s /tmp tmp)
+
+# package-related stuff
+(cat ${mnt}/etc/csh.cshrc;echo "setenv PKG_DBDIR /usr/pkg/.dbdir") > ${tmp}
+${sudo} mv ${tmp} ${mnt}/etc/csh.cshrc
+(cat ${mnt}/etc/profile;echo "export PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
+${sudo} mv ${tmp} ${mnt}/etc/profile
+(echo "PKG_DBDIR=/usr/pkg/.dbdir") > ${tmp}
+${sudo} mv ${tmp} ${mnt}/etc/mk.conf
+(cd ${mnt}/usr && ${sudo} ln -s /pkgs/usr/pkg pkg)
+
+# last, customisation stage
+if [ -d ${custom} ]; then
+ echo "${bar} user customisations from files in ${custom} ${bar}"
+ (cd ${custom} && ${sudo} pax -rwpe . ${mnt})
+fi
+
+df ${mnt}
+}
+
+cleanup() {
+}
diff -r b1fd3c5229b3 -r 87148e02742a distrib/utils/embedded/mkimage
--- a/distrib/utils/embedded/mkimage Sun Jan 13 19:56:13 2013 +0000
+++ b/distrib/utils/embedded/mkimage Sun Jan 13 20:57:18 2013 +0000
@@ -1,6 +1,6 @@
#! /bin/sh
-# $NetBSD: mkimage,v 1.3 2012/02/29 04:49:50 agc Exp $
+# $NetBSD: mkimage,v 1.4 2013/01/13 20:57:18 christos Exp $
# Copyright (c) 2012 Alistair Crooks <agc%NetBSD.org@localhost>
# All rights reserved.
@@ -70,6 +70,12 @@
# find the size of the gzipped files in a .tgz archive
sizeone() {
+ if [ ! -f "$1" ]
+ then
+ echo "$PROG: Missing set $1" 1>&2
+ echo 0
+ return;
+ fi
case "$1" in
*.tgz|*.tar.gz)
tar tvzf "$1" | awk '{ tot += $5 } END { print tot }'
@@ -83,31 +89,66 @@
esac
}
+usage() {
+ cat << EOF 1>&2
+Usage: $PROG [-S <setsdir>] [-c <custom-files-dir>] [-h <host-arch>] [-s <size>]
+EOF
+exit 1
+}
+
+finish() {
+ cleanup
+ ${sudo} umount ${mnt}
+ ${sudo} vnconfig -u ${vnddev}
+}
+
+trap finish 0 1 2 3 15
+DIR="$(dirname "$0")"
+PROG="$(basename "$0")"
bar="==="
-custom=custom
-h=usermode1.$(uname -n)
-image=usermode.img
-overhead=8 # in MB
-sets="base etc modules"
-setsdir=/usr/build/release/$(uname -m)/binary/sets
-size=0 # in MB
-specialdirs="/kern /proc"
-usermodedirs="/var.cow /etc.cow /root.cow /pkgs"
-sudo="sudo"
+sudo=
+mnt="/tmp/image.$$"
+src="/usr/src"
+obj="/usr/obj"
-while [ $# -gt 0 ]; do
- case "$1" in
- -S) setsdir=$2; shift ;;
- -c) custom=$2; shift ;;
- -h) h=$2; shift ;;
- -s) size=$2; shift ;;
- -x) set -x ;;
- *) break ;;
+# First pass for options to get the host
+OPTS="S:c:h:s:x"
+while getopts "$OPTS" f
+do
+ case $f in
+ h) h="$OPTARG";;
+ *) ;;
esac
- shift
done
-if [ $# -gt 0 ]; then
+if [ -z "$h" ]
+then
+ usage
+fi
+
+if [ ! -f "${DIR}/${h}.conf" ]
+then
+ echo $PROG: ${DIR}/${h}.conf is not present 1>&2
+ exit 1
+fi
+
+. "${DIR}/${h}.conf"
+
+OPTIND=1
+while getopts "$OPTS" f
+do
+ case $f in
+ S) setsdir="$OPTARG";;
+ c) custom="$OPTARG";;
+ h) ;;
+ s) size="$OPTARG";;
+ x) set -x;;
+ *) ;;
+ esac
+done
Home |
Main Index |
Thread Index |
Old Index