1 1.32 kre # $NetBSD: rpi.conf,v 1.32 2017/11/28 02:56:44 kre 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.16 christos kernel=$src/sys/arch/evbarm/compile/RPI/netbsd-RPI.bin 7 1.28 jmcneill resize=true 8 1.9 christos 9 1.9 christos . ${DIR}/conf/evbarm.conf 10 1.1 christos 11 1.1 christos firmwaredir=$src/external/broadcom/rpi-firmware/dist 12 1.1 christos firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf" 13 1.1 christos 14 1.1 christos make_fstab() { 15 1.9 christos make_fstab_evbarm 16 1.1 christos } 17 1.1 christos 18 1.13 christos make_label() { 19 1.13 christos make_label_evbarm 20 1.13 christos } 21 1.13 christos 22 1.1 christos customize() { 23 1.9 christos customize_evbarm 24 1.13 christos cat >> ${mnt}/etc/rc.conf << EOF 25 1.1 christos wscons=YES 26 1.20 jmcneill devpubd=YES 27 1.1 christos EOF 28 1.1 christos 29 1.25 jmcneill # 30 1.25 jmcneill # If arm_freq is specified in config.txt, set CPU frequency 31 1.25 jmcneill # to match at boot time. 32 1.25 jmcneill # 33 1.25 jmcneill cp ${release}/etc/rc.local ${mnt}/etc/rc.local 34 1.26 jmcneill cat >> ${mnt}/etc/rc.local << EOF 35 1.25 jmcneill if /sbin/sysctl -q machdep.cpu.frequency.max; then 36 1.25 jmcneill cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max) 37 1.25 jmcneill cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current) 38 1.25 jmcneill if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then 39 1.25 jmcneill /sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max 40 1.25 jmcneill fi 41 1.25 jmcneill fi 42 1.25 jmcneill EOF 43 1.25 jmcneill echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \ 44 1.25 jmcneill >> "$tmp/selected_sets" 45 1.13 christos } 46 1.13 christos 47 1.13 christos populate() { 48 1.27 skrll rpi2_kernel="$(echo $kernel | sed 's/RPI/RPI2/g')" 49 1.27 skrll 50 1.13 christos cat > ${mnt}/boot/cmdline.txt << EOF 51 1.24 skrll root=ld0a console=fb 52 1.31 skrll #fb=1280x1024 # to select a mode, otherwise try EDID 53 1.1 christos #fb=disable # to disable fb completely 54 1.1 christos EOF 55 1.30 jmcneill 56 1.30 jmcneill cat > ${mnt}/boot/config.txt << EOF 57 1.30 jmcneill # UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md 58 1.30 jmcneill enable_uart=1 59 1.30 jmcneill force_turbo=0 60 1.30 jmcneill EOF 61 1.30 jmcneill 62 1.14 christos if [ ! -f ${kernel} ]; then 63 1.14 christos echo ${PROG}: Missing ${kernel} 1>&2 64 1.10 skrll exit 1 65 1.10 skrll fi 66 1.10 skrll 67 1.27 skrll echo "${bar} installing RPI kernel ${bar}" 68 1.16 christos case ${kernel} in 69 1.16 christos *.gz) 70 1.19 riz gzip -dc ${kernel} > ${mnt}/boot/kernel.img 71 1.16 christos ;; 72 1.16 christos *) 73 1.16 christos cp ${kernel} ${mnt}/boot/kernel.img 74 1.16 christos ;; 75 1.32 kre esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed" 76 1.10 skrll 77 1.27 skrll echo "${bar} installing RPI2 kernel ${bar}" 78 1.27 skrll case ${rpi2_kernel} in 79 1.27 skrll *.gz) 80 1.27 skrll gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img 81 1.27 skrll ;; 82 1.27 skrll *) 83 1.32 kre cp ${rpi2_kernel} ${mnt}/boot/kernel7.img 84 1.27 skrll ;; 85 1.32 kre esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed" 86 1.27 skrll 87 1.17 jmcneill echo "${bar} installing firmware files ${bar}" 88 1.1 christos (cd ${mnt}/boot && 89 1.1 christos for f in ${firmwarefiles}; do 90 1.17 jmcneill echo " $f" 91 1.32 kre cp ${firmwaredir}/${f} . || exit 1 92 1.1 christos done 93 1.32 kre ) || fail "Copy of firmeware into ${mnt}/boot failed" 94 1.1 christos 95 1.1 christos } 96