-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathodroid-n2_buster_arm64_vmdb2-0.15.yaml
208 lines (170 loc) · 7.72 KB
/
odroid-n2_buster_arm64_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
# Use like this : sudo vmdb2 odroid-n2_buster_arm64_vmdb2-0.15.yaml --output odroid-n2_buster_arm64.img --rootfs-tarball buster_arm64_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: arm64
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-arm64
mv /initramfs-tools /zz-flash-kernel /etc/kernel/postinst.d/
- create-file: /etc/hostname
contents: |+
OdroidN2
- fstab: root
- create-file: /etc/flash-kernel/db
contents: |+
Machine: Hardkernel ODROID-N2
Kernel-Flavors: arm64
DTB-Id: amlogic/meson-g12b-odroid-n2.dtb
Boot-Script-Path: /boot/boot.scr
U-Boot-Script-Name: bootscr.uboot-generic
Required-Packages: u-boot-tools
- create-file: /etc/flash-kernel/machine
contents: |+
Hardkernel ODROID-N2
- create-file: /etc/flash-kernel/preboot.d/fix_ethernet_reset-gpios
contents: |+
load ${devtype} ${devnum}:${partition} ${kernel_addr_r} ${prefix}vmlinuz-${fk_kvers} \
&& load ${devtype} ${devnum}:${partition} ${fdt_addr_r} ${prefix}${fdtpath} \
&& fdt addr ${fdt_addr_r} \
&& fdt set /soc/bus@ff600000/mdio-multiplexer@4c000/mdio@0/ethernet-phy@0 reset-deassert-us <80000> \
&& echo "\c" \
&& echo "Use of fdt command to fix reset-gpios value for Ethernet MAC mdio :\c" \
&& echo " Clean fix to make ethernet work (able to up & down as pleased),\c" \
&& echo " which will be removed when the device-tree is fixed in Debian"\'"s kernel" \
&& load ${devtype} ${devnum}:${partition} ${ramdisk_addr_r} ${prefix}initrd.img-${fk_kvers} \
&& echo "Booting Debian ${fk_kvers} from ${devtype} ${devnum}:${partition}..." \
&& booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
load ${devtype} ${devnum}:${partition} ${kernel_addr_r} ${prefix}vmlinuz \
&& load ${devtype} ${devnum}:${partition} ${fdt_addr_r} ${prefix}dtb \
&& fdt addr ${fdt_addr_r} \
&& fdt set /soc/bus@ff600000/mdio-multiplexer@4c000/mdio@0/ethernet-phy@0 reset-deassert-us <80000> \
&& echo "\c" \
&& echo "Use of fdt command to fix reset-gpios value for Ethernet MAC mdio :\c" \
&& echo " Clean fix to make ethernet work (able to up & down as pleased),\c" \
&& echo " which will be removed when the device-tree is fixed in Debian"\'"s kernel" \
&& load ${devtype} ${devnum}:${partition} ${ramdisk_addr_r} ${prefix}initrd.img \
&& echo "Booting Debian from ${devtype} ${devnum}:${partition}..." \
&& booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
- apt: install
packages:
- cpufrequtils
tag: root
- create-file: /etc/default/cpufrequtils
contents: |+
# If the governor "schedutil" is selected,
# the cpu0 is unresponsive for about 20 seconds from time to time.
# By using the cpufrequtils utility we set the governor to another value.
# The governors "performance" & "conservative" seem stable after 1 week of tests.
GOVERNOR="performance"
- chroot: root
shell: |
# 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
# Added clk_ignore_unused to the cmdline to fix boot hang on Odroid N2 (Linux 5.6 at least)
sed -i "s@quiet@root=$(grep ^UUID /etc/fstab | cut -d \ -f 1) net.ifnames=0 clk_ignore_unused@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
# Adding missing ttyAML0 fixes login refusal from pam_securetty on serial UART on Odroid N2 (note the shell here is sh not bash, don't use echo -e)
echo "\n# ODROID N2 serial console\nttyAML0" >> /etc/securetty
# We use a recent Libretech Odroid N2 U-Boot
- root-fs: root
shell: |
mkdir $ROOT/boot/u-boot
curl -L -o $ROOT/boot/u-boot/u-boot.bin.gz https://github.com/BayLibre/u-boot/releases/download/v2017.11-libretech-cc/u-boot.bin.odroid-n2_2019.07-rc3-00022-g47bebaa4a3.gz
gunzip $ROOT/boot/u-boot/u-boot.bin.gz
dd if=$ROOT/boot/u-boot/u-boot.bin of={{ output }} bs=512 seek=1 conv=fsync,notrunc
- 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
- 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: |