Home | History | Annotate | Line # | Download | only in conf
armv7.conf revision 1.21
      1 # $NetBSD: armv7.conf,v 1.21 2017/11/30 19:55:47 jmcneill Exp $
      2 # ARMv7 customization script used by mkimage
      3 #
      4 board=armv7
      5 console=fb
      6 resize=true
      7 
      8 . ${DIR}/conf/evbarm.conf
      9 
     10 kernels_beagle="BEAGLEBOARD BEAGLEBONE"
     11 kernels_rpi="RPI2"
     12 kernels_amlogic="ODROID-C1"
     13 kernels_tegra="TEGRA"
     14 kernels_sunxi="SUNXI"
     15 
     16 make_label() {
     17 	make_label_evbarm
     18 }
     19 
     20 make_fstab() {
     21 	make_fstab_evbarm
     22 }
     23 
     24 customize() {
     25 	customize_evbarm
     26 	cat >> "${mnt}/etc/rc.conf" << EOF
     27 mdnsd=YES
     28 wscons=YES
     29 devpubd=YES
     30 EOF
     31 }
     32 
     33 populate_common() {
     34 	# Install boot script
     35 	cp ${DIR}/files/armv7_boot.cmd ${mnt}/boot/boot.cmd
     36 	"${MKUBOOTIMAGE}" -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/armv7 boot" "${mnt}/boot/boot.cmd" "${mnt}/boot/boot.scr"
     37 }
     38 
     39 populate_beagle() {
     40 	:
     41 }
     42 
     43 populate_rpi() {
     44 	firmwaredir="${src}/external/broadcom/rpi-firmware/dist"
     45 	firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
     46 
     47 	# RPI2 kernel needs to be installed as kernel7.img
     48 	if [ -f "${mnt}/boot/netbsd-RPI2.bin" ]; then
     49 		echo "${bar} renaming netbsd-RPI2.bin to kernel7.img ${bar}"
     50 		mv "${mnt}/boot/netbsd-RPI2.bin" "${mnt}/boot/kernel7.img"
     51 
     52 		cat > "${mnt}/boot/cmdline.txt" << EOF
     53 root=ld0a console=${console}
     54 #fb=1280x1024		# to select a mode, otherwise try EDID
     55 #fb=disable		# to disable fb completely
     56 EOF
     57 
     58 		cat > ${mnt}/boot/config.txt << EOF
     59 # UART settings, see https://www.raspberrypi.org/documentation/configuration/uart.md
     60 enable_uart=1
     61 force_turbo=0
     62 EOF
     63 
     64 	        echo "${bar} installing firmware files ${bar}"
     65 		(cd "${mnt}/boot" &&
     66 			for f in ${firmwarefiles}; do
     67 				echo " $f"
     68 				cp "${firmwaredir}/${f}" .
     69 			done
     70         	)
     71 
     72 	fi
     73 
     74 	#
     75 	# If arm_freq is specified in config.txt, set CPU frequency
     76 	# to match at boot time.
     77 	#
     78 	cp ${release}/etc/rc.local ${mnt}/etc/rc.local
     79 	cat >> ${mnt}/etc/rc.local << EOF
     80 if /sbin/sysctl -q machdep.cpu.frequency.max; then
     81 	cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
     82 	cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
     83 	if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
     84 		/sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
     85 	fi
     86 fi
     87 EOF
     88 	echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
     89 	    >> "$tmp/selected_sets"
     90 }
     91 
     92 populate_amlogic() {
     93 	odroidc1_kernelimg=netbsd-ODROID-C1.ub
     94 
     95 	# Create a boot.ini for Amlogic U-Boot
     96 	cat >> "${mnt}/boot/boot.ini" << EOF
     97 ODROIDC-UBOOT-CONFIG
     98 
     99 setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}"
    100 setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000"
    101 run bootcmd
    102 EOF
    103 }
    104 
    105 populate_sunxi() {
    106 	:
    107 }
    108 
    109 populate_tegra() {
    110 	:
    111 }
    112 
    113 populate() {
    114 	echo "${bar} looking for kernels in ${kernel} ${bar}"
    115 	kernels=""
    116 	# .ub kernels
    117 	for k in $kernels_beagle $kernels_sunxi $kernels_amlogic $kernels_tegra; do
    118 		f="${kernel}/netbsd-${k}.ub.gz"
    119 		test -f "${f}" && kernels="${kernels} ${f}"
    120 	done
    121 	# .bin kernels
    122 	for k in $kernels_rpi; do
    123 		f="${kernel}/netbsd-${k}.bin.gz"
    124 		test -f "${f}" && kernels="${kernels} ${f}"
    125 	done
    126 	# .dtb files
    127 	for k in $kernels_sunxi $kernels_tegra; do
    128 		test -d "${KERNOBJDIR}/${k}" && \
    129 		    dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
    130 		    dtbs=
    131 		for dtb in $dtbs; do
    132 			f="${kernel}/${dtb}.gz"
    133 			test -f "${f}" && kernels="${kernels} ${f}"
    134 		done
    135 	done
    136 
    137 	# install kernels to /boot partition
    138 	for k in ${kernels}; do
    139 		tgt="$(basename ${k} | sed 's/\.gz$//')"
    140 		echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
    141 		case "${k}" in
    142 		*.gz)
    143 			${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
    144 			;;
    145 		*)
    146 			cp "${k}" "${mnt}/boot/${tgt}"
    147 			;;
    148 		esac ||
    149 			fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
    150 	done
    151 
    152 	# board specific configuration
    153 	populate_beagle
    154 	populate_rpi
    155 	populate_amlogic
    156 	populate_tegra
    157 	populate_sunxi
    158 
    159 	# common configuration
    160 	populate_common
    161 }
    162