Tue Nov 28 02:56:44 2017 UTC ()
Be more precise about exactly what fails when something does.

Relying upon set -e to abort things is sort of OK (it is not
a recommended option to use in general - too many odd special cases),
but only if user can work out from the "build failed" what actually
went wrong.

Tested only on amd64 build (for this, i386 is the same) - if anyone
has problems on builds for other systems, please let me know.  However
the changes affect only failure paths, the most likely problem would
be for a build to fail to halt on an error, and I hope I have avoided
that.  There should be no difference at all to error-free builds.


(kre)
diff -r1.68 -r1.69 src/distrib/utils/embedded/mkimage
diff -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf
diff -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf
diff -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf
diff -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf

cvs diff -r1.68 -r1.69 src/distrib/utils/embedded/mkimage (switch to unified diff)

--- src/distrib/utils/embedded/mkimage 2017/11/28 00:24:08 1.68
+++ src/distrib/utils/embedded/mkimage 2017/11/28 02:56:44 1.69
@@ -1,274 +1,280 @@ @@ -1,274 +1,280 @@
1#!/bin/sh 1#!/bin/sh
2# $NetBSD: mkimage,v 1.68 2017/11/28 00:24:08 kre Exp $ 2# $NetBSD: mkimage,v 1.69 2017/11/28 02:56:44 kre Exp $
3# 3#
4# Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. 4# Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
5# All rights reserved. 5# All rights reserved.
6# 6#
7# This code is derived from software contributed to The NetBSD Foundation 7# This code is derived from software contributed to The NetBSD Foundation
8# by Christos Zoulas. 8# by Christos Zoulas.
9# 9#
10# Redistribution and use in source and binary forms, with or without 10# Redistribution and use in source and binary forms, with or without
11# modification, are permitted provided that the following conditions 11# modification, are permitted provided that the following conditions
12# are met: 12# are met:
13# 1. Redistributions of source code must retain the above copyright 13# 1. Redistributions of source code must retain the above copyright
14# notice, this list of conditions and the following disclaimer. 14# notice, this list of conditions and the following disclaimer.
15# 2. Redistributions in binary form must reproduce the above copyright 15# 2. Redistributions in binary form must reproduce the above copyright
16# notice, this list of conditions and the following disclaimer in the 16# notice, this list of conditions and the following disclaimer in the
17# documentation and/or other materials provided with the distribution. 17# documentation and/or other materials provided with the distribution.
18# 3. Neither the name of The NetBSD Foundation nor the names of its 18# 3. Neither the name of The NetBSD Foundation nor the names of its
19# contributors may be used to endorse or promote products derived 19# contributors may be used to endorse or promote products derived
20# from this software without specific prior written permission. 20# from this software without specific prior written permission.
21# 21#
22# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32# POSSIBILITY OF SUCH DAMAGE. 32# POSSIBILITY OF SUCH DAMAGE.
33# 33#
34 34
35# 35#
36# Makes a bootable image for the host architecture given. 36# Makes a bootable image for the host architecture given.
37# The host specific functions are pulled in from a /bin/sh script in the 37# The host specific functions are pulled in from a /bin/sh script in the
38# "conf" directory, and is expected to provide the following shell 38# "conf" directory, and is expected to provide the following shell
39# functions, which are called in the following order: 39# functions, which are called in the following order:
40# 40#
41# - make_fstab: Creates the host's /etc/fstab with / on ${rootdev}. 41# - make_fstab: Creates the host's /etc/fstab with / on ${rootdev}.
42# If -m is given, a number of directories are put on a tmpfs RAM disk 42# If -m is given, a number of directories are put on a tmpfs RAM disk
43# - customize: After unpacking the sets, this gets the system to 43# - customize: After unpacking the sets, this gets the system to
44# a working state, e. g. by setting up /etc/rc.conf and /dev 44# a working state, e. g. by setting up /etc/rc.conf and /dev
45# - populate: Add common goods like kernel and bootloader 45# - populate: Add common goods like kernel and bootloader
46# - make_label: Prints disklabel to stdout 46# - make_label: Prints disklabel to stdout
47# 47#
48 48
49set -e 49set -e
50 50
51DIR="$(cd "$(dirname "$0")" && pwd)" 51DIR="$(cd "$(dirname "$0")" && pwd)"
52PROG="$(basename "$0")" 52PROG="$(basename "$0")"
53 53
54MAKE=${TOOL_MAKE:-make} 54MAKE=${TOOL_MAKE:-make}
55DISKLABEL=${TOOL_DISKLABEL:-disklabel} 55DISKLABEL=${TOOL_DISKLABEL:-disklabel}
56FDISK=${TOOL_FDISK:-fdisk} 56FDISK=${TOOL_FDISK:-fdisk}
57MAKEFS=${TOOL_MAKEFS:-makefs} 57MAKEFS=${TOOL_MAKEFS:-makefs}
58MTREE=${TOOL_MTREE:-mtree} 58MTREE=${TOOL_MTREE:-mtree}
59INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot} 59INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot}
60MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE:-mkubootimage} 60MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE:-mkubootimage}
61GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1) 61GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1)
62 62
63src="/usr/src" 63src="/usr/src"
64sets="base comp etc games man misc modules tests text" 64sets="base comp etc games man misc modules tests text"
65xsets="xbase xcomp xetc xfont xserver"  65xsets="xbase xcomp xetc xfont xserver"
66minfree="10%" 66minfree="10%"
67bar="===" 67bar="==="
68 68
69tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")" 69tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")"
70mnt="${tmp}/mnt" 70mnt="${tmp}/mnt"
71mkdir -p "${mnt}/etc" "${mnt}/dev" 71mkdir -p "${mnt}/etc" "${mnt}/dev"
72 72
73trap "cleanup" 0 1 2 3 15 73trap "cleanup" 0 1 2 3 15
74 74
75cleanup() { 75cleanup() {
76 case "$tmp" in 76 case "$tmp" in
77 "${TMPDIR:-/tmp}/$PROG."*) rm -fr "$tmp";; 77 "${TMPDIR:-/tmp}/$PROG."*) rm -fr "$tmp";;
78 esac 78 esac
79} 79}
80 80
 81fail() {
 82 IFS=' '
 83 echo >&2 "${PROG}: $*"
 84 exit 1
 85}
 86
81getsize() { 87getsize() {
82 set -- $(ls -l $1) 88 set -- $(ls -l $1)
83 echo $5 89 echo $5
84} 90}
85 91
86getsectors() { 92getsectors() {
87 case "$1" in 93 case "$1" in
88 *g) 94 *g)
89 m=1073741824 95 m=1073741824
90 v=${1%g} 96 v=${1%g}
91 ;; 97 ;;
92 *m) 98 *m)
93 m=1048576 99 m=1048576
94 v=${1%m} 100 v=${1%m}
95 ;; 101 ;;
96 *k) 102 *k)
97 m=1024 103 m=1024
98 v=${1%k} 104 v=${1%k}
99 ;; 105 ;;
100 *[0-9b]) 106 *[0-9b])
101 m=1 107 m=1
102 v=${1%b} 108 v=${1%b}
103 ;; 109 ;;
104 esac 110 esac
105 echo $((m * v / 512)) 111 echo $((m * v / 512))
106} 112}
107 113
108usage() { 114usage() {
109 cat << EOF 1>&2 115 cat << EOF 1>&2
110Usage: $PROG -h <host-arch> [-bdmx] [-B <byte-order>] [-K <kerneldir>] [-S <srcdir>] [-D <destdir>] [-c <custom-files-dir>] [-s <Mb size>] [<image>] 116Usage: $PROG -h <host-arch> [-bdmx] [-B <byte-order>] [-K <kerneldir>] [-S <srcdir>] [-D <destdir>] [-c <custom-files-dir>] [-s <Mb size>] [<image>]
111 117
112-b Boot only, no sets loaded 118-b Boot only, no sets loaded
113-r root device kind (sd, wd, ld) 119-r root device kind (sd, wd, ld)
114-d Add the debug sets 120-d Add the debug sets
115-m Optimize the OS installation to mimimize disk writes for SSDs 121-m Optimize the OS installation to mimimize disk writes for SSDs
116-x Load the X sets too, not just the base ones 122-x Load the X sets too, not just the base ones
117EOF 123EOF
118 exit 1 124 exit 1
119} 125}
120 126
121# First pass for options to get the host and src directories 127# First pass for options to get the host and src directories
122OPTS="B:D:K:S:bc:dh:mr:s:x" 128OPTS="B:D:K:S:bc:dh:mr:s:x"
123while getopts "$OPTS" f 129while getopts "$OPTS" f
124do 130do
125 case $f in 131 case $f in
126 h) h="$OPTARG";; 132 h) h="$OPTARG";;
127 S) src="$OPTARG";; 133 S) src="$OPTARG";;
128 *) ;; 134 *) ;;
129 esac 135 esac
130done 136done
131 137
132if [ -z "$h" ] 138if [ -z "$h" ]
133then 139then
134 usage 140 usage
135fi 141fi
136 142
137if [ ! -f "${DIR}/conf/${h}.conf" ] 143if [ ! -f "${DIR}/conf/${h}.conf" ]
138then 144then
139 echo $PROG: ${DIR}/conf/${h}.conf is not present 1>&2 145 echo $PROG: ${DIR}/conf/${h}.conf is not present 1>&2
140 exit 1 146 exit 1
141fi 147fi
142 148
143resize=false 149resize=false
144 150
145. "${DIR}/conf/${h}.conf" 151. "${DIR}/conf/${h}.conf"
146release="/usr/obj/${MACHINE}/release" 152release="/usr/obj/${MACHINE}/release"
147 153
148selected_sets="$sets" 154selected_sets="$sets"
149dsets_p=false 155dsets_p=false
150xsets_p=false 156xsets_p=false
151minwrites=false 157minwrites=false
152rootdev=ld 158rootdev=ld
153endian= 159endian=
154 160
155OPTIND=1 161OPTIND=1
156while getopts "$OPTS" f 162while getopts "$OPTS" f
157do 163do
158 case $f in 164 case $f in
159 B) endian="-B $OPTARG";; 165 B) endian="-B $OPTARG";;
160 D) release="$OPTARG";; 166 D) release="$OPTARG";;
161 K) kernel="$OPTARG";; 167 K) kernel="$OPTARG";;
162 S) ;; 168 S) ;;
163 b) bootonly=true;; 169 b) bootonly=true;;
164 d) dsets_p=true 170 d) dsets_p=true
165 selected_sets="$selected_sets debug" 171 selected_sets="$selected_sets debug"
166 if $xsets_p; then 172 if $xsets_p; then
167 selected_sets="$selected_sets xdebug" 173 selected_sets="$selected_sets xdebug"
168 fi 174 fi
169 ;; 175 ;;
170 c) custom="$OPTARG";; 176 c) custom="$OPTARG";;
171 h) ;; 177 h) ;;
172 m) minwrites=true;; 178 m) minwrites=true;;
173 r) rootdev="$OPTARG";; 179 r) rootdev="$OPTARG";;
174 s) size="$OPTARG";; 180 s) size="$OPTARG";;
175 x) xsets_p=true 181 x) xsets_p=true
176 selected_sets="$selected_sets $xsets" 182 selected_sets="$selected_sets $xsets"
177 if $dsets_p; then 183 if $dsets_p; then
178 selected_sets="$selected_sets xdebug" 184 selected_sets="$selected_sets xdebug"
179 fi 185 fi
180 ;; 186 ;;
181 *) usage;; 187 *) usage;;
182 esac 188 esac
183done 189done
184 190
185shift $(( $OPTIND - 1 )) 191shift $(( $OPTIND - 1 ))
186if [ -n "$1" ]; then 192if [ -n "$1" ]; then
187 # take the next argument as being the image name 193 # take the next argument as being the image name
188 image="$1" 194 image="$1"
189 shift 195 shift
190fi 196fi
191 197
192case "$image" in 198case "$image" in
193*.gz) compress=true; image="${image%.gz}";; 199*.gz) compress=true; image="${image%.gz}";;
194*) compress=false;; 200*) compress=false;;
195esac 201esac
196 202
197if [ -z "${bootonly}" ]; then 203if [ -z "${bootonly}" ]; then
198 echo ${bar} configuring sets ${bar} 204 echo ${bar} configuring sets ${bar}
199 (cat "${release}/etc/mtree/NetBSD.dist" 205 (cat "${release}/etc/mtree/NetBSD.dist"
200 for i in $selected_sets; do 206 for i in $selected_sets; do
201 s="${release}/etc/mtree/set.$i" 207 s="${release}/etc/mtree/set.$i"
202 if [ -f "$s" ]; then 208 if [ -f "$s" ]; then
203 cat "$s" 209 cat "$s"
204 fi 210 fi
205 done) > "$tmp/selected_sets" 211 done) > "$tmp/selected_sets"
206fi 212fi
207 213
208make_fstab 214make_fstab
209customize 215customize
210populate 216populate
211 217
212if [ -n "${msdosid}" ]; then 218if [ -n "${msdosid}" ]; then
213 echo ${bar} Populating msdos filesystem ${bar} 219 echo ${bar} Populating msdos filesystem ${bar}
214 ${MAKEFS} -N ${release}/etc -t msdos -o volume_label=NETBSD \ 220 ${MAKEFS} -N ${release}/etc -t msdos -o volume_label=NETBSD \
215 -O $((${init} / 2))m -s $((${boot} / 2))m \ 221 -O $((${init} / 2))m -s $((${boot} / 2))m \
216 ${image} ${mnt}/boot 222 ${image} ${mnt}/boot
217fi 223fi
218 224
219if [ -z "${bootonly}" ]; then 225if [ -z "${bootonly}" ]; then
220 echo ${bar} Populating ffs filesystem ${bar} 226 echo ${bar} Populating ffs filesystem ${bar}
221 ${MAKEFS} -rx ${endian} -N ${release}/etc -t ffs \ 227 ${MAKEFS} -rx ${endian} -N ${release}/etc -t ffs \
222 -O ${ffsoffset} \ 228 -O ${ffsoffset} \
223 -o d=4096,f=8192,b=65536 -b $((${extra}))m \ 229 -o d=4096,f=8192,b=65536 -b $((${extra}))m \
224 -F "$tmp/selected_sets" ${image} "${release}" "${mnt}" 230 -F "$tmp/selected_sets" ${image} "${release}" "${mnt}"
225fi 231fi
226 232
227if [ "${size}" = 0 ]; then 233if [ "${size}" = 0 ]; then
228 size="$(getsize "${image}")" 234 size="$(getsize "${image}")"
229fi 235fi
230newsize=$((${size} / 2 / 1024)) 236newsize=$((${size} / 2 / 1024))
231compare=$((${newsize} * 2 * 1024)) 237compare=$((${newsize} * 2 * 1024))
232while [ "${compare}" != "${size}" ] 238while [ "${compare}" != "${size}" ]
233do  239do
234 size="$((size + size - compare))"  240 size="$((size + size - compare))"
235 newsize="$((${size} / 2 / 1024))" 241 newsize="$((${size} / 2 / 1024))"
236 compare="$((${newsize} * 2 * 1024))" 242 compare="$((${newsize} * 2 * 1024))"
237done  243done
238 244
239if [ -n "${msdosid}" ]; then 245if [ -n "${msdosid}" ]; then
240 echo ${bar} Running fdisk ${bar} 246 echo ${bar} Running fdisk ${bar}
241 initsecs=$((${init} * 1024)) 247 initsecs=$((${init} * 1024))
242 bootsecs=$((${boot} * 1024)) 248 bootsecs=$((${boot} * 1024))
243 ${FDISK} -f -i ${image} 249 ${FDISK} -f -i ${image}
244 ${FDISK} -f -a -u -0 -s ${msdosid}/${initsecs}/${bootsecs} -F ${image} 250 ${FDISK} -f -a -u -0 -s ${msdosid}/${initsecs}/${bootsecs} -F ${image}
245 if [ -z "${bootonly}" ]; then 251 if [ -z "${bootonly}" ]; then
246 ffsstart="$(getsectors ${ffsoffset})" 252 ffsstart="$(getsectors ${ffsoffset})"
247 imagesize="$(getsize "${image}")" 253 imagesize="$(getsize "${image}")"
248 imagesecs="$(getsectors ${imagesize})" 254 imagesecs="$(getsectors ${imagesize})"
249 ffssize="$(expr ${imagesecs} - ${ffsstart})" 255 ffssize="$(expr ${imagesecs} - ${ffsstart})"
250 ${FDISK} -f -u -1 -s 169/${ffsstart}/${ffssize} -F ${image} 256 ${FDISK} -f -u -1 -s 169/${ffsstart}/${ffssize} -F ${image}
251 fi 257 fi
252 258
253 echo ${bar} Adding label ${bar} 259 echo ${bar} Adding label ${bar}
254 make_label > ${tmp}/label 260 make_label > ${tmp}/label
255 ${DISKLABEL} -R -F ${image} ${tmp}/label 261 ${DISKLABEL} -R -F ${image} ${tmp}/label
256elif [ -n "${netbsdid}" ]; then 262elif [ -n "${netbsdid}" ]; then
257 echo ${bar} Adding label ${bar} 263 echo ${bar} Adding label ${bar}
258 make_label > ${tmp}/label 264 make_label > ${tmp}/label
259 ${DISKLABEL} -R -F ${image} ${tmp}/label 265 ${DISKLABEL} -R -F ${image} ${tmp}/label
260 266
261 echo ${bar} Running fdisk ${bar} 267 echo ${bar} Running fdisk ${bar}
262 ${FDISK} -f -i ${image} 268 ${FDISK} -f -i ${image}
263 ${FDISK} -f -a -u -0 -s 169/${init} ${image} 269 ${FDISK} -f -a -u -0 -s 169/${init} ${image}
264 ${INSTALLBOOT} -f -v ${image} ${release}/usr/mdec/bootxx_ffsv1 270 ${INSTALLBOOT} -f -v ${image} ${release}/usr/mdec/bootxx_ffsv1
265fi 271fi
266 272
267if $compress; then 273if $compress; then
268 echo ${bar} Compressing image ${bar} 274 echo ${bar} Compressing image ${bar}
269 rm -f "${image}.gz" 275 rm -f "${image}.gz"
270 ${GZIP_CMD} -9 ${image} 276 ${GZIP_CMD} -9 ${image}
271 image="${image}.gz" 277 image="${image}.gz"
272fi 278fi
273 279
274echo ${bar} Image is ${image} ${bar} 280echo ${bar} Image is ${image} ${bar}

cvs diff -r1.19 -r1.20 src/distrib/utils/embedded/conf/armv7.conf (switch to unified diff)

--- src/distrib/utils/embedded/conf/armv7.conf 2017/11/09 21:36:46 1.19
+++ src/distrib/utils/embedded/conf/armv7.conf 2017/11/28 02:56:44 1.20
@@ -1,166 +1,167 @@ @@ -1,166 +1,167 @@
1# $NetBSD: armv7.conf,v 1.19 2017/11/09 21:36:46 skrll Exp $ 1# $NetBSD: armv7.conf,v 1.20 2017/11/28 02:56:44 kre Exp $
2# ARMv7 customization script used by mkimage 2# ARMv7 customization script used by mkimage
3# 3#
4board=armv7 4board=armv7
5console=fb 5console=fb
6resize=true 6resize=true
7 7
8. ${DIR}/conf/evbarm.conf 8. ${DIR}/conf/evbarm.conf
9 9
10kernels_beagle="BEAGLEBOARD BEAGLEBONE" 10kernels_beagle="BEAGLEBOARD BEAGLEBONE"
11kernels_awin="BPI CUBIEBOARD CUBIETRUCK" 11kernels_awin="BPI CUBIEBOARD CUBIETRUCK"
12kernels_rpi="RPI2" 12kernels_rpi="RPI2"
13kernels_amlogic="ODROID-C1" 13kernels_amlogic="ODROID-C1"
14kernels_tegra="TEGRA" 14kernels_tegra="TEGRA"
15kernels_sunxi="SUNXI" 15kernels_sunxi="SUNXI"
16 16
17make_label() { 17make_label() {
18 make_label_evbarm 18 make_label_evbarm
19} 19}
20 20
21make_fstab() { 21make_fstab() {
22 make_fstab_evbarm 22 make_fstab_evbarm
23} 23}
24 24
25customize() { 25customize() {
26 customize_evbarm 26 customize_evbarm
27 cat >> "${mnt}/etc/rc.conf" << EOF 27 cat >> "${mnt}/etc/rc.conf" << EOF
28mdnsd=YES 28mdnsd=YES
29wscons=YES 29wscons=YES
30devpubd=YES 30devpubd=YES
31EOF 31EOF
32} 32}
33 33
34populate_common() { 34populate_common() {
35 # Install boot script 35 # Install boot script
36 cp ${DIR}/files/armv7_boot.cmd ${mnt}/boot/boot.cmd 36 cp ${DIR}/files/armv7_boot.cmd ${mnt}/boot/boot.cmd
37 "${MKUBOOTIMAGE}" -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/armv7 boot" "${mnt}/boot/boot.cmd" "${mnt}/boot/boot.scr" 37 "${MKUBOOTIMAGE}" -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/armv7 boot" "${mnt}/boot/boot.cmd" "${mnt}/boot/boot.scr"
38} 38}
39 39
40populate_beagle() { 40populate_beagle() {
41 : 41 :
42} 42}
43 43
44populate_awin() { 44populate_awin() {
45 : 45 :
46} 46}
47 47
48populate_rpi() { 48populate_rpi() {
49 firmwaredir="${src}/external/broadcom/rpi-firmware/dist" 49 firmwaredir="${src}/external/broadcom/rpi-firmware/dist"
50 firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" 50 firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
51 51
52 # RPI2 kernel needs to be installed as kernel7.img 52 # RPI2 kernel needs to be installed as kernel7.img
53 if [ -f "${mnt}/boot/netbsd-RPI2.bin" ]; then 53 if [ -f "${mnt}/boot/netbsd-RPI2.bin" ]; then
54 echo "${bar} renaming netbsd-RPI2.bin to kernel7.img ${bar}" 54 echo "${bar} renaming netbsd-RPI2.bin to kernel7.img ${bar}"
55 mv "${mnt}/boot/netbsd-RPI2.bin" "${mnt}/boot/kernel7.img" 55 mv "${mnt}/boot/netbsd-RPI2.bin" "${mnt}/boot/kernel7.img"
56 56
57 cat > "${mnt}/boot/cmdline.txt" << EOF 57 cat > "${mnt}/boot/cmdline.txt" << EOF
58root=ld0a console=${console} 58root=ld0a console=${console}
59#fb=1280x1024 # to select a mode, otherwise try EDID 59#fb=1280x1024 # to select a mode, otherwise try EDID
60#fb=disable # to disable fb completely 60#fb=disable # to disable fb completely
61EOF 61EOF
62 62
63 cat > ${mnt}/boot/config.txt << EOF 63 cat > ${mnt}/boot/config.txt << EOF
64# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md 64# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
65enable_uart=1 65enable_uart=1
66force_turbo=0 66force_turbo=0
67EOF 67EOF
68 68
69 echo "${bar} installing firmware files ${bar}" 69 echo "${bar} installing firmware files ${bar}"
70 (cd "${mnt}/boot" && 70 (cd "${mnt}/boot" &&
71 for f in ${firmwarefiles}; do 71 for f in ${firmwarefiles}; do
72 echo " $f" 72 echo " $f"
73 cp "${firmwaredir}/${f}" . 73 cp "${firmwaredir}/${f}" .
74 done 74 done
75 ) 75 )
76 76
77 fi 77 fi
78 78
79 # 79 #
80 # If arm_freq is specified in config.txt, set CPU frequency 80 # If arm_freq is specified in config.txt, set CPU frequency
81 # to match at boot time. 81 # to match at boot time.
82 # 82 #
83 cp ${release}/etc/rc.local ${mnt}/etc/rc.local 83 cp ${release}/etc/rc.local ${mnt}/etc/rc.local
84 cat >> ${mnt}/etc/rc.local << EOF 84 cat >> ${mnt}/etc/rc.local << EOF
85if /sbin/sysctl -q machdep.cpu.frequency.max; then 85if /sbin/sysctl -q machdep.cpu.frequency.max; then
86 cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max) 86 cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
87 cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current) 87 cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
88 if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then 88 if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
89 /sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max 89 /sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
90 fi 90 fi
91fi 91fi
92EOF 92EOF
93 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \ 93 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
94 >> "$tmp/selected_sets" 94 >> "$tmp/selected_sets"
95} 95}
96 96
97populate_amlogic() { 97populate_amlogic() {
98 odroidc1_kernelimg=netbsd-ODROID-C1.ub 98 odroidc1_kernelimg=netbsd-ODROID-C1.ub
99 99
100 # Create a boot.ini for Amlogic U-Boot 100 # Create a boot.ini for Amlogic U-Boot
101 cat >> "${mnt}/boot/boot.ini" << EOF 101 cat >> "${mnt}/boot/boot.ini" << EOF
102ODROIDC-UBOOT-CONFIG 102ODROIDC-UBOOT-CONFIG
103 103
104setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}" 104setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}"
105setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000" 105setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000"
106run bootcmd 106run bootcmd
107EOF 107EOF
108} 108}
109 109
110populate_sunxi() { 110populate_sunxi() {
111 : 111 :
112} 112}
113 113
114populate_tegra() { 114populate_tegra() {
115 : 115 :
116} 116}
117 117
118populate() { 118populate() {
119 echo "${bar} looking for kernels in ${kernel} ${bar}" 119 echo "${bar} looking for kernels in ${kernel} ${bar}"
120 kernels="" 120 kernels=""
121 # .ub kernels 121 # .ub kernels
122 for k in $kernels_beagle $kernels_awin $kernels_sunxi $kernels_amlogic $kernels_tegra; do 122 for k in $kernels_beagle $kernels_awin $kernels_sunxi $kernels_amlogic $kernels_tegra; do
123 f="${kernel}/netbsd-${k}.ub.gz" 123 f="${kernel}/netbsd-${k}.ub.gz"
124 test -f "${f}" && kernels="${kernels} ${f}" 124 test -f "${f}" && kernels="${kernels} ${f}"
125 done 125 done
126 # .bin kernels 126 # .bin kernels
127 for k in $kernels_rpi; do 127 for k in $kernels_rpi; do
128 f="${kernel}/netbsd-${k}.bin.gz" 128 f="${kernel}/netbsd-${k}.bin.gz"
129 test -f "${f}" && kernels="${kernels} ${f}" 129 test -f "${f}" && kernels="${kernels} ${f}"
130 done 130 done
131 # .dtb files 131 # .dtb files
132 for k in $kernels_sunxi $kernels_tegra; do 132 for k in $kernels_sunxi $kernels_tegra; do
133 test -d "${KERNOBJDIR}/${k}" && \ 133 test -d "${KERNOBJDIR}/${k}" && \
134 dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \ 134 dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
135 dtbs= 135 dtbs=
136 for dtb in $dtbs; do 136 for dtb in $dtbs; do
137 f="${kernel}/${dtb}.gz" 137 f="${kernel}/${dtb}.gz"
138 test -f "${f}" && kernels="${kernels} ${f}" 138 test -f "${f}" && kernels="${kernels} ${f}"
139 done 139 done
140 done 140 done
141 141
142 # install kernels to /boot partition 142 # install kernels to /boot partition
143 for k in ${kernels}; do 143 for k in ${kernels}; do
144 tgt="$(basename ${k} | sed 's/\.gz$//')" 144 tgt="$(basename ${k} | sed 's/\.gz$//')"
145 echo "${bar} installing ${k} to /boot/${tgt} ${bar}" 145 echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
146 case "${k}" in 146 case "${k}" in
147 *.gz) 147 *.gz)
148 ${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}" 148 ${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
149 ;; 149 ;;
150 *) 150 *)
151 cp "${k}" "${mnt}/boot/${tgt}" 151 cp "${k}" "${mnt}/boot/${tgt}"
152 ;; 152 ;;
153 esac 153 esac ||
 154 fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
154 done 155 done
155 156
156 # board specific configuration 157 # board specific configuration
157 populate_beagle 158 populate_beagle
158 populate_awin 159 populate_awin
159 populate_rpi 160 populate_rpi
160 populate_amlogic 161 populate_amlogic
161 populate_tegra 162 populate_tegra
162 populate_sunxi 163 populate_sunxi
163 164
164 # common configuration 165 # common configuration
165 populate_common 166 populate_common
166} 167}

cvs diff -r1.31 -r1.32 src/distrib/utils/embedded/conf/rpi.conf (switch to unified diff)

--- src/distrib/utils/embedded/conf/rpi.conf 2017/11/09 21:36:46 1.31
+++ src/distrib/utils/embedded/conf/rpi.conf 2017/11/28 02:56:44 1.32
@@ -1,95 +1,95 @@ @@ -1,95 +1,95 @@
1# $NetBSD: rpi.conf,v 1.31 2017/11/09 21:36:46 skrll Exp $ 1# $NetBSD: rpi.conf,v 1.32 2017/11/28 02:56:44 kre Exp $
2# Raspberry Pi customization script used by mkimage 2# Raspberry Pi customization script used by mkimage
3# 3#
4 4
5board=rpi 5board=rpi
6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin 6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin
7resize=true 7resize=true
8 8
9. ${DIR}/conf/evbarm.conf 9. ${DIR}/conf/evbarm.conf
10 10
11firmwaredir=$src/external/broadcom/rpi-firmware/dist 11firmwaredir=$src/external/broadcom/rpi-firmware/dist
12firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" 12firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
13 13
14make_fstab() { 14make_fstab() {
15 make_fstab_evbarm 15 make_fstab_evbarm
16} 16}
17 17
18make_label() { 18make_label() {
19 make_label_evbarm 19 make_label_evbarm
20} 20}
21 21
22customize() { 22customize() {
23 customize_evbarm 23 customize_evbarm
24 cat >> ${mnt}/etc/rc.conf << EOF 24 cat >> ${mnt}/etc/rc.conf << EOF
25wscons=YES 25wscons=YES
26devpubd=YES 26devpubd=YES
27EOF 27EOF
28 28
29 # 29 #
30 # If arm_freq is specified in config.txt, set CPU frequency 30 # If arm_freq is specified in config.txt, set CPU frequency
31 # to match at boot time. 31 # to match at boot time.
32 # 32 #
33 cp ${release}/etc/rc.local ${mnt}/etc/rc.local 33 cp ${release}/etc/rc.local ${mnt}/etc/rc.local
34 cat >> ${mnt}/etc/rc.local << EOF 34 cat >> ${mnt}/etc/rc.local << EOF
35if /sbin/sysctl -q machdep.cpu.frequency.max; then 35if /sbin/sysctl -q machdep.cpu.frequency.max; then
36 cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max) 36 cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
37 cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current) 37 cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
38 if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then 38 if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
39 /sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max 39 /sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
40 fi 40 fi
41fi 41fi
42EOF 42EOF
43 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \ 43 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
44 >> "$tmp/selected_sets" 44 >> "$tmp/selected_sets"
45} 45}
46 46
47populate() { 47populate() {
48 rpi2_kernel="$(echo $kernel | sed 's/RPI/RPI2/g')" 48 rpi2_kernel="$(echo $kernel | sed 's/RPI/RPI2/g')"
49 49
50 cat > ${mnt}/boot/cmdline.txt << EOF 50 cat > ${mnt}/boot/cmdline.txt << EOF
51root=ld0a console=fb 51root=ld0a console=fb
52#fb=1280x1024 # to select a mode, otherwise try EDID 52#fb=1280x1024 # to select a mode, otherwise try EDID
53#fb=disable # to disable fb completely 53#fb=disable # to disable fb completely
54EOF 54EOF
55 55
56 cat > ${mnt}/boot/config.txt << EOF 56 cat > ${mnt}/boot/config.txt << EOF
57# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md 57# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
58enable_uart=1 58enable_uart=1
59force_turbo=0 59force_turbo=0
60EOF 60EOF
61 61
62 if [ ! -f ${kernel} ]; then 62 if [ ! -f ${kernel} ]; then
63 echo ${PROG}: Missing ${kernel} 1>&2 63 echo ${PROG}: Missing ${kernel} 1>&2
64 exit 1 64 exit 1
65 fi 65 fi
66 66
67 echo "${bar} installing RPI kernel ${bar}" 67 echo "${bar} installing RPI kernel ${bar}"
68 case ${kernel} in 68 case ${kernel} in
69 *.gz) 69 *.gz)
70 gzip -dc ${kernel} > ${mnt}/boot/kernel.img 70 gzip -dc ${kernel} > ${mnt}/boot/kernel.img
71 ;; 71 ;;
72 *) 72 *)
73 cp ${kernel} ${mnt}/boot/kernel.img 73 cp ${kernel} ${mnt}/boot/kernel.img
74 ;; 74 ;;
75 esac 75 esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
76 76
77 echo "${bar} installing RPI2 kernel ${bar}" 77 echo "${bar} installing RPI2 kernel ${bar}"
78 case ${rpi2_kernel} in 78 case ${rpi2_kernel} in
79 *.gz) 79 *.gz)
80 gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img 80 gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img
81 ;; 81 ;;
82 *) 82 *)
83 cp ${rpi_kernel} ${mnt}/boot/kernel7.img 83 cp ${rpi2_kernel} ${mnt}/boot/kernel7.img
84 ;; 84 ;;
85 esac 85 esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed"
86 86
87 echo "${bar} installing firmware files ${bar}" 87 echo "${bar} installing firmware files ${bar}"
88 (cd ${mnt}/boot && 88 (cd ${mnt}/boot &&
89 for f in ${firmwarefiles}; do 89 for f in ${firmwarefiles}; do
90 echo " $f" 90 echo " $f"
91 cp ${firmwaredir}/${f} . 91 cp ${firmwaredir}/${f} . || exit 1
92 done 92 done
93 ) 93 ) || fail "Copy of firmeware into ${mnt}/boot failed"
94 94
95} 95}

cvs diff -r1.9 -r1.10 src/distrib/utils/embedded/conf/rpi_inst.conf (switch to unified diff)

--- src/distrib/utils/embedded/conf/rpi_inst.conf 2017/07/31 16:34:22 1.9
+++ src/distrib/utils/embedded/conf/rpi_inst.conf 2017/11/28 02:56:44 1.10
@@ -1,115 +1,115 @@ @@ -1,115 +1,115 @@
1# $NetBSD: rpi_inst.conf,v 1.9 2017/07/31 16:34:22 jmcneill Exp $ 1# $NetBSD: rpi_inst.conf,v 1.10 2017/11/28 02:56:44 kre Exp $
2# Raspberry Pi customization script used by mkimage 2# Raspberry Pi customization script used by mkimage
3# 3#
4 4
5board=rpi_inst 5board=rpi_inst
6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin 6kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin
7 7
8. ${DIR}/conf/evbarm.conf 8. ${DIR}/conf/evbarm.conf
9 9
10image=$HOME/${board}.img 10image=$HOME/${board}.img
11 11
12swap=8 12swap=8
13extra=8 # spare space 13extra=8 # spare space
14boot=112 14boot=112
15init=8 15init=8
16 16
17size=$(( 10485760 + ${swap} * 1024 * 512 + ${boot} * 1024 * 512 + ${init} * 1024 * 512 )) 17size=$(( 10485760 + ${swap} * 1024 * 512 + ${boot} * 1024 * 512 + ${init} * 1024 * 512 ))
18msdosid=12 18msdosid=12
19 19
20make_label() { 20make_label() {
21 # compute all sizes in terms of sectors 21 # compute all sizes in terms of sectors
22 local totalsize=$(( ${newsize} * 1024 * 2 / 512 )) 22 local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
23 23
24 local swapsize=$(( ${swap} * 1024 )) 24 local swapsize=$(( ${swap} * 1024 ))
25 local bootsize=$(( ${boot} * 1024 )) 25 local bootsize=$(( ${boot} * 1024 ))
26 26
27 local bootoffset=$(( ${init} * 1024 )) 27 local bootoffset=$(( ${init} * 1024 ))
28 local swapoffset=$(( ${bootoffset} + ${bootsize} )) 28 local swapoffset=$(( ${bootoffset} + ${bootsize} ))
29 29
30 local asize=$(( ${totalsize} - ${swapsize} - ${bootsize} - ${bootoffset} )) 30 local asize=$(( ${totalsize} - ${swapsize} - ${bootsize} - ${bootoffset} ))
31 local aoffset=$(( ${swapoffset} + ${swapsize} )) 31 local aoffset=$(( ${swapoffset} + ${swapsize} ))
32 32
33 local bps=512 33 local bps=512
34 local spt=32 34 local spt=32
35 local tpc=64 35 local tpc=64
36 local spc=2048 36 local spc=2048
37 local cylinders=$(( ${totalsize} / ${spc} )) 37 local cylinders=$(( ${totalsize} / ${spc} ))
38 38
39 cat << EOF 39 cat << EOF
40type: SCSI 40type: SCSI
41disk: STORAGE DEVICE 41disk: STORAGE DEVICE
42label: fictitious 42label: fictitious
43flags: removable 43flags: removable
44bytes/sector: ${bps} 44bytes/sector: ${bps}
45sectors/track: ${spt} 45sectors/track: ${spt}
46tracks/cylinder: ${tpc} 46tracks/cylinder: ${tpc}
47sectors/cylinder: ${spc} 47sectors/cylinder: ${spc}
48cylinders: ${cylinders} 48cylinders: ${cylinders}
49total sectors: ${totalsize} 49total sectors: ${totalsize}
50rpm: 3600 50rpm: 3600
51interleave: 1 51interleave: 1
52trackskew: 0 52trackskew: 0
53cylinderskew: 0 53cylinderskew: 0
54headswitch: 0 # microseconds 54headswitch: 0 # microseconds
55track-to-track seek: 0 # microseconds 55track-to-track seek: 0 # microseconds
56drivedata: 0  56drivedata: 0
57 57
588 partitions: 588 partitions:
59# size offset fstype [fsize bsize cpg/sgs] 59# size offset fstype [fsize bsize cpg/sgs]
60 a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 #  60 a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 #
61 b: ${swapsize} ${swapoffset} swap # 61 b: ${swapsize} ${swapoffset} swap #
62 d: ${totalsize} 0 unused 0 0 # 62 d: ${totalsize} 0 unused 0 0 #
63 e: ${bootsize} ${bootoffset} MSDOS # 63 e: ${bootsize} ${bootoffset} MSDOS #
64EOF 64EOF
65} 65}
66 66
67customize() { 67customize() {
68 echo "${bar} creating directories ${bar}" 68 echo "${bar} creating directories ${bar}"
69 mkdir ${mnt}/proc ${mnt}/kern 69 mkdir ${mnt}/proc ${mnt}/kern
70} 70}
71 71
72make_fstab() { 72make_fstab() {
73 : 73 :
74} 74}
75 75
76firmwaredir=$src/external/broadcom/rpi-firmware/dist 76firmwaredir=$src/external/broadcom/rpi-firmware/dist
77firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" 77firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
78 78
79populate() { 79populate() {
80 cat > ${mnt}/boot/cmdline.txt << EOF 80 cat > ${mnt}/boot/cmdline.txt << EOF
81root=ld0a console=fb 81root=ld0a console=fb
82#fb=1280x1024 # to select a mode, otherwise try EDID  82#fb=1280x1024 # to select a mode, otherwise try EDID
83#fb=disable # to disable fb completely 83#fb=disable # to disable fb completely
84EOF 84EOF
85 85
86 cat > ${mnt}/boot/config.txt << EOF 86 cat > ${mnt}/boot/config.txt << EOF
87# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md 87# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
88enable_uart=1  88enable_uart=1
89force_turbo=0 89force_turbo=0
90EOF 90EOF
91 91
92 if [ ! -f ${kernel} ]; then 92 if [ ! -f ${kernel} ]; then
93 echo ${PROG}: Missing ${kernel} 1>&2 93 echo ${PROG}: Missing ${kernel} 1>&2
94 exit 1 94 exit 1
95 fi 95 fi
96 96
97 echo "${bar} installing kernel ${bar}" 97 echo "${bar} installing kernel ${bar}"
98 case ${kernel} in 98 case ${kernel} in
99 *.gz) 99 *.gz)
100 ${GZIP_CMD} -dc ${kernel} > ${mnt}/boot/kernel.img 100 ${GZIP_CMD} -dc ${kernel} > ${mnt}/boot/kernel.img
101 ;; 101 ;;
102 *) 102 *)
103 cp ${kernel} ${mnt}/boot/kernel.img 103 cp ${kernel} ${mnt}/boot/kernel.img
104 ;; 104 ;;
105 esac 105 esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
106 106
107 echo "${bar} installing firmware files ${bar}" 107 echo "${bar} installing firmware files ${bar}"
108 (cd ${mnt}/boot && 108 (cd ${mnt}/boot &&
109 for f in ${firmwarefiles}; do 109 for f in ${firmwarefiles}; do
110 echo " $f" 110 echo " $f"
111 cp ${firmwaredir}/${f} . 111 cp ${firmwaredir}/${f} . || exit 1
112 done 112 done
113 ) 113 ) || fail "Copy of firmware to ${mnt}/boot failed"
114 114
115} 115}

cvs diff -r1.7 -r1.8 src/distrib/utils/embedded/conf/x86.conf (switch to unified diff)

--- src/distrib/utils/embedded/conf/x86.conf 2015/01/29 14:54:06 1.7
+++ src/distrib/utils/embedded/conf/x86.conf 2017/11/28 02:56:44 1.8
@@ -1,149 +1,150 @@ @@ -1,149 +1,150 @@
1# $NetBSD: x86.conf,v 1.7 2015/01/29 14:54:06 skrll Exp $ 1# $NetBSD: x86.conf,v 1.8 2017/11/28 02:56:44 kre Exp $
2# x86 shared config 2# x86 shared config
3# 3#
4 4
5image=$HOME/${board}.img 5image=$HOME/${board}.img
6MACHINE=${board} 6MACHINE=${board}
7kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd 7kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd
8bootfile=$release/usr/mdec/boot 8bootfile=$release/usr/mdec/boot
9 9
10extra=8 # spare space 10extra=8 # spare space
11size=0 # autocompute 11size=0 # autocompute
12netbsdid=169 12netbsdid=169
13init=63 13init=63
14ffsoffset=${init}b 14ffsoffset=${init}b
15 15
16make_label() { 16make_label() {
17 # compute all sizes in terms of sectors 17 # compute all sizes in terms of sectors
18 local totalsize=$(( ${newsize} * 1024 * 2 / 512 )) 18 local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
19 19
20 local aoffset=${init} 20 local aoffset=${init}
21 local asize=$(( ${totalsize} - ${aoffset} )) 21 local asize=$(( ${totalsize} - ${aoffset} ))
22 22
23 local bps=512 23 local bps=512
24 local spt=32 24 local spt=32
25 local tpc=64 25 local tpc=64
26 local spc=2048 26 local spc=2048
27 local cylinders=$(( ${totalsize} / ${spc} )) 27 local cylinders=$(( ${totalsize} / ${spc} ))
28 28
29 cat << EOF 29 cat << EOF
30type: SCSI 30type: SCSI
31disk: STORAGE DEVICE 31disk: STORAGE DEVICE
32label: fictitious 32label: fictitious
33flags: removable 33flags: removable
34bytes/sector: ${bps} 34bytes/sector: ${bps}
35sectors/track: ${spt} 35sectors/track: ${spt}
36tracks/cylinder: ${tpc} 36tracks/cylinder: ${tpc}
37sectors/cylinder: ${spc} 37sectors/cylinder: ${spc}
38cylinders: ${cylinders} 38cylinders: ${cylinders}
39total sectors: ${totalsize} 39total sectors: ${totalsize}
40rpm: 3600 40rpm: 3600
41interleave: 1 41interleave: 1
42trackskew: 0 42trackskew: 0
43cylinderskew: 0 43cylinderskew: 0
44headswitch: 0 # microseconds 44headswitch: 0 # microseconds
45track-to-track seek: 0 # microseconds 45track-to-track seek: 0 # microseconds
46drivedata: 0  46drivedata: 0
47 47
488 partitions: 488 partitions:
49# size offset fstype [fsize bsize cpg/sgs] 49# size offset fstype [fsize bsize cpg/sgs]
50 a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 #  50 a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 #
51 c: ${totalsize} 0 unused 0 0 # 51 c: ${totalsize} 0 unused 0 0 #
52 d: ${totalsize} 0 unused 0 0 # 52 d: ${totalsize} 0 unused 0 0 #
53EOF 53EOF
54} 54}
55 55
56make_fstab_normal() { 56make_fstab_normal() {
57 cat > ${mnt}/etc/fstab << EOF 57 cat > ${mnt}/etc/fstab << EOF
58# NetBSD /etc/fstab 58# NetBSD /etc/fstab
59# See /usr/share/examples/fstab/ for more examples. 59# See /usr/share/examples/fstab/ for more examples.
60/dev/${rootdev}0a / ffs rw,log 1 1 60/dev/${rootdev}0a / ffs rw,log 1 1
61kernfs /kern kernfs rw 61kernfs /kern kernfs rw
62ptyfs /dev/pts ptyfs rw 62ptyfs /dev/pts ptyfs rw
63procfs /proc procfs rw 63procfs /proc procfs rw
64EOF 64EOF
65} 65}
66 66
67# From Richard Neswold's: 67# From Richard Neswold's:
68# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html 68# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html
69# Also for the postfix stuff below 69# Also for the postfix stuff below
70make_fstab_minwrites() { 70make_fstab_minwrites() {
71 cat > ${mnt}/etc/fstab << EOF 71 cat > ${mnt}/etc/fstab << EOF
72# NetBSD /etc/fstab 72# NetBSD /etc/fstab
73# See /usr/share/examples/fstab/ for more examples. 73# See /usr/share/examples/fstab/ for more examples.
74/dev/${rootdev}0a / ffs rw,log,noatime,nodevmtime 1 1 74/dev/${rootdev}0a / ffs rw,log,noatime,nodevmtime 1 1
75kernfs /kern kernfs rw 75kernfs /kern kernfs rw
76ptyfs /dev/pts ptyfs rw 76ptyfs /dev/pts ptyfs rw
77procfs /proc procfs rw 77procfs /proc procfs rw
78tmpfs /tmp tmpfs rw,-s32M 78tmpfs /tmp tmpfs rw,-s32M
79tmpfs /var/log tmpfs rw,union,-s32M 79tmpfs /var/log tmpfs rw,union,-s32M
80tmpfs /var/run tmpfs rw,union,-s1M 80tmpfs /var/run tmpfs rw,union,-s1M
81tmpfs /var/mail tmpfs rw,union,-s10M 81tmpfs /var/mail tmpfs rw,union,-s10M
82tmpfs /var/spool/postfix tmpfs rw,union,-s20M 82tmpfs /var/spool/postfix tmpfs rw,union,-s20M
83tmpfs /var/db/postfix tmpfs rw,union,-s1M 83tmpfs /var/db/postfix tmpfs rw,union,-s1M
84tmpfs /var/chroot tmpfs rw,union,-s10M 84tmpfs /var/chroot tmpfs rw,union,-s10M
85EOF 85EOF
86} 86}
87 87
88make_fstab() { 88make_fstab() {
89 if $minwrites; then 89 if $minwrites; then
90 make_fstab_minwrites 90 make_fstab_minwrites
91 else 91 else
92 make_fstab_normal 92 make_fstab_normal
93 fi 93 fi
94 echo "./etc/fstab type=file uname=root gname=wheel mode=0755" \ 94 echo "./etc/fstab type=file uname=root gname=wheel mode=0755" \
95 >> "$tmp/selected_sets" 95 >> "$tmp/selected_sets"
96 96
97 echo "./proc type=dir uname=root gname=wheel mode=0755" \ 97 echo "./proc type=dir uname=root gname=wheel mode=0755" \
98 >> "$tmp/selected_sets" 98 >> "$tmp/selected_sets"
99 echo "./kern type=dir uname=root gname=wheel mode=0755" \ 99 echo "./kern type=dir uname=root gname=wheel mode=0755" \
100 >> "$tmp/selected_sets" 100 >> "$tmp/selected_sets"
101} 101}
102 102
103customize() { 103customize() {
104 cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf 104 cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
105 if $minwrites; then 105 if $minwrites; then
106 mkdir ${mnt}/etc/postfix 106 mkdir ${mnt}/etc/postfix
107 (umask 022 107 (umask 022
108 sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \ 108 sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
109 ${mnt}/etc/postfix/master.cf) 109 ${mnt}/etc/postfix/master.cf)
110 fi 110 fi
111 cat >> ${mnt}/etc/rc.conf << EOF 111 cat >> ${mnt}/etc/rc.conf << EOF
112rc_configured=YES 112rc_configured=YES
113hostname=${board} 113hostname=${board}
114sshd=YES 114sshd=YES
115dhcpcd=YES 115dhcpcd=YES
116wscons=YES 116wscons=YES
117devpubd=YES 117devpubd=YES
118EOF 118EOF
119 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \ 119 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
120 >> "$tmp/selected_sets" 120 >> "$tmp/selected_sets"
121 121
122 if [ ! -f ${release}/dev/MAKEDEV ]; then 122 if [ ! -f ${release}/dev/MAKEDEV ]; then
123 echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2 123 echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
124 exit 1 124 exit 1
125 fi 125 fi
126 echo "${bar} running MAKEDEV ${bar}" 126 echo "${bar} running MAKEDEV ${bar}"
127 ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \ 127 ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
128 >> "$tmp/selected_sets" 128 >> "$tmp/selected_sets"
129} 129}
130 130
131populate() { 131populate() {
132 if [ ! -f ${kernel} ]; then 132 if [ ! -f ${kernel} ]; then
133 echo ${PROG}: Missing ${kernel} 1>&2 133 echo ${PROG}: Missing ${kernel} 1>&2
134 exit 1 134 exit 1
135 fi 135 fi
136 136
137 echo "${bar} installing kernel ${bar}" 137 echo "${bar} installing kernel ${bar}"
138 cp ${kernel} ${mnt}/netbsd 138 cp ${kernel} ${mnt}/netbsd
139 if [ ! -f ${bootfile} ]; then 139 if [ ! -f ${bootfile} ]; then
140 echo ${PROG}: Missing ${bootfile} 1>&2 140 echo ${PROG}: Missing ${bootfile} 1>&2
141 exit 1 141 exit 1
142 fi 142 fi
143 cp ${bootfile} ${mnt}/boot 143 cp ${bootfile} ${mnt}/boot ||
 144 fail "copy of ${bootfile} to ${mnt}/boot failed"
144 145
145 echo "./netbsd type=file uname=root gname=wheel mode=0755" \ 146 echo "./netbsd type=file uname=root gname=wheel mode=0755" \
146 >> "$tmp/selected_sets" 147 >> "$tmp/selected_sets"
147 echo "./boot type=file uname=root gname=wheel mode=0444" \ 148 echo "./boot type=file uname=root gname=wheel mode=0444" \
148 >> "$tmp/selected_sets" 149 >> "$tmp/selected_sets"
149} 150}