Skip to content

Commit

Permalink
Add Ubuntu Noble RPI description
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefi committed Sep 6, 2024
1 parent 6e43550 commit 6a8ec1b
Show file tree
Hide file tree
Showing 16 changed files with 509 additions and 0 deletions.
75 changes: 75 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/appliance.kiwi
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>

<image schemaversion="7.6" name="kiwi-test-image-rpi">
<description type="system">
<author>Marcus Schäfer</author>
<contact>[email protected]</contact>
<specification>Disk image for RaspberryPi test build</specification>
</description>
<preferences>
<version>1.22.4</version>
<packagemanager>apt</packagemanager>
<locale>en_US</locale>
<keytable>us</keytable>
<timezone>UTC</timezone>
<rpm-excludedocs>true</rpm-excludedocs>
<type image="oem" filesystem="xfs" firmware="efi" bootpartition="false" efipartsize="128" devicepersistency="by-label" editbootinstall="editbootinstall_rpi.sh">
<bootloader name="custom"/>
<oemconfig>
<oem-resize>false</oem-resize>
<oem-swap>false</oem-swap>
</oemconfig>
</type>
</preferences>
<users>
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/root" name="root" groups="root"/>
</users>
<users>
<user password="$1$wYJUgpM5$RXMMeASDc035eX.NbYWFl0" home="/home/ubuntu" name="ubuntu" groups="users,kvm" shell="/bin/bash"/>
</users>
<repository type="apt-deb" alias="Noble" distribution="noble" components="main multiverse restricted universe" repository_gpgcheck="false">
<source path="http://ports.ubuntu.com/ubuntu-ports"/>
</repository>
<packages type="image">
<package name="libpam-runtime"/>
<package name="language-pack-en"/>
<package name="linux-raspi"/>
<package name="ubuntu-raspi-settings"/>
<package name="linux-firmware"/>
<package name="u-boot-rpi"/>
<package name="u-boot-tools"/>
<package name="rpi-eeprom"/>
<package name="libraspberrypi-bin"/>
<package name="bash-completion"/>
<package name="git"/>
<package name="sudo"/>
<package name="net-tools"/>
<package name="tzdata"/>
<package name="apt-utils"/>
<package name="systemd"/>
<package name="systemd-timesyncd"/>
<package name="gnupg"/>
<package name="iproute2"/>
<package name="iptables"/>
<package name="iputils-ping"/>
<package name="ifupdown"/>
<package name="netbase"/>
<package name="dbus"/>
<package name="xfsprogs"/>
<package name="mawk"/>
<package name="openssh-client"/>
<package name="openssh-server"/>
<package name="zstd"/>
<package name="util-linux"/>
<package name="less"/>
<package name="vim"/>
<package name="fdisk"/>
</packages>
<packages type="bootstrap">
<package name="gawk"/>
<package name="apt-utils"/>
<package name="debconf"/>
<package name="mawk"/>
<package name="dialog"/>
</packages>
</image>
92 changes: 92 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
set -ex

#======================================
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig

echo "Configure image: [$kiwi_iname]..."

#======================================
# add missing fonts
#--------------------------------------
CONSOLE_FONT="eurlatgr.psfu"

#======================================
# Install firmware
#--------------------------------------
dpkg -i /var/tmp/firmware/linux-firmware-raspi_6-0ubuntu3_arm64.deb
dpkg -i /var/tmp/firmware/linux-firmware-raspi2_6-0ubuntu3_arm64.deb

#======================================
# Setup default target, multi-user
#--------------------------------------
baseSetRunlevel 3

# On Debian based distributions the kiwi built in way
# to setup locale, keyboard and timezone via systemd tools
# does not work because not(yet) provided by the distribution.
# Thus the following manual steps to make the values provided
# in the image description effective needs to be done.
#
#=======================================
# Setup system locale
#---------------------------------------
echo "LANG=${kiwi_language}" > /etc/locale.conf

#=======================================
# Setup system keymap
#---------------------------------------
echo "KEYMAP=${kiwi_keytable}" > /etc/vconsole.conf
echo "FONT=eurlatgr.psfu" >> /etc/vconsole.conf
echo "FONT_MAP=" >> /etc/vconsole.conf
echo "FONT_UNIMAP=" >> /etc/vconsole.conf

#=======================================
# Setup system timezone
#---------------------------------------
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/${kiwi_timezone} /etc/localtime

#=======================================
# Setup HW clock to UTC
#---------------------------------------
echo "0.0 0 0.0" > /etc/adjtime
echo "0" >> /etc/adjtime
echo "UTC" >> /etc/adjtime

#======================================
# Activate services
#--------------------------------------
baseInsertService ssh
baseInsertService systemd-networkd
baseInsertService symlink-resolvconf
baseInsertService rpi-eeprom-update
baseInsertService systemd-timesyncd

#======================================
# Sysconfig Update
#--------------------------------------
# Systemd controls the console font now
echo FONT="$CONSOLE_FONT" >> /etc/vconsole.conf

#======================================
# Configure Raspberry Pi specifics
#--------------------------------------
# Add necessary kernel modules to initrd (will disappear with bsc#1084272)
echo 'add_drivers+=" bcm2835_dma dwc2 "' \
> /etc/dracut.conf.d/raspberrypi_modules.conf

# Work around HDMI connector bug and network issues
# No HDMI hotplug available
# Prevent too many page allocations (bsc#1012449)
cat > /etc/modprobe.d/50-rpi3.conf <<-EOF
options drm_kms_helper poll=0
options smsc95xx turbo_mode=N
EOF

# Avoid running out of DMA pages for smsc95xx (bsc#1012449)
cat > /usr/lib/sysctl.d/50-rpi3.conf <<-EOF
vm.min_free_kbytes = 2048
EOF
39 changes: 39 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/editbootinstall_rpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -ex

image_fs=$1

root_partnum=$2

root_device=/dev/mapper/loop*p${root_partnum}

loop_name=$(basename $root_device | cut -f 1-2 -d'p')

disk_device=/dev/${loop_name}

#==========================================
# Change partition label type to MBR
#------------------------------------------
# The target system doesn't support GPT, so let's move it to
# MBR partition layout instead.
#
# Also make sure to set the ESP partition to type 0xc so that
# broken firmware (Rpi) detects it as FAT.
#
# Use tabs, "<<-" strips tabs, but no other whitespace!
cat > gdisk.tmp <<-'EOF'
x
r
g
t
1
c
w
y
EOF
dd if=$disk_device of=mbrid.bin bs=1 skip=440 count=4
gdisk $disk_device < gdisk.tmp
dd of=$disk_device if=mbrid.bin bs=1 seek=440 count=4
rm -f mbrid.bin
rm -f gdisk.tmp
36 changes: 36 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/pre_disk_sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/dash

set -ex

# copy Raspberry Pi boot data to "EFI" part...
#==========================================
# copy firmware
#------------------------------------------
cp -a /usr/lib/linux-firmware-raspi/* /boot/efi

#==========================================
# copy device tree's
#------------------------------------------
cp -a /usr/lib/firmware/*-raspi/device-tree/overlays /boot/efi/
cp -a /usr/lib/firmware/*-raspi/device-tree/broadcom/* /boot/efi/

#==========================================
# copy initrd and kernel
#------------------------------------------
cp /boot/initrd-*-raspi /boot/efi/initrd.img
cp /boot/vmlinuz-*-raspi /boot/efi/vmlinuz

#==========================================
# copy u-boot
#------------------------------------------
cp /usr/lib/u-boot/rpi_3/u-boot.bin /boot/efi/uboot_rpi_3.bin
cp /usr/lib/u-boot/rpi_4/u-boot.bin /boot/efi/uboot_rpi_4.bin
cp /usr/lib/u-boot/rpi_arm64/u-boot.bin /boot/efi/uboot_rpi_arm64.bin

#==========================================
# create u-boot loader config
#------------------------------------------
echo "console=serial0,115200 dwc_otg.lpm_enable=0 console=tty1 root=LABEL=ROOT rd.kiwi.debug rootfstype=xfs rootwait fixrtc" > /boot/efi/cmdline.txt

mkimage -A arm64 -O linux -T script -C none -d /boot/efi/boot.cmd \
/boot/efi/boot.scr
70 changes: 70 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/root/boot/efi/boot.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Ubuntu Classic RPi U-Boot script (for armhf and arm64)

# Expects to be called with the following environment variables set:
#
# devtype e.g. mmc/scsi etc
# devnum The device number of the given type
# distro_bootpart The partition containing the boot files
# (introduced in u-boot mainline 2016.01)
# prefix Prefix within the boot partiion to the boot files
# kernel_addr_r Address to load the kernel to
# fdt_addr_r Address to load the FDT to
# ramdisk_addr_r Address to load the initrd to.

#Set device tree address
# Take fdt addr from the prior stage boot loader, if available
if test -n "$fdt_addr"; then
fdt addr ${fdt_addr}
fdt move ${fdt_addr} ${fdt_addr_r} # implicitly sets fdt active
else
fdt addr ${fdt_addr_r}
fi
fdt get value bootargs /chosen bootargs

setenv bootargs " ${bootargs} quiet splash"

if test -z "${fk_image_locations}"; then
setenv fk_image_locations ${prefix}
fi

for pathprefix in ${fk_image_locations}; do
# Store the gzip header (1f 8b) in the kernel area for comparison to the
# header of the image we load. Load "vmlinuz" into the portion of memory for
# the RAM disk (because we want to uncompress to the kernel area if it's
# compressed) and compare the word at the start
mw.w ${kernel_addr_r} 0x8b1f # little endian

#Loading kernel
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${pathprefix}vmlinuz; then
kernel_size=${filesize}

#Determine whether the kernel image is compressed
if cmp.w ${kernel_addr_r} ${ramdisk_addr_r} 1; then
# gzip compressed image (NOTE: *not* a self-extracting gzip compressed
# kernel, just a kernel image that has been gzip'd)
echo "Decompressing kernel..."
unzip ${ramdisk_addr_r} ${kernel_addr_r}
setenv kernel_size ${filesize}
setenv try_boot "booti"
else
# Possibly self-extracting or uncompressed; copy data into the kernel area
# and attempt launch with bootz then booti
echo "Copying kernel..."
cp.b ${ramdisk_addr_r} ${kernel_addr_r} ${kernel_size}
setenv try_boot "bootz booti"
fi

#Loading the root file system
if load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${pathprefix}initrd.img; then
setenv ramdisk_param "${ramdisk_addr_r}:${filesize}"
else
setenv ramdisk_param "-"
fi

#Boot kernel
for cmd in ${try_boot}; do
echo "Booting Ubuntu (with ${cmd}) from ${devtype} ${devnum}:${partition}..."
${cmd} ${kernel_addr_r} ${ramdisk_param} ${fdt_addr_r}
done
fi
done
43 changes: 43 additions & 0 deletions ubuntu/aarch64/ubuntu-noble-rpi/root/boot/efi/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[all]
kernel=vmlinuz
cmdline=cmdline.txt
initramfs initrd.img followkernel

[pi4]
max_framebuffers=2
arm_boost=1

[all]
# Enable the audio output, I2C and SPI interfaces on the GPIO header. As these
# parameters related to the base device-tree they must appear *before* any
# other dtoverlay= specification
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=spi=on

# Comment out the following line if the edges of the desktop appear outside
# the edges of your display
disable_overscan=1

# If you have issues with audio, you may try uncommenting the following line
# which forces the HDMI output into HDMI mode instead of DVI (which doesn't
# support audio output)
#hdmi_drive=2

# Enable the serial pins
enable_uart=1

# Autoload overlays for any recognized cameras or displays that are attached
# to the CSI/DSI ports. Please note this is for libcamera support, *not* for
# the legacy camera stack
camera_auto_detect=1
display_auto_detect=1

# Config settings specific to arm64
arm_64bit=1
dtoverlay=dwc2

[cm4]
# Enable the USB2 outputs on the IO board (assuming your CM4 is plugged into
# such a board)
dtoverlay=dwc2,dr_mode=host
Loading

0 comments on commit 6a8ec1b

Please sign in to comment.