Home | History | Annotate | Line # | Download | only in conf
rpi.conf revision 1.34.4.1
      1  1.34.4.1    martin # $NetBSD: rpi.conf,v 1.34.4.1 2020/04/08 14:03:55 martin Exp $
      2      1.11  jakllsch # Raspberry Pi customization script used by mkimage
      3       1.1  christos #
      4       1.9  christos 
      5       1.9  christos board=rpi
      6      1.33  jmcneill kerneldir=$src/sys/arch/evbarm/compile/RPI/
      7  1.34.4.1    martin kernel=$kerneldir/netbsd-RPI.bin
      8      1.33  jmcneill kernels_rpi="RPI RPI2"
      9      1.28  jmcneill resize=true
     10       1.9  christos 
     11       1.9  christos . ${DIR}/conf/evbarm.conf
     12       1.1  christos 
     13       1.1  christos firmwaredir=$src/external/broadcom/rpi-firmware/dist
     14       1.1  christos firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
     15       1.1  christos 
     16       1.1  christos make_fstab() {
     17       1.9  christos 	make_fstab_evbarm
     18       1.1  christos }
     19       1.1  christos 
     20      1.13  christos make_label() {
     21      1.13  christos 	make_label_evbarm
     22      1.13  christos }
     23      1.13  christos 
     24       1.1  christos customize() {
     25       1.9  christos 	customize_evbarm
     26      1.13  christos 	cat >> ${mnt}/etc/rc.conf << EOF
     27       1.1  christos wscons=YES
     28      1.20  jmcneill devpubd=YES
     29       1.1  christos EOF
     30       1.1  christos 
     31      1.25  jmcneill 	#
     32      1.25  jmcneill 	# If arm_freq is specified in config.txt, set CPU frequency
     33      1.25  jmcneill 	# to match at boot time.
     34      1.25  jmcneill 	#
     35      1.25  jmcneill 	cp ${release}/etc/rc.local ${mnt}/etc/rc.local
     36      1.26  jmcneill 	cat >> ${mnt}/etc/rc.local << EOF
     37      1.25  jmcneill if /sbin/sysctl -q machdep.cpu.frequency.max; then
     38      1.25  jmcneill 	cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
     39      1.25  jmcneill 	cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
     40      1.25  jmcneill 	if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
     41      1.25  jmcneill 		/sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
     42      1.25  jmcneill 	fi
     43      1.25  jmcneill fi
     44      1.25  jmcneill EOF
     45      1.25  jmcneill 	echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
     46      1.25  jmcneill 	    >> "$tmp/selected_sets"
     47      1.13  christos }
     48      1.13  christos 
     49      1.13  christos populate() {
     50  1.34.4.1    martin 	rpi2_kernel="$(echo $kernel | sed -e 's/RPI/RPI2/g')"
     51      1.27     skrll 
     52      1.13  christos 	cat > ${mnt}/boot/cmdline.txt << EOF
     53      1.24     skrll root=ld0a console=fb
     54      1.31     skrll #fb=1280x1024		# to select a mode, otherwise try EDID
     55       1.1  christos #fb=disable		# to disable fb completely
     56       1.1  christos EOF
     57      1.30  jmcneill 
     58      1.30  jmcneill 	cat > ${mnt}/boot/config.txt << EOF
     59  1.34.4.1    martin #
     60  1.34.4.1    martin upstream_kernel=1
     61      1.30  jmcneill # UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
     62      1.30  jmcneill enable_uart=1
     63      1.30  jmcneill force_turbo=0
     64      1.30  jmcneill EOF
     65      1.30  jmcneill 
     66      1.33  jmcneill 	echo "${bar} kernel ${kernel} ${bar}"
     67      1.33  jmcneill 
     68      1.14  christos 	if [ ! -f ${kernel} ]; then
     69      1.14  christos 		echo ${PROG}: Missing ${kernel} 1>&2
     70      1.10     skrll 		exit 1
     71      1.10     skrll 	fi
     72      1.10     skrll 
     73      1.33  jmcneill 	# .img files
     74      1.27     skrll 	echo "${bar} installing RPI kernel ${bar}"
     75      1.16  christos 	case ${kernel} in
     76      1.16  christos 	*.gz)
     77      1.19       riz 		gzip -dc ${kernel} > ${mnt}/boot/kernel.img
     78      1.16  christos 		;;
     79      1.16  christos 	*)
     80      1.16  christos 		cp ${kernel} ${mnt}/boot/kernel.img
     81      1.16  christos 		;;
     82      1.32       kre 	esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
     83      1.10     skrll 
     84      1.27     skrll 	echo "${bar} installing RPI2 kernel ${bar}"
     85      1.27     skrll 	case ${rpi2_kernel} in
     86      1.27     skrll 	*.gz)
     87      1.27     skrll 		gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img
     88      1.27     skrll 		;;
     89      1.27     skrll 	*)
     90      1.32       kre 		cp ${rpi2_kernel} ${mnt}/boot/kernel7.img
     91      1.27     skrll 		;;
     92      1.32       kre 	esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed"
     93      1.27     skrll 
     94      1.33  jmcneill 	# dtb files
     95      1.33  jmcneill 	for k in $kernels_rpi; do
     96      1.33  jmcneill 		test -d "${KERNOBJDIR}/${k}" && \
     97      1.33  jmcneill 		    dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
     98      1.33  jmcneill 		    dtbs=
     99      1.33  jmcneill 		for dtb in $dtbs; do
    100      1.33  jmcneill 			f="${KERNOBJDIR}/${k}/${dtb}"
    101      1.33  jmcneill 			test -f "${f}" && kernels="${kernels} ${f}"
    102      1.33  jmcneill 		done
    103      1.33  jmcneill 	done
    104      1.33  jmcneill 
    105      1.33  jmcneill 	echo "${bar} installing kernel files ${bar}"
    106      1.33  jmcneill 	# install kernels to /boot partition
    107      1.33  jmcneill 	for k in ${kernels}; do
    108      1.33  jmcneill 		tgt="$(basename ${k} | sed 's/\.gz$//')"
    109      1.33  jmcneill 		echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
    110      1.33  jmcneill 		case "${k}" in
    111      1.33  jmcneill 		*.gz)
    112      1.33  jmcneill 			${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
    113      1.33  jmcneill 			;;
    114      1.33  jmcneill 		*)
    115      1.33  jmcneill 			cp "${k}" "${mnt}/boot/${tgt}"
    116      1.33  jmcneill 			;;
    117      1.33  jmcneill 		esac
    118      1.33  jmcneill 	done
    119      1.33  jmcneill 
    120      1.17  jmcneill 	echo "${bar} installing firmware files ${bar}"
    121       1.1  christos 	(cd ${mnt}/boot &&
    122       1.1  christos 		for f in ${firmwarefiles}; do
    123      1.17  jmcneill 			echo " $f"
    124      1.32       kre 			cp ${firmwaredir}/${f} . || exit 1
    125       1.1  christos 		done
    126      1.34  jmcneill 	) || fail "Copy of firmware into ${mnt}/boot failed"
    127       1.1  christos 
    128       1.1  christos }
    129