blob: ac33efd8888e29acb14b2cfe418d0874ecae2313 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# $NetBSD: armv7.conf,v 1.46 2023/04/19 18:39:18 brook Exp $
# ARMv7 customization script used by mkimage
#
board=armv7
console=fb
resize=true
. ${DIR}/conf/evbarm.conf
kernels_generic="GENERIC"
make_label() {
make_label_evbarm
}
make_fstab() {
make_fstab_evbarm
}
customize() {
customize_evbarm
cat >> "${mnt}/etc/rc.conf" << EOF
mdnsd=YES
devpubd=YES
wscons=\$(dev_exists wsdisplay0)
EOF
}
populate_common() {
if [ -f "${release}/usr/mdec/bootarm.efi" ]; then
# Install EFI bootloader
mkdir -p "${mnt}/boot/EFI/BOOT"
cp "${release}/usr/mdec/bootarm.efi" "${mnt}/boot/EFI/BOOT/bootarm.efi"
# Install GENERIC kernel to root of the FFS partition
${GZIP_CMD} -dc ${kernel}/netbsd-${kernels_generic}.gz > "${mnt}/netbsd"
echo "./netbsd type=file uname=root gname=wheel mode=0755" \
>> "$tmp/selected_sets"
cp ${DIR}/files/armv7_boot.cmd ${mnt}/boot/boot.cmd
cp ${DIR}/files/boot.cfg ${mnt}/boot/boot.cfg
else
# Fallback to non-EFI boot command
cp ${DIR}/files/armv7_boot_nonefi.cmd ${mnt}/boot/boot.cmd
fi
# Install boot script
"${MKUBOOTIMAGE}" -A arm -C none -O netbsd -T script -a 0 -n "NetBSD/armv7 boot" "${mnt}/boot/boot.cmd" "${mnt}/boot/boot.scr"
}
populate_rpi() {
firmwaredir="${src}/external/broadcom/rpi-firmware/dist"
firmwarefiles="LICENCE.broadcom bootcode.bin fixup.dat fixup_cd.dat start.elf start_cd.elf"
# The GENERIC .img kernel img is used for RPI2
if [ -f "${mnt}/boot/netbsd-GENERIC.img" ]; then
cat > "${mnt}/boot/cmdline.txt" << EOF
root=ld0a console=${console}
#fb=1280x1024 # to select a mode, otherwise try EDID
#fb=disable # to disable fb completely
EOF
cat > ${mnt}/boot/config.txt << EOF
#
upstream_kernel=1
os_prefix=dtb/
cmdline=../cmdline.txt
kernel=/netbsd-GENERIC.img
# Boot options, see https://www.raspberrypi.com/documentation/computers/config_txt.html#boot-options
kernel_address=0x01000040
# UART settings, see https://www.raspberrypi.com/documentation/computers/configuration.html#configuring-uarts
enable_uart=1
force_turbo=0
EOF
echo "${bar} installing firmware files ${bar}"
(cd "${mnt}/boot" &&
for f in ${firmwarefiles}; do
echo " $f"
cp "${firmwaredir}/${f}" .
done
)
fi
#
# 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_amlogic() {
odroidc1_kernelimg=netbsd-GENERIC.ub
# Create a boot.ini for Amlogic U-Boot
cat >> "${mnt}/boot/boot.ini" << EOF
ODROIDC-UBOOT-CONFIG
setenv bootargs "awge0.mac-address=\${ethaddr}"
setenv bootcmd "fatload mmc 0:1 0x21000000 ${odroidc1_kernelimg}; fatload mmc 0:1 0x20000000 dtb/meson8b-odroidc1.dtb; bootm 0x21000000 - 0x20000000"
run bootcmd
EOF
}
populate() {
echo "${bar} looking for kernels in ${kernel} ${bar}"
kernels=""
# .ub kernels
for k in $kernels_generic; do
f="${kernel}/netbsd-${k}.ub.gz"
test -f "${f}" && kernels="${kernels} ${f}"
done
# .img kernels
for k in $kernels_generic; do
f="${kernel}/netbsd-${k}.img.gz"
test -f "${f}" && kernels="${kernels} ${f}"
done
# 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 ||
fail "Copy of ${k} to ${mnt}/boot/${tgt} failed"
done
# board specific configuration
populate_amlogic
populate_rpi
# common configuration
populate_common
}
|