Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/embedded Add preliminary support for creating ...



details:   https://anonhg.NetBSD.org/src/rev/136334a27b2b
branches:  trunk
changeset: 328333:136334a27b2b
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 31 16:20:48 2014 +0000

description:
Add preliminary support for creating x86 usb sticks with mkimage.
This is untested, and just a checkpoint of the work. Image looks
ok, but I have not tried if it boots.

diffstat:

 distrib/utils/embedded/conf/amd64.conf  |   46 +++++++++++
 distrib/utils/embedded/conf/evbarm.conf |    3 +-
 distrib/utils/embedded/conf/x86.conf    |  125 ++++++++++++++++++++++++++++++++
 distrib/utils/embedded/mkimage          |   22 +++--
 4 files changed, 187 insertions(+), 9 deletions(-)

diffs (276 lines):

diff -r cadf498eedba -r 136334a27b2b distrib/utils/embedded/conf/amd64.conf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/amd64.conf    Mon Mar 31 16:20:48 2014 +0000
@@ -0,0 +1,46 @@
+# $NetBSD: amd64.conf,v 1.1 2014/03/31 16:20:49 christos Exp $
+# Amd64 customization script used by mkimage
+#
+
+board=amd64
+MACHINE=amd64
+kernel=$src/sys/arch/amd64/compile/GENERIC/netbsd
+bootfile=$release/usr/mdec/boot
+
+. ${DIR}/conf/x86.conf
+
+make_filesystems() {
+       make_filesystems_x86
+}
+
+make_fstab() {
+       make_fstab_x86
+}
+
+make_label() {
+       make_label_x86
+}
+
+customize() {
+       customize_x86
+       cat >> ${mnt}/etc/rc.conf << EOF
+wscons=YES
+devpubd=YES
+EOF
+
+}
+
+populate() {
+       if [ ! -f ${kernel} ]; then
+               echo ${PROG}: Missing ${kernel} 1>&2
+               exit 1
+       fi
+
+       echo "${bar} installing kernel ${bar}"
+       cp ${kernel} ${mnt}/netbsd
+       if [ ! -f ${bootfile} ]; then
+               echo ${PROG}: Missing ${bootfile} 1>&2
+               exit 1
+       fi
+       cp ${bootfile} ${mnt}/boot
+}
diff -r cadf498eedba -r 136334a27b2b distrib/utils/embedded/conf/evbarm.conf
--- a/distrib/utils/embedded/conf/evbarm.conf   Mon Mar 31 13:38:44 2014 +0000
+++ b/distrib/utils/embedded/conf/evbarm.conf   Mon Mar 31 16:20:48 2014 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: evbarm.conf,v 1.13 2013/11/22 11:13:54 skrll Exp $
+# $NetBSD: evbarm.conf,v 1.14 2014/03/31 16:20:49 christos Exp $
 # evbarm shared config
 #
 image=$HOME/${board}.img
 
 specialdirs="/kern /proc"
+MACHINE=evbarm
 
 swap=256
 extra=8                # spare space
diff -r cadf498eedba -r 136334a27b2b distrib/utils/embedded/conf/x86.conf
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/x86.conf      Mon Mar 31 16:20:48 2014 +0000
@@ -0,0 +1,125 @@
+# $NetBSD: x86.conf,v 1.1 2014/03/31 16:20:49 christos Exp $
+# x86 shared config
+#
+image=$HOME/${board}.img
+
+specialdirs="/kern /proc"
+
+swap=256
+extra=8                # spare space
+
+size=0         # autocompute
+netbsdid=169
+
+make_label_x86() {
+       # compute all sizes in terms of sectors
+       local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
+
+       local swapsize=$(( ${swap} * 1024 ))
+
+       local aoffset=63
+       local asize=$(( ${totalsize} - ${swapsize} - ${aoffset} ))
+
+       local swapoffset=$(( ${aoffset} + ${asize} ))
+
+       local bps=512
+       local spt=32
+       local tpc=64
+       local spc=2048
+       local cylinders=$(( ${totalsize} / ${spc} ))
+
+       cat << EOF
+type: SCSI
+disk: STORAGE DEVICE
+label: fictitious
+flags: removable
+bytes/sector: ${bps}
+sectors/track: ${spt}
+tracks/cylinder: ${tpc}
+sectors/cylinder: ${spc}
+cylinders: ${cylinders}
+total sectors: ${totalsize}
+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:   ${asize}     ${aoffset}    4.2BSD  ${fsize} ${bsize} 0  # 
+ b:   ${swapsize}  ${swapoffset} swap                         #
+ c:   ${totalsize} 0             unused      0     0          #
+ d:   ${totalsize} 0             unused      0     0          #
+EOF
+}
+
+make_fstab_x86_normal() {
+       cat > ${mnt}/etc/fstab << EOF
+# NetBSD /etc/fstab
+# See /usr/share/examples/fstab/ for more examples.
+/dev/sd0a      /               ffs     rw,log  1 1
+/dev/sd0b      none            swap    sw      0 0
+kernfs         /kern           kernfs  rw
+ptyfs          /dev/pts        ptyfs   rw
+procfs         /proc           procfs  rw
+EOF
+}
+
+# From Richard Neswold's:
+# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html
+# Also for the postfix stuff below
+make_fstab_x86_minwrites() {
+       cat > ${mnt}/etc/fstab << EOF
+# NetBSD /etc/fstab
+# See /usr/share/examples/fstab/ for more examples.
+/dev/sd0a      /                       ffs     rw,log,noatime,nodevmtime 1 1
+/dev/sd0b      none                    swap    sw                        0 0
+kernfs         /kern                   kernfs  rw
+ptyfs          /dev/pts                ptyfs   rw
+procfs         /proc                   procfs  rw
+tmpfs          /tmp                    tmpfs   rw,-s32M
+tmpfs          /var/log                tmpfs   rw,union,-s32M
+tmpfs          /var/run                tmpfs   rw,union,-s1M
+tmpfs          /var/mail               tmpfs   rw,union,-s10M
+tmpfs          /var/spool/postfix      tmpfs   rw,union,-s20M
+tmpfs          /var/db/postfix         tmpfs   rw,union,-s1M
+tmpfs          /var/chroot             tmpfs   rw,union,-s10M
+EOF
+}
+
+make_fstab_x86() {
+       if $minwrites; then
+               make_fstab_x86_minwrites
+       else
+               make_fstab_x86_normal
+       fi
+}
+
+customize_x86() {
+       cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
+       if $minwrites; then
+               mkdir ${mnt}/etc/postfix
+               (umask 022
+               sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
+                   ${mnt}/etc/postfix/master.cf)
+       fi
+       cat >> ${mnt}/etc/rc.conf << EOF
+rc_configured=YES
+hostname=${board}
+sshd=YES
+dhcpcd=YES
+EOF
+       if [ ! -f ${release}/dev/MAKEDEV ]; then
+               echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
+               exit 1
+       fi
+       echo "${bar} running MAKEDEV ${bar}"
+       ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
+           >> "$tmp/selected_sets"
+
+       echo "${bar} creating directories ${bar}"
+       mkdir ${mnt}/proc ${mnt}/kern
+}
diff -r cadf498eedba -r 136334a27b2b distrib/utils/embedded/mkimage
--- a/distrib/utils/embedded/mkimage    Mon Mar 31 13:38:44 2014 +0000
+++ b/distrib/utils/embedded/mkimage    Mon Mar 31 16:20:48 2014 +0000
@@ -1,7 +1,7 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.44 2013/09/14 12:51:27 ast Exp $
+# $NetBSD: mkimage,v 1.45 2014/03/31 16:20:48 christos Exp $
 #
-# Copyright (c) 2013 The NetBSD Foundation, Inc.
+# Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
 # This code is derived from software contributed to The NetBSD Foundation
@@ -41,10 +41,10 @@
 FDISK=${TOOL_FDISK:-fdisk}
 MAKEFS=${TOOL_MAKEFS:-makefs}
 MTREE=${TOOL_MTREE:-mtree}
+INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot}
 GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1)
 
 src="/usr/src"
-release="/usr/obj/evbarm/release"
 sets="base comp etc games man misc modules text"
 xsets="xbase xcomp xetc xfont xserver" 
 minfree="10%"
@@ -102,6 +102,7 @@
 fi
 
 . "${DIR}/conf/${h}.conf"
+release="/usr/obj/${MACHINE}/release"
 
 selected_sets="$sets"
 dsets=false
@@ -148,7 +149,7 @@
 *)     compress=false;;
 esac
 
-if [ -z "$bootonly" ]; then
+if [ -z "${bootonly}" ]; then
        echo ${bar} configuring sets ${bar}
        (echo '/set type=dir uname=root gname=wheel mode=0755'
        for i in $selected_sets; do
@@ -163,18 +164,18 @@
 customize
 populate
 
-if [ -z "$bootonly" ]; then
+if [ -z "${bootonly}" ]; then
        (cd ${mnt}; ${MTREE} -N ${release}/etc -c -k all | 
            ${MTREE} -N ${release}/etc -C -k all) >> "$tmp/selected_sets"
 fi
-if [ -n ${msdosid} ]; then
+if [ -n "${msdosid}" ]; then
        echo ${bar} Populating msdos filesystem ${bar}
        ${MAKEFS} -N ${release}/etc -t msdos \
            -O $((${init} / 2))m -s $((${boot} / 2 + ${init} / 2))m \
            ${image} ${mnt}/boot
 fi
 
-if [ -z "$bootonly" ]; then
+if [ -z "${bootonly}" ]; then
        echo ${bar} Populating ffs filesystem ${bar}
        ${MAKEFS} -N ${release}/etc -t ffs -rx \
            -O $(((${init} + ${boot} + ${swap}) / 2))m \
@@ -190,11 +191,16 @@
 echo ${bar} Adding label ${bar}
 make_label > ${tmp}/label
 ${DISKLABEL} -R -F ${image} ${tmp}/label
-if [ -n ${msdosid} ]; then
+if [ -n "${msdosid}" ]; then
        echo ${bar} Running fdisk ${bar}
        initsecs=$((${init} * 1024))
        bootsecs=$((${boot} * 1024))
        ${FDISK} -f -u -0 -s ${msdosid}/${initsecs}/${bootsecs} -F ${image}
+elif [ -n "${netbsdid}" ]; then
+       echo ${bar} Running fdisk ${bar}
+       ${FDISK} -f -i ${image}
+       ${FDISK} -f -a -u -0 -s 169/-1/-1/ ${image}
+       ${INSTALLBOOT} -f -v ${image} ${release}/usr/mdec/bootxx_ffsv1
 fi
 
 if $compress; then



Home | Main Index | Thread Index | Old Index