blob: f1bb3f654bc3a1a0edc298f5689b1cd0197a3b90 (
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
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
|
Prepare a distro image for N1SDP: Ubuntu 18.04 as an example
============================================================
.. section-numbering::
:suffix: .
.. contents::
Introduction
------------
The Neoverse N1 System Development Platform (N1SDP) is an enterprise class reference board based on the Neoverse N1 core.
This document is a guide on how to prepare a Linux distro image for N1SDP platform taking Ubuntu 18.04 as an example.
All the steps mentioned below are implemented in build-scripts provided with N1SDP Software stack.
Building Linux Images
---------------------
Get Linux version 4.18 or above (5.4.0 used in this example).
Two Linux images are required
- Monolithic Linux image: Used during first boot
- Linux debian package: Installed by Ubuntu in first boot and used after second boot onwards.
**Building monolithic linux image**
Apply n1sdp-pcie-quirk patches available inside <workspace/n1sdp-pcie-quirk/linux/>.
Also available here https://git.linaro.org/landing-teams/working/arm/n1sdp-pcie-quirk.git/tree/linux/
::
$ export ARCH=arm64
$ export CROSS_COMPILE=/usr/bin/aarch64-linux-gnu-
$ make defconfig
$ make Image
Generated Image name : Image
**Building linux deb package**
Along with the N1SDP Quirk patches get the following 5 patches from https://kernel.ubuntu.com/~kernel-ppa/mainline provided by Ubuntu and required to build linux debian package.Patches version should match with linux kernel version e.g. for 5.4 use patches under https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.4/
Ubuntu Patches:
- 0001-base-packaging.patch
- 0002-UBUNTU-SAUCE-add-vmlinux.strip-to-BOOT_TARGETS1-on-p.patch
- 0003-UBUNTU-SAUCE-tools-hv-lsvmbus-add-manual-page.patch
- 0004-debian-changelog.patch
- 0005-configs-based-on-Ubuntu-5.4.0-7.8.patch
Build Commands:
::
$ export ARCH=arm64
$ export CROSS_COMPILE=/usr/bin/aarch64-linux-gnu-
$ cat debian.master/config/config.common.ubuntu debian.master/config/arm64/config.common.arm64 > $UBUNTU_OUT_DIR/.config
$ make oldconfig
$ sed -ie 's/CONFIG_DEBUG_INFO=y/# CONFIG_DEBUG_INFO is not set/' .config
$ make bindeb-pkg
Generated Image name: linux-image-5.4.0+_5.4.0+-1_arm64.deb rename it to "linux-image-n1sdp.deb"
Creating Ubuntu Root FS
-----------------------------
Download the Ubuntu minimal root file system image from
"http://cdimage.ubuntu.com/ubuntu-base/bionic/daily/current/bionic-base-arm64.tar.gz".
This image will be extracted and modified to boot a fully fledged Ubuntu 18.04
distro.
An initramfs is provided containing the necessary firmware and hardware support.
The initramfs PID 1 should configure the network interface and then
execute the installation script.
During the first boot an installation script will configure a minimal working
base-system.
The provided installation script preforms the following tasks:
- Set root as password for root
- Add 8.8.4.4 and 8.8.8.8 as nameservers
- Resize the second partion (and file-system) to end of disk
- Install a minimal set of package with apt-get
Content of the provided installation script (assumes that network is up):
::
#!/bin/sh
on_exit() {
test $? -ne 0 || exit 0
echo "something unexpected happend, bailing to a recovery shell!" >&2
exec /bin/bash
}
trap "on_exit" EXIT TERM
set -u
set -e
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -o remount,rw /
chown -Rf root:root / || true
chmod 777 /tmp
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH
apt-get update
apt-get install -y \
apt-utils \
grub-efi-arm64 \
ifupdown \
initramfs-tools \
isc-dhcp-client \
kmod \
linux-firmware \
net-tools \
openssh-server \
resolvconf \
sudo \
systemd \
udev \
vim \
ln -s /dev/null /etc/systemd/network/99-default.link
echo "nameserver 8.8.4.4" >> /etc/resolvconf/resolv.conf.d/head
echo "nameserver 8.8.8.8" >> /etc/resolvconf/resolv.conf.d/head
service resolvconf restart
echo "LABEL=Ubuntu-18.04 / ext4 defaults 0 0" >> etc/fstab
echo "LABEL=ESP /boot/efi vfat defaults 0 0" >> etc/fstab
mkdir /boot/efi
mount /boot/efi
mount -t efivarfs efivarfs /sys/firmware/efi/efivars/
grub-install || true
[ -e /linux-image-n1sdp.deb ] && dpkg -i /linux-image-n1sdp.deb
[ -e /linux-headers-n1sdp.deb ] && dpkg -i /linux-headers-n1sdp.deb
sed -ie 's/^GRUB_TIMEOUT_STYLE=.*$/GRUB_TIMEOUT_STYLE=menu/; s/^GRUB_TIMEOUT=.*$/GRUB_TIMEOUT=2/; s/GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT="earlycon vfio-pci.ids=10ee:9038"/' /etc/default/grub
update-grub
sync
# change root password
echo "root:root" | chpasswd
# Create user ubuntu:ubuntu
adduser ubuntu --gecos "ubuntu" --disabled-password
echo "ubuntu:ubuntu" | chpasswd
usermod -aG sudo ubuntu
cat <<EOF >/etc/modprobe.d/vfio.conf
# cat /etc/modprobe.d/vfio.conf
options vfio-pci ids=10ee:9038
softdep radeon pre: vfio-pci
softdep amdgpu pre: vfio-pci
softdep nouveau pre: vfio-pci
softdep drm pre: vfio-pci
options kvm_amd avic=1
EOF
update-initramfs -u
cat <<EOF >/etc/modules-load.d/vfio-pci.conf
# cat /etc/modules-load.d/vfio-pci.conf
vfio-pci
EOF
sync
Content of /etc/network/interfaces
::
#!/bin/sh
# Network setup
# interfaces(5) file used by ifup(8) and ifdown(8)
auto eth0
iface eth0 inet dhcp
Creating Ubuntu disk Image
--------------------------
- Create "grub-ubuntu.img" disk image which will have two partitions, first a
FAT partition of 20MB and second an EXT4 partiton of 4GB.
- FAT partition labeled as ESP which contains grub configuration for **first** boot.
::
set debug="loader,mm"
set term="vt100"
set default="0"
set timeout="1"
set root=(hd1,msdos2)
menuentry 'Install Ubuntu on N1SDP Platform' {
linux /Image acpi=force earlycon=pl011,0x2A400000
initrd /ramdisk.img
}
- EXT4 partition labeled as Ubuntu-18.04 which contains extracted Ubuntu-18.04
root file system created earlier along with both kernel images and initramfs.
Mounting of disk Image on memory stick
--------------------------------------
::
$ lsblk
$ sudo dd if=grub-ubuntu.img of=/dev/sd<X> bs=1M
$ sync
Note: Replace ``/dev/sdX`` with the handle corresponding to your USB stick as identified by the ``lsblk``
Booting Sequence
----------------
**First Boot**
- The GRUB configuration stored on the ESP partition is used
- The monolithic kernel image and initramfs are used
- /init configures the network and mount the real root
- /init executes the installation script
- The installation script installs the base packages
- The installation script installs the Linux deb package and creates a
new initramfs and grub entry
**Second Boot**
- Second boot onwards a minimal Ubuntu-18.04 will be booted which already has a grub entry created during first boot.
- It will also use linux debian image and initramfs installed during first boot.
--------------
*Copyright (c) 2020, Arm Limited. All rights reserved.*
|