-
Notifications
You must be signed in to change notification settings - Fork 5
/
nanopi-r1_buster_armhf_vmdb2-0.15.yaml
330 lines (265 loc) · 10.5 KB
/
nanopi-r1_buster_armhf_vmdb2-0.15.yaml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# Use like this : sudo vmdb2 nanopi-r1_buster_armhf_vmdb2-0.15.yaml --output nanopi-r1_buster_armhf.img --rootfs-tarball buster_armhf_rootfs.tgz --verbose --log=log.txt
steps:
- mkimg: "{{ output }}"
size: 3G
- mklabel: msdos
device: "{{ output }}"
- mkpart: primary
device: "{{ output }}"
start: 16M
end: 100%
tag: root
- kpartx: "{{ output }}"
- mkfs: ext4
partition: root
- mount: root
- unpack-rootfs: root
- qemu-debootstrap: buster
mirror: http://ftp.de.debian.org/debian
target: root
arch: armhf
components:
- main
- contrib
- non-free
unless: rootfs_unpacked
- apt: install
packages:
- initramfs-tools
tag: root
unless: rootfs_unpacked
- chroot: root
shell: |
echo "deb http://ftp.de.debian.org/debian buster main contrib non-free" > /etc/apt/sources.list
echo "deb http://security.debian.org/ buster/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://ftp.de.debian.org/debian buster-updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://ftp.de.debian.org/debian buster-backports main contrib non-free" >> /etc/apt/sources.list
unless: rootfs_unpacked
- apt: install
packages:
- flash-kernel
tag: root
unless: rootfs_unpacked
- cache-rootfs: root
unless: rootfs_unpacked
- chroot: root
shell: |
apt-get update
apt-get -y upgrade
mv /etc/kernel/postinst.d/initramfs-tools /etc/kernel/postinst.d/zz-flash-kernel /
apt-get -y install -t buster-backports linux-image-armmp-lpae
mv /initramfs-tools /zz-flash-kernel /etc/kernel/postinst.d/
- create-file: /etc/hostname
contents: |+
NanoPiR1
- fstab: root
- root-fs: root
shell: |
curl -L -o $ROOT/linux-dtb.deb https://imola.armbian.com/apt/pool/main/l/linux-5.10.16-sunxi/linux-dtb-current-sunxi_21.02.2_armhf.deb
- create-file: /etc/kernel/postinst.d/add-armbian-dtb
contents: |+
#!/bin/sh -e
version="$1"
# passing the kernel version is required
if [ -z "${version}" ]; then
echo >&2 "W: add-armbian-dtb: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number"
exit 2
fi
# only works with boards specified in /etc/flash-kerne/db, flash-kernel supported boards' dtb should be in kernel pkg
if [ ! -e "/etc/flash-kernel/db" ]; then
echo >&2 "W: add-armbian-dtb: Missing /etc/flash-kernel/db, add-armbian-dtb cannot continue"
exit 1
fi
dtbfile=$(grep DTB-Id /etc/flash-kernel/db | sed "s@.*DTB-Id: @@g")
# only works with available /boot/armbian-dtb/${dtbfile}
if [ ! -e "/boot/armbian-dtb/${dtbfile}" ]; then
echo >&2 "W: add-armbian-dtb: Missing /boot/armbian-dtb/${dtbfile}, add-armbian-dtb cannot continue"
exit 1
fi
if [ -e "/lib/linux-image-${version}/${dtbfile}" ]; then
if cmp -s /boot/armbian-dtb/${dtbfile} /lib/linux-image-${version}/${dtbfile}; then
echo "I: ${dtbfile} imported from Armbian is already in /lib/linux-image-${version}/"
else
echo "I: This board is supported in this Debian kernel"
fi
echo "I: Skipping adding dtb imported from Armbian to new kernel"
exit 0
fi
echo "I: This board is not supported in this Debian kernel"
echo "I: Adding ${dtbfile} imported from Armbian to /lib/linux-image-${version}/"
cp /boot/armbian-dtb/${dtbfile} /lib/linux-image-${version}/
- create-file: /etc/kernel/postrm.d/add-armbian-dtb
contents: |+
#!/bin/sh -e
version="$1"
# passing the kernel version is required
if [ -z "${version}" ]; then
echo >&2 "W: add-armbian-dtb: ${DPKG_MAINTSCRIPT_PACKAGE:-kernel package} did not pass a version number"
exit 2
fi
# only works with boards specified in /etc/flash-kerne/db, flash-kernel supported boards' dtb should be in kernel pkg
if [ ! -e "/etc/flash-kernel/db" ]; then
echo >&2 "W: add-armbian-dtb: Missing /etc/flash-kernel/db, add-armbian-dtb cannot continue"
exit 1
fi
dtbfile=$(grep DTB-Id /etc/flash-kernel/db | sed "s@.*DTB-Id: @@g")
# only works with available /boot/armbian-dtb/${dtbfile}
if [ ! -e "/boot/armbian-dtb/${dtbfile}" ]; then
echo >&2 "W: add-armbian-dtb: Missing /boot/armbian-dtb/${dtbfile}, add-armbian-dtb cannot continue"
exit 1
fi
if [ ! -e "/lib/linux-image-${version}/${dtbfile}" ]; then
exit 0
fi
if cmp -s /boot/armbian-dtb/${dtbfile} /lib/linux-image-${version}/${dtbfile}; then
echo "I: Removing Armbian's ${dtbfile} from /lib/linux-image-${version}/ added on kernel install"
rm /lib/linux-image-${version}/${dtbfile}
else
echo "I: ${dtbfile} in /lib/linux-image-${version}/ is not Armbian's"
echo "I: Skipping removing dtb imported from Armbian from /lib/linux-image-${version}/"
fi
- chroot: root
shell: |
dpkg -i linux-dtb.deb
mkdir -p /boot/armbian-dtb
cp /boot/dtb-5.10.16-sunxi/sun8i-h3-nanopi-r1.dtb /boot/armbian-dtb/
dpkg -P linux-dtb-current-sunxi
rm linux-dtb.deb
chmod +x /etc/kernel/postinst.d/add-armbian-dtb
chmod +x /etc/kernel/postrm.d/add-armbian-dtb
cp /boot/armbian-dtb/sun8i-h3-nanopi-r1.dtb /usr/lib/linux-image-$(ls -l /vmlinuz | sed "s%^.*vmlinuz-\(.*\)$%\1%g")/
- create-dir: /lib/firmware/brcm
- create-file: /lib/firmware/brcm/brcmfmac43430-sdio.txt
contents: |+
#AP6212_NVRAM_V1.0_20140603
# 2.4 GHz, 20 MHz BW mode
# The following parameter values are just placeholders, need to be updated.
manfid=0x2d0
prodid=0x0726
vendid=0x14e4
devid=0x43e2
boardtype=0x0726
boardrev=0x1101
boardnum=22
macaddr=00:90:4c:c5:12:38
sromrev=11
boardflags=0x00404201
xtalfreq=26000
nocrc=1
ag0=255
aa2g=1
ccode=ALL
pa0itssit=0x20
extpagain2g=0
#PA parameters for 2.4GHz, measured at CHIP OUTPUT
pa2ga0=-168,7161,-820
AvVmid_c0=0x0,0xc8
cckpwroffset0=5
# PPR params
maxp2ga0=90
txpwrbckof=6
cckbw202gpo=0x5555
legofdmbw202gpo=0x77777777
mcsbw202gpo=0xaaaaaaaa
# OFDM IIR :
ofdmdigfilttype=7
# PAPD mode:
papdmode=2
il0macaddr=00:90:4c:c5:12:38
wl0id=0x431b
#OOB parameters
hostwake=0x40
hostrdy=0x41
usbrdy=0x03
usbrdydelay=100
deadman_to=0xffffffff
# muxenab: 0x1 for UART enable, 0x10 for Host awake
muxenab=0x10
# CLDO PWM voltage settings - 0x4 - 1.1 volt
#cldo_pwm=0x4
- create-file: /etc/flash-kernel/db
contents: |+
Machine: FriendlyElec NanoPi-R1
Kernel-Flavors: armmp armmp-lpae
Boot-Script-Path: /boot/boot.scr
DTB-Id: sun8i-h3-nanopi-r1.dtb
U-Boot-Script-Name: bootscr.sunxi
Required-Packages: u-boot-tools
- create-file: /etc/flash-kernel/machine
contents: |+
FriendlyElec NanoPi-R1
- chroot: root
shell: |
apt-get -y install -t buster-backports wireless-regdb firmware-brcm80211
apt-get -y install crda
# Add hostname to /etc/hosts for IPv4 & IPv6
HOSTNAME=$(cat /etc/hostname)
sed -i "2i127.0.0.2\t$HOSTNAME" /etc/hosts
sed -i "4i::2\t\t$HOSTNAME" /etc/hosts
sed -i "s@errors=remount-ro@noatime,nodiratime,errors=remount-ro@g" /etc/fstab
sed -i "s@quiet@root=$(grep ^UUID /etc/fstab | cut -d \ -f 1) net.ifnames=0@g" /etc/default/flash-kernel
# Back-up fsck
mv /usr/share/initramfs-tools/hooks/fsck /usr/share/initramfs-tools/hooks/fsck.bak
chmod -x /usr/share/initramfs-tools/hooks/fsck.bak
# Fix fsck to read root fstype in fstab
sed "s@\[.*\"\/\".*|| @@g" /usr/share/initramfs-tools/hooks/fsck.bak > /usr/share/initramfs-tools/hooks/fsck
chmod +x /usr/share/initramfs-tools/hooks/fsck
update-initramfs -c -k $(ls -l /vmlinuz | sed "s%^.*vmlinuz-\(.*\)$%\1%g")
sed -i "s@root:\*:@root::@g" /etc/shadow
- root-fs: root
shell: |
curl -L -o $ROOT/u-boot.deb https://imola.armbian.com/apt/pool/main/l/linux-u-boot-nanopi-r1-current/linux-u-boot-current-nanopi-r1_21.05.1_armhf.deb
- chroot: root
shell: |
dpkg -i u-boot.deb
rm u-boot.deb
- root-fs: root
shell: |
dd conv=fsync,notrunc if=$ROOT/usr/lib/linux-u-boot-current-nanopi-r1_21.05.1_armhf/u-boot-sunxi-with-spl.bin of={{ output }} bs=1024 seek=8
- create-file: /etc/network/interfaces.d/lo
contents: |+
auto lo
iface lo inet loopback
- create-file: /etc/network/interfaces.d/eth0
contents: |+
auto eth0
iface eth0 inet dhcp
- create-file: /etc/network/interfaces.d/eth1
contents: |+
auto eth1
iface eth1 inet dhcp
- root-fs: root
shell: |
test -e vmdb2-ansible.yaml || ln -s vmdb2-ansible.yaml.example vmdb2-ansible.yaml
mount -t proc proc $ROOT/proc
# The "ansible" directive is non-functional in Debian 12 Bookworm.
#
# Since Ansible in Debian Bookworm is version 2.14, UTF8 is mandatory :
# https://docs.ansible.com/ansible/devel/porting_guides/porting_guide_7.html#command-line
#
# This is taken into account in vmdb2 0.27, see 5th bullet point in 0.27 section, here :
# http://git.liw.fi/vmdb2/tree/NEWS
#
# Unfortunately, Bookworm uses vmdb2 0.26, which has UTF8 missing when calling vmdb2.
# To fix that in Bookworm, we call the ansible-playbook command directly.
# This directive is commented for now (Bookworm)
# - ansible: root
# playbook: vmdb2-ansible.yaml
# Will be uncommented when Debian 13 Trixie becomes stable
# This directive bloc should be removed when Debian 13 Trixie becomes stable
- root-fs: root
shell: |
echo "[image]" > /tmp/tmpinvvmdb2ansible
echo "$ROOT" >> /tmp/tmpinvvmdb2ansible
LC_ALL=C.UTF8 ansible-playbook -c chroot -i /tmp/tmpinvvmdb2ansible --tags all vmdb2-ansible.yaml
rm /tmp/tmpinvvmdb2ansible
- root-fs: root
shell: |
# Restore fsck
mv $ROOT/usr/share/initramfs-tools/hooks/fsck.bak $ROOT/usr/share/initramfs-tools/hooks/fsck
chmod +x $ROOT/usr/share/initramfs-tools/hooks/fsck
umount $ROOT/proc
rm $ROOT/etc/flash-kernel/machine
diff vmdb2-ansible.yaml.example vmdb2-ansible.yaml && test -L vmdb2-ansible.yaml && rm vmdb2-ansible.yaml || true
- create-file: /etc/resolv.conf
contents: |