Home | History | Annotate | Line # | Download | only in conf
armv7.conf revision 1.15
      1 # $NetBSD: armv7.conf,v 1.15 2017/07/09 10:41:40 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_awin="BPI CUBIEBOARD CUBIETRUCK"
     12 kernels_rpi="RPI2"
     13 kernels_amlogic="ODROID-C1"
     14 kernels_tegra="TEGRA"
     15 kernels_sunxi="SUNXI"
     16 
     17 make_label() {
     18 	make_label_evbarm
     19 }
     20 
     21 make_fstab() {
     22 	make_fstab_evbarm
     23 }
     24 
     25 customize() {
     26 	customize_evbarm
     27 	cat >> "${mnt}/etc/rc.conf" << EOF
     28 mdnsd=YES
     29 wscons=YES
     30 devpubd=YES
     31 EOF
     32 }
     33 
     34 populate_beagle() {
     35 	bboard_kernelimg=netbsd-BEAGLEBOARD.ub
     36 	bboard_loadaddr=81000000
     37 	bbone_kernelimg=netbsd-BEAGLEBONE.ub
     38 	bbone_loadaddr=82000000
     39 
     40 	# Create a uEnv.txt to auto boot the correct kernel
     41 	cat >> "${mnt}/boot/uEnv.txt" << EOF
     42 loaduimage=if test \$board = am335x; then fatload mmc 0 ${bbone_loadaddr} ${bbone_kernelimg}; bootm ${bbone_loadaddr} root=ld0a; else fatload mmc 0 ${bboard_loadaddr} ${bboard_kernelimg}; bootm ${bboard_loadaddr} root=ld0a; fi
     43 EOF
     44 }
     45 
     46 populate_awin() {
     47 	cat >> "${mnt}/boot/uEnv.txt" << EOF
     48 bootargs=root=ld0a console=${console}
     49 uenvcmd=mmc dev 0; mmc rescan; if test \$fdtfile = sun7i-a20-cubieboard2.dtb; then setenv kernel netbsd-CUBIEBOARD.ub; elif test \$fdtfile = sun7i-a20-cubietruck.dtb; then setenv kernel netbsd-CUBIETRUCK.ub; elif test \$fdtfile = sun6i-a31-hummingbird.dtb; then setenv kernel netbsd-HUMMINGBIRD_A31.ub; elif test \$fdtfile = sun7i-a20-bananapi.dtb; then setenv kernel netbsd-BPI.ub; fi; fatload mmc 0:1 82000000 \$kernel; bootm 82000000
     50 EOF
     51 }
     52 
     53 populate_rpi() {
     54 	firmwaredir="${src}/external/broadcom/rpi-firmware/dist"
     55 	firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
     56 
     57 	# RPI2 kernel needs to be installed as kernel7.img
     58 	if [ -f "${mnt}/boot/netbsd-RPI2.bin" ]; then
     59 		echo "${bar} renaming netbsd-RPI2.bin to kernel7.img ${bar}"
     60 		mv "${mnt}/boot/netbsd-RPI2.bin" "${mnt}/boot/kernel7.img"
     61 
     62 		cat > "${mnt}/boot/cmdline.txt" << EOF
     63 root=ld0a console=${console}
     64 #fb=1280x1024		# to select a mode, otherwise try EDID
     65 #fb=disable		# to disable fb completely
     66 EOF
     67 
     68 	        echo "${bar} installing firmware files ${bar}"
     69 		(cd "${mnt}/boot" &&
     70 			for f in ${firmwarefiles}; do
     71 				echo " $f"
     72 				cp "${firmwaredir}/${f}" .
     73 			done
     74         	)
     75 
     76 	fi
     77 
     78 	#
     79 	# If arm_freq is specified in config.txt, set CPU frequency
     80 	# to match at boot time.
     81 	#
     82 	cp ${release}/etc/rc.local ${mnt}/etc/rc.local
     83 	cat >> ${mnt}/etc/rc.local << EOF
     84 if /sbin/sysctl -q machdep.cpu.frequency.max; then
     85 	cpufreq_max=\$(/sbin/sysctl -n machdep.cpu.frequency.max)
     86 	cpufreq_cur=\$(/sbin/sysctl -n machdep.cpu.frequency.current)
     87 	if [ ! "\$cpufreq_max" = "\$cpufreq_cur" ]; then
     88 		/sbin/sysctl -w machdep.cpu.frequency.target=\$cpufreq_max
     89 	fi
     90 fi
     91 EOF
     92 	echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
     93 	    >> "$tmp/selected_sets"
     94 }
     95 
     96 populate_amlogic() {
     97 	odroidc1_kernelimg=netbsd-ODROID-C1.ub
     98 
     99 	# Create a boot.ini for Amlogic U-Boot
    100 	cat >> "${mnt}/boot/boot.ini" << EOF
    101 ODROIDC-UBOOT-CONFIG
    102 
    103 setenv bootargs "root=ld0a awge0.mac-address=\${ethaddr} console=${console}"
    104 setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; bootm 0x21000000"
    105 run bootcmd
    106 EOF
    107 }
    108 
    109 populate_sunxi() {
    110 	:
    111 }
    112 
    113 populate_tegra() {
    114 	tegra_kernelimg=netbsd-TEGRA.ub
    115 	tegra_loadaddr=0x90000000
    116 
    117 	# Create a boot.scr for Tegra U-Boot
    118 	cat > "${mnt}/boot/boot-TEGRA.txt" << EOF
    119 setenv bootargs root=ld0a
    120 fatload mmc 1:1 ${tegra_loadaddr} ${tegra_kernelimg}
    121 fatload mmc 1:1 \${fdt_addr_r} tegra124-\${board}.dtb
    122 fdt addr \${fdt_addr_r}
    123 bootm ${tegra_loadaddr} - \${fdt_addr_r}
    124 EOF
    125 	"${MKUBOOTIMAGE}" -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/tegra boot" "${mnt}/boot/boot-TEGRA.txt" "${mnt}/boot/boot.scr"
    126 }
    127 
    128 populate() {
    129 	echo "${bar} looking for kernels in ${kernel} ${bar}"
    130 	kernels=""
    131 	# .ub kernels
    132 	for k in $kernels_beagle $kernels_awin $kernels_sunxi $kernels_amlogic $kernels_tegra; do
    133 		f="${kernel}/netbsd-${k}.ub.gz"
    134 		test -f "${f}" && kernels="${kernels} ${f}"
    135 	done
    136 	# .bin kernels
    137 	for k in $kernels_rpi; do
    138 		f="${kernel}/netbsd-${k}.bin.gz"
    139 		test -f "${f}" && kernels="${kernels} ${f}"
    140 	done
    141 	# .dtb files
    142 	for k in $kernels_sunxi $kernels_tegra; do
    143 		test -d "${KERNOBJDIR}/${k}" && \
    144 		    dtbs="$(${MAKE} -C ${KERNOBJDIR}/${k} -v DTB)" || \
    145 		    dtbs=
    146 		for dtb in $dtbs; do
    147 			f="${kernel}/${dtb}.gz"
    148 			test -f "${f}" && kernels="${kernels} ${f}"
    149 		done
    150 	done
    151 
    152 	# install kernels to /boot partition
    153 	for k in ${kernels}; do
    154 		tgt="$(basename ${k} | sed 's/\.gz$//')"
    155 		echo "${bar} installing ${k} to /boot/${tgt} ${bar}"
    156 		case "${k}" in
    157 		*.gz)
    158 			${GZIP_CMD} -dc "${k}" > "${mnt}/boot/${tgt}"
    159 			;;
    160 		*)
    161 			cp "${k}" "${mnt}/boot/${tgt}"
    162 			;;
    163 		esac
    164 	done
    165 
    166 	# board specific configuration
    167 	populate_beagle
    168 	populate_awin
    169 	populate_rpi
    170 	populate_amlogic
    171 	populate_tegra
    172 	populate_sunxi
    173 }
    174