Home | History | Annotate | Line # | Download | only in conf
riscv.conf revision 1.3
      1 # $NetBSD: riscv.conf,v 1.3 2024/12/27 19:02:19 christos Exp $
      2 # riscv shared config
      3 #
      4 image=$HOME/${board}.img
      5 
      6 extra=48		# spare space
      7 init=32
      8 boot=$((192 - ${init}))
      9 ffsoffset=$(( (${init} + ${boot}) / 2 ))m
     10 
     11 size=0		# autocompute
     12 msdosid=12
     13 
     14 if $gpt; then
     15 	partition_type="gpt"
     16 else
     17 	partition_type="disklabel"
     18 fi
     19 
     20 mkdir -p ${mnt}/boot
     21 
     22 make_label_riscv() {
     23 	# compute all sizes in terms of sectors
     24 	local totalsize=$(( ${size} / 512 ))
     25 
     26 	local bootsize=$(( ${boot} * 1024 ))
     27 
     28 	local bootoffset=$(( ${init} * 1024 ))
     29 
     30 	local asize=$(( ${totalsize} - ${bootsize} - ${bootoffset} ))
     31 	local aoffset=$(( ${bootoffset} + ${bootsize} ))
     32 
     33 	local bps=512
     34 	local spt=32
     35 	local tpc=64
     36 	local spc=2048
     37 	local cylinders=$(( ${totalsize} / ${spc} ))
     38 
     39 	cat << EOF
     40 type: SCSI
     41 disk: STORAGE DEVICE
     42 label: fictitious
     43 flags: removable
     44 bytes/sector: ${bps}
     45 sectors/track: ${spt}
     46 tracks/cylinder: ${tpc}
     47 sectors/cylinder: ${spc}
     48 cylinders: ${cylinders}
     49 total sectors: ${totalsize}
     50 rpm: 3600
     51 interleave: 1
     52 trackskew: 0
     53 cylinderskew: 0
     54 headswitch: 0           # microseconds
     55 track-to-track seek: 0  # microseconds
     56 drivedata: 0
     57 
     58 8 partitions:
     59 #     size         offset        fstype [fsize bsize cpg/sgs]
     60  a:   ${asize}     ${aoffset}    4.2BSD  ${fsize} ${bsize} 0  #
     61  c:   ${totalsize} 0             unused      0     0          #
     62  e:   ${bootsize}  ${bootoffset} MSDOS                        #
     63 EOF
     64 }
     65 
     66 make_fstab_riscv() {
     67 	make_fstab_default EFI
     68 }
     69 
     70 customize_riscv() {
     71 	cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
     72 	cat >> ${mnt}/etc/rc.conf << EOF
     73 dev_exists() {
     74 	if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then
     75 		printf YES
     76 	else
     77 		printf NO
     78 	fi
     79 }
     80 
     81 rc_configured=YES
     82 hostname=${hostname:-${board}}
     83 no_swap=YES
     84 savecore=NO
     85 sshd=YES
     86 dhcpcd=YES
     87 ntpd=YES
     88 ntpd_flags="-g"
     89 creds_msdos=YES
     90 creds_msdos_partition=/boot
     91 certctl_init=YES
     92 EOF
     93 
     94 	if $resize; then
     95 		cat >> ${mnt}/etc/rc.conf << EOF
     96 resize_${partition_type}=YES
     97 resize_root=YES
     98 resize_root_flags="-p"
     99 resize_root_postcmd="/sbin/reboot -n"
    100 EOF
    101 	fi
    102 
    103 	echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
    104 	    >> "$tmp/selected_sets"
    105 
    106 	mkdir ${mnt}/etc/rc.d
    107 	for _f in resize_${partition_type} creds_msdos; do
    108 		cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f}
    109 		echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \
    110 		    >> "$tmp/selected_sets"
    111 	done
    112 
    113 	if [ ! -f ${release}/dev/MAKEDEV ]; then
    114 		echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
    115 		exit 1
    116 	fi
    117 	echo "${bar} running MAKEDEV ${bar}"
    118 	${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
    119 	    >> "$tmp/selected_sets"
    120 
    121 	echo "${bar} fixing up permissions"
    122 	echo "./boot type=dir uname=root gname=wheel mode=0755" \
    123 	    >> "$tmp/selected_sets"
    124 }
    125