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.diff -r1.68 -r1.69 src/distrib/utils/embedded/mkimage
(kre)
--- 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 | |||
49 | set -e | 49 | set -e | |
50 | 50 | |||
51 | DIR="$(cd "$(dirname "$0")" && pwd)" | 51 | DIR="$(cd "$(dirname "$0")" && pwd)" | |
52 | PROG="$(basename "$0")" | 52 | PROG="$(basename "$0")" | |
53 | 53 | |||
54 | MAKE=${TOOL_MAKE:-make} | 54 | MAKE=${TOOL_MAKE:-make} | |
55 | DISKLABEL=${TOOL_DISKLABEL:-disklabel} | 55 | DISKLABEL=${TOOL_DISKLABEL:-disklabel} | |
56 | FDISK=${TOOL_FDISK:-fdisk} | 56 | FDISK=${TOOL_FDISK:-fdisk} | |
57 | MAKEFS=${TOOL_MAKEFS:-makefs} | 57 | MAKEFS=${TOOL_MAKEFS:-makefs} | |
58 | MTREE=${TOOL_MTREE:-mtree} | 58 | MTREE=${TOOL_MTREE:-mtree} | |
59 | INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot} | 59 | INSTALLBOOT=${TOOL_INSTALLBOOT:-installboot} | |
60 | MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE:-mkubootimage} | 60 | MKUBOOTIMAGE=${TOOL_MKUBOOTIMAGE:-mkubootimage} | |
61 | GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1) | 61 | GZIP_CMD=${TOOL_GZIP:-gzip} # ${GZIP} is special to gzip(1) | |
62 | 62 | |||
63 | src="/usr/src" | 63 | src="/usr/src" | |
64 | sets="base comp etc games man misc modules tests text" | 64 | sets="base comp etc games man misc modules tests text" | |
65 | xsets="xbase xcomp xetc xfont xserver" | 65 | xsets="xbase xcomp xetc xfont xserver" | |
66 | minfree="10%" | 66 | minfree="10%" | |
67 | bar="===" | 67 | bar="===" | |
68 | 68 | |||
69 | tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")" | 69 | tmp="$(mktemp -d "${TMPDIR:-/tmp}/$PROG.XXXXXX")" | |
70 | mnt="${tmp}/mnt" | 70 | mnt="${tmp}/mnt" | |
71 | mkdir -p "${mnt}/etc" "${mnt}/dev" | 71 | mkdir -p "${mnt}/etc" "${mnt}/dev" | |
72 | 72 | |||
73 | trap "cleanup" 0 1 2 3 15 | 73 | trap "cleanup" 0 1 2 3 15 | |
74 | 74 | |||
75 | cleanup() { | 75 | cleanup() { | |
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 | |||
81 | fail() { | |||
82 | IFS=' ' | |||
83 | echo >&2 "${PROG}: $*" | |||
84 | exit 1 | |||
85 | } | |||
86 | ||||
81 | getsize() { | 87 | getsize() { | |
82 | set -- $(ls -l $1) | 88 | set -- $(ls -l $1) | |
83 | echo $5 | 89 | echo $5 | |
84 | } | 90 | } | |
85 | 91 | |||
86 | getsectors() { | 92 | getsectors() { | |
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 | |||
108 | usage() { | 114 | usage() { | |
109 | cat << EOF 1>&2 | 115 | cat << EOF 1>&2 | |
110 | Usage: $PROG -h <host-arch> [-bdmx] [-B <byte-order>] [-K <kerneldir>] [-S <srcdir>] [-D <destdir>] [-c <custom-files-dir>] [-s <Mb size>] [<image>] | 116 | Usage: $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 | |
117 | EOF | 123 | EOF | |
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 | |
122 | OPTS="B:D:K:S:bc:dh:mr:s:x" | 128 | OPTS="B:D:K:S:bc:dh:mr:s:x" | |
123 | while getopts "$OPTS" f | 129 | while getopts "$OPTS" f | |
124 | do | 130 | do | |
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 | |
130 | done | 136 | done | |
131 | 137 | |||
132 | if [ -z "$h" ] | 138 | if [ -z "$h" ] | |
133 | then | 139 | then | |
134 | usage | 140 | usage | |
135 | fi | 141 | fi | |
136 | 142 | |||
137 | if [ ! -f "${DIR}/conf/${h}.conf" ] | 143 | if [ ! -f "${DIR}/conf/${h}.conf" ] | |
138 | then | 144 | then | |
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 | |
141 | fi | 147 | fi | |
142 | 148 | |||
143 | resize=false | 149 | resize=false | |
144 | 150 | |||
145 | . "${DIR}/conf/${h}.conf" | 151 | . "${DIR}/conf/${h}.conf" | |
146 | release="/usr/obj/${MACHINE}/release" | 152 | release="/usr/obj/${MACHINE}/release" | |
147 | 153 | |||
148 | selected_sets="$sets" | 154 | selected_sets="$sets" | |
149 | dsets_p=false | 155 | dsets_p=false | |
150 | xsets_p=false | 156 | xsets_p=false | |
151 | minwrites=false | 157 | minwrites=false | |
152 | rootdev=ld | 158 | rootdev=ld | |
153 | endian= | 159 | endian= | |
154 | 160 | |||
155 | OPTIND=1 | 161 | OPTIND=1 | |
156 | while getopts "$OPTS" f | 162 | while getopts "$OPTS" f | |
157 | do | 163 | do | |
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 | |
183 | done | 189 | done | |
184 | 190 | |||
185 | shift $(( $OPTIND - 1 )) | 191 | shift $(( $OPTIND - 1 )) | |
186 | if [ -n "$1" ]; then | 192 | if [ -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 | |
190 | fi | 196 | fi | |
191 | 197 | |||
192 | case "$image" in | 198 | case "$image" in | |
193 | *.gz) compress=true; image="${image%.gz}";; | 199 | *.gz) compress=true; image="${image%.gz}";; | |
194 | *) compress=false;; | 200 | *) compress=false;; | |
195 | esac | 201 | esac | |
196 | 202 | |||
197 | if [ -z "${bootonly}" ]; then | 203 | if [ -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" | |
206 | fi | 212 | fi | |
207 | 213 | |||
208 | make_fstab | 214 | make_fstab | |
209 | customize | 215 | customize | |
210 | populate | 216 | populate | |
211 | 217 | |||
212 | if [ -n "${msdosid}" ]; then | 218 | if [ -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 | |
217 | fi | 223 | fi | |
218 | 224 | |||
219 | if [ -z "${bootonly}" ]; then | 225 | if [ -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}" | |
225 | fi | 231 | fi | |
226 | 232 | |||
227 | if [ "${size}" = 0 ]; then | 233 | if [ "${size}" = 0 ]; then | |
228 | size="$(getsize "${image}")" | 234 | size="$(getsize "${image}")" | |
229 | fi | 235 | fi | |
230 | newsize=$((${size} / 2 / 1024)) | 236 | newsize=$((${size} / 2 / 1024)) | |
231 | compare=$((${newsize} * 2 * 1024)) | 237 | compare=$((${newsize} * 2 * 1024)) | |
232 | while [ "${compare}" != "${size}" ] | 238 | while [ "${compare}" != "${size}" ] | |
233 | do | 239 | do | |
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))" | |
237 | done | 243 | done | |
238 | 244 | |||
239 | if [ -n "${msdosid}" ]; then | 245 | if [ -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 | |
256 | elif [ -n "${netbsdid}" ]; then | 262 | elif [ -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 | |
265 | fi | 271 | fi | |
266 | 272 | |||
267 | if $compress; then | 273 | if $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" | |
272 | fi | 278 | fi | |
273 | 279 | |||
274 | echo ${bar} Image is ${image} ${bar} | 280 | echo ${bar} Image is ${image} ${bar} |
--- 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 | # | |
4 | board=armv7 | 4 | board=armv7 | |
5 | console=fb | 5 | console=fb | |
6 | resize=true | 6 | resize=true | |
7 | 7 | |||
8 | . ${DIR}/conf/evbarm.conf | 8 | . ${DIR}/conf/evbarm.conf | |
9 | 9 | |||
10 | kernels_beagle="BEAGLEBOARD BEAGLEBONE" | 10 | kernels_beagle="BEAGLEBOARD BEAGLEBONE" | |
11 | kernels_awin="BPI CUBIEBOARD CUBIETRUCK" | 11 | kernels_awin="BPI CUBIEBOARD CUBIETRUCK" | |
12 | kernels_rpi="RPI2" | 12 | kernels_rpi="RPI2" | |
13 | kernels_amlogic="ODROID-C1" | 13 | kernels_amlogic="ODROID-C1" | |
14 | kernels_tegra="TEGRA" | 14 | kernels_tegra="TEGRA" | |
15 | kernels_sunxi="SUNXI" | 15 | kernels_sunxi="SUNXI" | |
16 | 16 | |||
17 | make_label() { | 17 | make_label() { | |
18 | make_label_evbarm | 18 | make_label_evbarm | |
19 | } | 19 | } | |
20 | 20 | |||
21 | make_fstab() { | 21 | make_fstab() { | |
22 | make_fstab_evbarm | 22 | make_fstab_evbarm | |
23 | } | 23 | } | |
24 | 24 | |||
25 | customize() { | 25 | customize() { | |
26 | customize_evbarm | 26 | customize_evbarm | |
27 | cat >> "${mnt}/etc/rc.conf" << EOF | 27 | cat >> "${mnt}/etc/rc.conf" << EOF | |
28 | mdnsd=YES | 28 | mdnsd=YES | |
29 | wscons=YES | 29 | wscons=YES | |
30 | devpubd=YES | 30 | devpubd=YES | |
31 | EOF | 31 | EOF | |
32 | } | 32 | } | |
33 | 33 | |||
34 | populate_common() { | 34 | populate_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 | |||
40 | populate_beagle() { | 40 | populate_beagle() { | |
41 | : | 41 | : | |
42 | } | 42 | } | |
43 | 43 | |||
44 | populate_awin() { | 44 | populate_awin() { | |
45 | : | 45 | : | |
46 | } | 46 | } | |
47 | 47 | |||
48 | populate_rpi() { | 48 | populate_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 | |
58 | root=ld0a console=${console} | 58 | root=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 | |
61 | EOF | 61 | EOF | |
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 | |
65 | enable_uart=1 | 65 | enable_uart=1 | |
66 | force_turbo=0 | 66 | force_turbo=0 | |
67 | EOF | 67 | EOF | |
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 | |
85 | if /sbin/sysctl -q machdep.cpu.frequency.max; then | 85 | if /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 | |
91 | fi | 91 | fi | |
92 | EOF | 92 | EOF | |
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 | |||
97 | populate_amlogic() { | 97 | populate_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 | |
102 | ODROIDC-UBOOT-CONFIG | 102 | ODROIDC-UBOOT-CONFIG | |
103 | 103 | |||
104 | setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}" | 104 | setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}" | |
105 | setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000" | 105 | setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000" | |
106 | run bootcmd | 106 | run bootcmd | |
107 | EOF | 107 | EOF | |
108 | } | 108 | } | |
109 | 109 | |||
110 | populate_sunxi() { | 110 | populate_sunxi() { | |
111 | : | 111 | : | |
112 | } | 112 | } | |
113 | 113 | |||
114 | populate_tegra() { | 114 | populate_tegra() { | |
115 | : | 115 | : | |
116 | } | 116 | } | |
117 | 117 | |||
118 | populate() { | 118 | populate() { | |
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 | } |
--- 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 | |||
5 | board=rpi | 5 | board=rpi | |
6 | kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin | 6 | kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin | |
7 | resize=true | 7 | resize=true | |
8 | 8 | |||
9 | . ${DIR}/conf/evbarm.conf | 9 | . ${DIR}/conf/evbarm.conf | |
10 | 10 | |||
11 | firmwaredir=$src/external/broadcom/rpi-firmware/dist | 11 | firmwaredir=$src/external/broadcom/rpi-firmware/dist | |
12 | firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" | 12 | firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" | |
13 | 13 | |||
14 | make_fstab() { | 14 | make_fstab() { | |
15 | make_fstab_evbarm | 15 | make_fstab_evbarm | |
16 | } | 16 | } | |
17 | 17 | |||
18 | make_label() { | 18 | make_label() { | |
19 | make_label_evbarm | 19 | make_label_evbarm | |
20 | } | 20 | } | |
21 | 21 | |||
22 | customize() { | 22 | customize() { | |
23 | customize_evbarm | 23 | customize_evbarm | |
24 | cat >> ${mnt}/etc/rc.conf << EOF | 24 | cat >> ${mnt}/etc/rc.conf << EOF | |
25 | wscons=YES | 25 | wscons=YES | |
26 | devpubd=YES | 26 | devpubd=YES | |
27 | EOF | 27 | EOF | |
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 | |
35 | if /sbin/sysctl -q machdep.cpu.frequency.max; then | 35 | if /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 | |
41 | fi | 41 | fi | |
42 | EOF | 42 | EOF | |
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 | |||
47 | populate() { | 47 | populate() { | |
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 | |
51 | root=ld0a console=fb | 51 | root=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 | |
54 | EOF | 54 | EOF | |
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 | |
58 | enable_uart=1 | 58 | enable_uart=1 | |
59 | force_turbo=0 | 59 | force_turbo=0 | |
60 | EOF | 60 | EOF | |
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 | } |
--- 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 | |||
5 | board=rpi_inst | 5 | board=rpi_inst | |
6 | kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin | 6 | kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI_INSTALL.bin | |
7 | 7 | |||
8 | . ${DIR}/conf/evbarm.conf | 8 | . ${DIR}/conf/evbarm.conf | |
9 | 9 | |||
10 | image=$HOME/${board}.img | 10 | image=$HOME/${board}.img | |
11 | 11 | |||
12 | swap=8 | 12 | swap=8 | |
13 | extra=8 # spare space | 13 | extra=8 # spare space | |
14 | boot=112 | 14 | boot=112 | |
15 | init=8 | 15 | init=8 | |
16 | 16 | |||
17 | size=$(( 10485760 + ${swap} * 1024 * 512 + ${boot} * 1024 * 512 + ${init} * 1024 * 512 )) | 17 | size=$(( 10485760 + ${swap} * 1024 * 512 + ${boot} * 1024 * 512 + ${init} * 1024 * 512 )) | |
18 | msdosid=12 | 18 | msdosid=12 | |
19 | 19 | |||
20 | make_label() { | 20 | make_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 | |
40 | type: SCSI | 40 | type: SCSI | |
41 | disk: STORAGE DEVICE | 41 | disk: STORAGE DEVICE | |
42 | label: fictitious | 42 | label: fictitious | |
43 | flags: removable | 43 | flags: removable | |
44 | bytes/sector: ${bps} | 44 | bytes/sector: ${bps} | |
45 | sectors/track: ${spt} | 45 | sectors/track: ${spt} | |
46 | tracks/cylinder: ${tpc} | 46 | tracks/cylinder: ${tpc} | |
47 | sectors/cylinder: ${spc} | 47 | sectors/cylinder: ${spc} | |
48 | cylinders: ${cylinders} | 48 | cylinders: ${cylinders} | |
49 | total sectors: ${totalsize} | 49 | total sectors: ${totalsize} | |
50 | rpm: 3600 | 50 | rpm: 3600 | |
51 | interleave: 1 | 51 | interleave: 1 | |
52 | trackskew: 0 | 52 | trackskew: 0 | |
53 | cylinderskew: 0 | 53 | cylinderskew: 0 | |
54 | headswitch: 0 # microseconds | 54 | headswitch: 0 # microseconds | |
55 | track-to-track seek: 0 # microseconds | 55 | track-to-track seek: 0 # microseconds | |
56 | drivedata: 0 | 56 | drivedata: 0 | |
57 | 57 | |||
58 | 8 partitions: | 58 | 8 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 # | |
64 | EOF | 64 | EOF | |
65 | } | 65 | } | |
66 | 66 | |||
67 | customize() { | 67 | customize() { | |
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 | |||
72 | make_fstab() { | 72 | make_fstab() { | |
73 | : | 73 | : | |
74 | } | 74 | } | |
75 | 75 | |||
76 | firmwaredir=$src/external/broadcom/rpi-firmware/dist | 76 | firmwaredir=$src/external/broadcom/rpi-firmware/dist | |
77 | firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" | 77 | firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" | |
78 | 78 | |||
79 | populate() { | 79 | populate() { | |
80 | cat > ${mnt}/boot/cmdline.txt << EOF | 80 | cat > ${mnt}/boot/cmdline.txt << EOF | |
81 | root=ld0a console=fb | 81 | root=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 | |
84 | EOF | 84 | EOF | |
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 | |
88 | enable_uart=1 | 88 | enable_uart=1 | |
89 | force_turbo=0 | 89 | force_turbo=0 | |
90 | EOF | 90 | EOF | |
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 | } |
--- 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 | |||
5 | image=$HOME/${board}.img | 5 | image=$HOME/${board}.img | |
6 | MACHINE=${board} | 6 | MACHINE=${board} | |
7 | kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd | 7 | kernel=$src/sys/arch/${board}/compile/GENERIC/netbsd | |
8 | bootfile=$release/usr/mdec/boot | 8 | bootfile=$release/usr/mdec/boot | |
9 | 9 | |||
10 | extra=8 # spare space | 10 | extra=8 # spare space | |
11 | size=0 # autocompute | 11 | size=0 # autocompute | |
12 | netbsdid=169 | 12 | netbsdid=169 | |
13 | init=63 | 13 | init=63 | |
14 | ffsoffset=${init}b | 14 | ffsoffset=${init}b | |
15 | 15 | |||
16 | make_label() { | 16 | make_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 | |
30 | type: SCSI | 30 | type: SCSI | |
31 | disk: STORAGE DEVICE | 31 | disk: STORAGE DEVICE | |
32 | label: fictitious | 32 | label: fictitious | |
33 | flags: removable | 33 | flags: removable | |
34 | bytes/sector: ${bps} | 34 | bytes/sector: ${bps} | |
35 | sectors/track: ${spt} | 35 | sectors/track: ${spt} | |
36 | tracks/cylinder: ${tpc} | 36 | tracks/cylinder: ${tpc} | |
37 | sectors/cylinder: ${spc} | 37 | sectors/cylinder: ${spc} | |
38 | cylinders: ${cylinders} | 38 | cylinders: ${cylinders} | |
39 | total sectors: ${totalsize} | 39 | total sectors: ${totalsize} | |
40 | rpm: 3600 | 40 | rpm: 3600 | |
41 | interleave: 1 | 41 | interleave: 1 | |
42 | trackskew: 0 | 42 | trackskew: 0 | |
43 | cylinderskew: 0 | 43 | cylinderskew: 0 | |
44 | headswitch: 0 # microseconds | 44 | headswitch: 0 # microseconds | |
45 | track-to-track seek: 0 # microseconds | 45 | track-to-track seek: 0 # microseconds | |
46 | drivedata: 0 | 46 | drivedata: 0 | |
47 | 47 | |||
48 | 8 partitions: | 48 | 8 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 # | |
53 | EOF | 53 | EOF | |
54 | } | 54 | } | |
55 | 55 | |||
56 | make_fstab_normal() { | 56 | make_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 | |
61 | kernfs /kern kernfs rw | 61 | kernfs /kern kernfs rw | |
62 | ptyfs /dev/pts ptyfs rw | 62 | ptyfs /dev/pts ptyfs rw | |
63 | procfs /proc procfs rw | 63 | procfs /proc procfs rw | |
64 | EOF | 64 | EOF | |
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 | |
70 | make_fstab_minwrites() { | 70 | make_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 | |
75 | kernfs /kern kernfs rw | 75 | kernfs /kern kernfs rw | |
76 | ptyfs /dev/pts ptyfs rw | 76 | ptyfs /dev/pts ptyfs rw | |
77 | procfs /proc procfs rw | 77 | procfs /proc procfs rw | |
78 | tmpfs /tmp tmpfs rw,-s32M | 78 | tmpfs /tmp tmpfs rw,-s32M | |
79 | tmpfs /var/log tmpfs rw,union,-s32M | 79 | tmpfs /var/log tmpfs rw,union,-s32M | |
80 | tmpfs /var/run tmpfs rw,union,-s1M | 80 | tmpfs /var/run tmpfs rw,union,-s1M | |
81 | tmpfs /var/mail tmpfs rw,union,-s10M | 81 | tmpfs /var/mail tmpfs rw,union,-s10M | |
82 | tmpfs /var/spool/postfix tmpfs rw,union,-s20M | 82 | tmpfs /var/spool/postfix tmpfs rw,union,-s20M | |
83 | tmpfs /var/db/postfix tmpfs rw,union,-s1M | 83 | tmpfs /var/db/postfix tmpfs rw,union,-s1M | |
84 | tmpfs /var/chroot tmpfs rw,union,-s10M | 84 | tmpfs /var/chroot tmpfs rw,union,-s10M | |
85 | EOF | 85 | EOF | |
86 | } | 86 | } | |
87 | 87 | |||
88 | make_fstab() { | 88 | make_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 | |||
103 | customize() { | 103 | customize() { | |
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 | |
112 | rc_configured=YES | 112 | rc_configured=YES | |
113 | hostname=${board} | 113 | hostname=${board} | |
114 | sshd=YES | 114 | sshd=YES | |
115 | dhcpcd=YES | 115 | dhcpcd=YES | |
116 | wscons=YES | 116 | wscons=YES | |
117 | devpubd=YES | 117 | devpubd=YES | |
118 | EOF | 118 | EOF | |
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 | |||
131 | populate() { | 131 | populate() { | |
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 | } |