xref: /netbsd-src/distrib/utils/embedded/conf/evbarm.conf (revision a04395531661c5e8d314125d5ae77d4cbedd5d73)
1# $NetBSD: evbarm.conf,v 1.39 2021/07/06 11:49:36 jmcneill Exp $
2# evbarm shared config
3#
4image=$HOME/${board}.img
5
6MACHINE=evbarm
7
8extra=48		# spare space
9init=32
10boot=$((192 - ${init}))
11ffsoffset=$(( (${init} + ${boot}) / 2 ))m
12
13size=0		# autocompute
14msdosid=12
15
16if $gpt; then
17	partition_type="gpt"
18else
19	partition_type="disklabel"
20fi
21
22mkdir -p ${mnt}/boot
23
24make_label_evbarm() {
25	# compute all sizes in terms of sectors
26	local totalsize=$(( ${size} / 512 ))
27
28	local bootsize=$(( ${boot} * 1024 ))
29
30	local bootoffset=$(( ${init} * 1024 ))
31
32	local asize=$(( ${totalsize} - ${bootsize} - ${bootoffset} ))
33	local aoffset=$(( ${bootoffset} + ${bootsize} ))
34
35	local bps=512
36	local spt=32
37	local tpc=64
38	local spc=2048
39	local cylinders=$(( ${totalsize} / ${spc} ))
40
41	cat << EOF
42type: SCSI
43disk: STORAGE DEVICE
44label: fictitious
45flags: removable
46bytes/sector: ${bps}
47sectors/track: ${spt}
48tracks/cylinder: ${tpc}
49sectors/cylinder: ${spc}
50cylinders: ${cylinders}
51total sectors: ${totalsize}
52rpm: 3600
53interleave: 1
54trackskew: 0
55cylinderskew: 0
56headswitch: 0           # microseconds
57track-to-track seek: 0  # microseconds
58drivedata: 0 
59
608 partitions:
61#     size         offset        fstype [fsize bsize cpg/sgs]
62 a:   ${asize}     ${aoffset}    4.2BSD  ${fsize} ${bsize} 0  # 
63 c:   ${totalsize} 0             unused      0     0          #
64 e:   ${bootsize}  ${bootoffset} MSDOS                        #
65EOF
66}
67
68make_fstab_evbarm_gpt() {
69	cat > ${mnt}/etc/fstab << EOF
70# NetBSD /etc/fstab
71# See /usr/share/examples/fstab/ for more examples.
72NAME=${gpt_label_ffs:-netbsd-root}	/		ffs	rw,noatime	1 1
73NAME=${gpt_label_boot:-EFI}		/boot		msdos	rw	1 1
74ptyfs		/dev/pts	ptyfs	rw
75procfs		/proc		procfs	rw
76tmpfs		/var/shm	tmpfs	rw,-m1777,-sram%25
77EOF
78}
79
80make_fstab_evbarm_normal() {
81	cat > ${mnt}/etc/fstab << EOF
82# NetBSD /etc/fstab
83# See /usr/share/examples/fstab/ for more examples.
84ROOT.a		/		ffs	rw,noatime	1 1
85ROOT.e		/boot		msdos	rw	1 1
86ptyfs		/dev/pts	ptyfs	rw
87procfs		/proc		procfs	rw
88tmpfs		/var/shm	tmpfs	rw,-m1777,-sram%25
89EOF
90}
91
92# From Richard Neswold's:
93# http://rich-tbp.blogspot.com/2013/03/netbsd-on-rpi-minimizing-disk-writes.html
94# Also for the postfix stuff below
95make_fstab_evbarm_minwrites() {
96	cat > ${mnt}/etc/fstab << EOF
97# NetBSD /etc/fstab
98# See /usr/share/examples/fstab/ for more examples.
99ROOT.a		/			ffs	rw,log,noatime,nodevmtime 1 1
100ROOT.e		/boot			msdos	rw			  1 1
101ptyfs		/dev/pts		ptyfs	rw
102procfs		/proc			procfs	rw
103tmpfs		/tmp			tmpfs	rw,-s32M
104tmpfs		/var/log		tmpfs	rw,union,-s32M
105tmpfs		/var/run		tmpfs	rw,union,-s1M
106tmpfs		/var/mail		tmpfs	rw,union,-s10M
107tmpfs		/var/spool/postfix	tmpfs	rw,union,-s20M
108tmpfs		/var/db/postfix		tmpfs	rw,union,-s1M
109tmpfs		/var/chroot		tmpfs	rw,union,-s10M
110tmpfs		/var/shm		tmpfs	rw,-m1777,-sram%25
111EOF
112}
113
114make_fstab_evbarm() {
115	if $gpt; then
116		make_fstab_evbarm_gpt
117	elif $minwrites; then
118		make_fstab_evbarm_minwrites
119	else
120		make_fstab_evbarm_normal
121	fi
122	echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \
123	    >> "$tmp/selected_sets"
124
125	# Missing mount points from fstab
126	echo "./proc type=dir uname=root gname=wheel mode=0755" \
127	    >> "$tmp/selected_sets"
128}
129
130customize_evbarm() {
131	if $minwrites; then
132		mkdir ${mnt}/etc/postfix
133		(umask 022
134		sed -e 's/fifo/unix/' < ${release}/etc/postfix/master.cf > \
135		    ${mnt}/etc/postfix/master.cf)
136	fi
137
138	cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
139	cat >> ${mnt}/etc/rc.conf << EOF
140dev_exists() {
141	if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then
142		printf YES
143	else
144		printf NO
145	fi
146}
147
148rc_configured=YES
149hostname=${hostname:-${board}}
150no_swap=YES
151savecore=NO
152sshd=YES
153dhcpcd=YES
154ntpd=YES
155ntpd_flags="-g"
156creds_msdos=YES
157creds_msdos_partition=/boot
158EOF
159
160	if $resize; then
161		cat >> ${mnt}/etc/rc.conf << EOF
162resize_${partition_type}=YES
163resize_root=YES
164resize_root_flags="-p"
165resize_root_postcmd="/sbin/reboot -n"
166EOF
167	fi
168
169	echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
170	    >> "$tmp/selected_sets"
171
172	mkdir ${mnt}/etc/rc.d
173	for _f in resize_${partition_type} creds_msdos; do
174		cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f}
175		echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \
176		    >> "$tmp/selected_sets"
177	done
178
179	if [ ! -f ${release}/dev/MAKEDEV ]; then
180		echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
181		exit 1
182	fi
183	echo "${bar} running MAKEDEV ${bar}"
184	${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
185	    >> "$tmp/selected_sets"
186
187	echo "${bar} fixing up permissions"
188	echo "./boot type=dir uname=root gname=wheel mode=0755" \
189	    >> "$tmp/selected_sets"
190}
191