# $NetBSD: rpi.conf,v 1.34 2017/12/12 21:00:28 jmcneill Exp $
# Raspberry Pi customization script used by mkimage
#
board=rpi
kerneldir=$src/sys/arch/evbarm/compile/RPI/
kernel=$kerneldir/netbsd-RPI.img
kernels_rpi="RPI RPI2"
resize=true
. ${DIR}/conf/evbarm.conf
firmwaredir=$src/external/broadcom/rpi-firmware/dist
firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
make_fstab() {
make_fstab_evbarm
}
make_label() {
make_label_evbarm
}
customize() {
customize_evbarm
cat >> ${mnt}/etc/rc.conf << EOF
wscons=YES
devpubd=YES
EOF
#
# If arm_freq is specified in config.txt, set CPU frequency
# to match at boot time.
#
cp ${release}/etc/rc.local ${mnt}/etc/rc.local
cat >> ${mnt}/etc/rc.local << EOF
if /sbin/sysctl -q machdep.cpu.frequency.max; then
cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
/sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
fi
fi
EOF
echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
>> "$tmp/selected_sets"
}
populate() {
rpi2_kernel="$(echo $kernel | sed 's/RPI/RPI2/g')"
cat > ${mnt}/boot/cmdline.txt << EOF
root=ld0a console=fb
#fb=1280x1024 # to select a mode, otherwise try EDID
#fb=disable # to disable fb completely
EOF
cat > ${mnt}/boot/config.txt << EOF
# UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
enable_uart=1
force_turbo=0
EOF
echo "${bar} kernel ${kernel} ${bar}"
if [ ! -f ${kernel} ]; then
echo ${PROG}: Missing ${kernel} 1>&2
exit 1
fi
# .img files
echo "${bar} installing RPI kernel ${bar}"
case ${kernel} in
*.gz)
gzip -dc ${kernel} > ${mnt}/boot/kernel.img
;;
*)
cp ${kernel} ${mnt}/boot/kernel.img
;;
esac || fail "copy of ${kernel} to ${mnt}/boot/kernel.img failed"
echo "${bar} installing RPI2 kernel ${bar}"
case ${rpi2_kernel} in
*.gz)
gzip -dc ${rpi2_kernel} > ${mnt}/boot/kernel7.img
;;
*)
cp ${rpi2_kernel} ${mnt}/boot/kernel7.img
;;
esac || fail "Copy of ${rpi2_kernel} to ${mnt}/boot/kernel7.img failed"
# dtb files
for k in $kernels_rpi; do
test -d "${KERNOBJDIR}/${k}" && \
dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
dtbs=
for dtb in $dtbs; do
f="${KERNOBJDIR}/${k}/${dtb}"
test -f "${f}" && kernels="${kernels} ${f}"
done
done
echo "${bar} installing kernel files ${bar}"
# install kernels to /boot partition
for k in ${kernels}; do
tgt="$(basename ${k} | sed 's/\.gz$//')"
echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
case "${k}" in
*.gz)
${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
;;
*)
cp "${k}" "${mnt}/boot/${tgt}"
;;
esac
done
echo "${bar} installing firmware files ${bar}"
(cd ${mnt}/boot &&
for f in ${firmwarefiles}; do
echo " $f"
cp ${firmwaredir}/${f} . || exit 1
done
) || fail "Copy of firmware into ${mnt}/boot failed"
}