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