Skip to content

Commit fbaa802

Browse files
authored
Improvements for the OPi image (#19)
Improve network configuration and boot behavior for the OrangePi5 Ubuntu 24.04 image and add support for the OrangePi5 Pro.
1 parent c5a1e83 commit fbaa802

File tree

5 files changed

+232
-25
lines changed

5 files changed

+232
-25
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- name: opi5plus
3434
script: ./install_opi5.sh
3535
base_image: https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v2.1.0/ubuntu-24.04-preinstalled-server-arm64-orangepi-5-plus.img.xz
36+
- name: opi5pro
37+
script: ./install_opi5.sh
38+
base_image: https://github.com/Joshua-Riek/ubuntu-rockchip/releases/download/v2.1.0/ubuntu-24.04-preinstalled-server-arm64-orangepi-5-pro.img.xz
3639

3740
name: "Build for ${{ matrix.name }}"
3841

@@ -58,7 +61,7 @@ jobs:
5861
mv ${{ steps.install_deps.outputs.image }} photonvision_${{ matrix.name }}.img
5962
sudo xz -T 0 -v photonvision_${{ matrix.name }}.img
6063
61-
- uses: actions/[email protected].3
64+
- uses: actions/[email protected].4
6265
with:
6366
name: photonvision_${{ matrix.name }}.img.xz
6467
path: photonvision_${{ matrix.name }}.img.xz
@@ -70,7 +73,7 @@ jobs:
7073
runs-on: ubuntu-22.04
7174
steps:
7275
# Download literally every single artifact
73-
- uses: actions/[email protected].7
76+
- uses: actions/[email protected].8
7477
- run: find
7578
# Push to dev release
7679
- uses: pyTooling/Actions/[email protected]
@@ -82,7 +85,7 @@ jobs:
8285
**/*.xz
8386
if: github.event_name == 'push'
8487
# Upload all xz archives to GH tag if tagged
85-
- uses: softprops/[email protected].6
88+
- uses: softprops/[email protected].8
8689
with:
8790
files: |
8891
**/*.xz

OPi5_CIDATA/meta-data

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This is the meta-data configuration file for cloud-init. Please refer to the
2+
# cloud-init documentation for more information:
3+
#
4+
# https://cloudinit.readthedocs.io/
5+
6+
# Set the datasource mode to "local". This ensures that user-data is acted upon
7+
# prior to bringing up the network (because everything about the datasource is
8+
# assumed to be local). If you wish to use an HTTP datasource instead, you can
9+
# change this to "net" or override it on the kernel cmdline (see README).
10+
dsmode: local
11+
12+
# Specifies the "unique" identifier of the instance. Typically in cloud-init
13+
# this is generated by the owning cloud and is actually unique (to some
14+
# degree). Here our data-source is local, so this is just a fixed string.
15+
# Warning: changing this will cause cloud-init to assume it is running on a
16+
# "new" instance, and to go through first time setup again (the value is
17+
# compared to a cached copy).
18+
instance-id: cloud-image

OPi5_CIDATA/network-config

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This file contains a netplan-compatible configuration which cloud-init will
2+
# apply on first-boot (note: it will *not* update the config after the first
3+
# boot). Please refer to the cloud-init documentation and the netplan reference
4+
# for full details:
5+
#
6+
# https://netplan.io/reference
7+
# https://cloudinit.readthedocs.io/en/latest/topics/network-config.html
8+
# https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html
9+
#
10+
# Please note that the YAML format employed by this file is sensitive to
11+
# differences in whitespace; if you are editing this file in an editor (like
12+
# Notepad) which uses literal tabs, take care to only use spaces for
13+
# indentation. See the following link for more details:
14+
#
15+
# https://en.wikipedia.org/wiki/YAML
16+
17+
# Some additional examples are commented out below
18+
19+
network:
20+
version: 2
21+
renderer: NetworkManager
22+
ethernets:
23+
zz-all-en:
24+
renderer: NetworkManager
25+
match:
26+
name: "en*"
27+
dhcp4: true
28+
optional: true
29+
zz-all-eth:
30+
renderer: NetworkManager
31+
match:
32+
name: "eth*"
33+
dhcp4: true
34+
optional: true
35+

OPi5_CIDATA/user-data

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#cloud-config
2+
3+
# This is the user-data configuration file for cloud-init. By default this sets
4+
# up an initial user called "ubuntu" with password "ubuntu", which must be
5+
# changed at first login. However, many additional actions can be initiated on
6+
# first boot from this file. The cloud-init documentation has more details:
7+
#
8+
# https://cloudinit.readthedocs.io/
9+
#
10+
# Please note that the YAML format employed by this file is sensitive to
11+
# differences in whitespace; if you are editing this file in an editor (like
12+
# Notepad) which uses literal tabs, take care to only use spaces for
13+
# indentation. See the following link for more details:
14+
#
15+
# https://en.wikipedia.org/wiki/YAML
16+
#
17+
# Some additional examples are provided in comments below the default
18+
# configuration.
19+
20+
# The (default) ubuntu user must be in the video group for hardware acceleration
21+
users:
22+
- default
23+
- name: ubuntu
24+
groups: video
25+
26+
# On first boot, set the (default) ubuntu user's password to "ubuntu" and
27+
# expire user passwords
28+
chpasswd:
29+
expire: true
30+
users:
31+
- name: ubuntu
32+
password: ubuntu
33+
type: text
34+
35+
## Set the system's hostname. Please note that, unless you have a local DNS
36+
## setup where the hostname is derived from DHCP requests (as with dnsmasq),
37+
## setting the hostname here will not make the machine reachable by this name.
38+
## You may also wish to install avahi-daemon (see the "packages:" key below)
39+
## to make your machine reachable by the .local domain
40+
hostname: photonvision
41+
42+
## Set up the keyboard layout. See localectl(1), in particular the various
43+
## list-x11-* sub-commands, to determine the available models, layouts,
44+
## variants, and options
45+
#keyboard:
46+
# model: pc105
47+
# layout: gb
48+
# variant:
49+
# options: ctrl:nocaps
50+
51+
# Enable password authentication with the SSH daemon
52+
ssh_pwauth: true
53+
54+
## On first boot, use ssh-import-id to give the specific users SSH access to
55+
## the default user
56+
#ssh_import_id:
57+
#- lp:my_launchpad_username
58+
#- gh:my_github_username
59+
60+
## Add users and groups to the system, and import keys with the ssh-import-id
61+
## utility
62+
#groups:
63+
#- robot: [robot]
64+
#- robotics: [robot]
65+
#- pi
66+
#
67+
#users:
68+
#- default
69+
#- name: robot
70+
# gecos: Mr. Robot
71+
# primary_group: robot
72+
# groups: users
73+
# ssh_import_id: foobar
74+
# lock_passwd: false
75+
# passwd: $5$hkui88$nvZgIle31cNpryjRfO9uArF7DYiBcWEnjqq7L1AQNN3
76+
77+
## Update apt database and upgrade packages on first boot
78+
#package_update: true
79+
#package_upgrade: true
80+
81+
## Install additional packages on first boot
82+
#packages:
83+
#- avahi-daemon
84+
#- rng-tools
85+
#- python3-gpiozero
86+
#- [python3-serial, 3.5-1]
87+
88+
## Write arbitrary files to the file-system (including binaries!)
89+
#write_files:
90+
#- path: /etc/default/console-setup
91+
# content: |
92+
# # Consult the console-setup(5) manual page.
93+
# ACTIVE_CONSOLES="/dev/tty[1-6]"
94+
# CHARMAP="UTF-8"
95+
# VIDEOMODE=
96+
# FONT="Lat15-Terminus18x10.psf.gz"
97+
# FONTFACE=
98+
# FONTSIZE=
99+
# CODESET="Lat15"
100+
# permissions: '0644'
101+
# owner: root:root
102+
#- encoding: gzip
103+
# path: /root/Makefile
104+
# content: !!binary |
105+
# H4sICF2DTWIAA01ha2VmaWxlAFNWCM8syVBILMjPyU/PTC1WKMlXiPB2dlFQNjSx5MpNteLi
106+
# dLDiSoRQxYl5KeWZyRkgXrSCkoqKRmaKgm6pppKCbmqhgoFCrIKamkK1QmpyRr6Ckn92YqWS
107+
# NdC80uQMBZhOa4VahZoaqIrwjMQSewXfxOxUhcwShcr80qLi1Jw0RSUuAIYfEJmVAAAA
108+
# owner: root:root
109+
# permissions: '0644'
110+
111+
## Run arbitrary commands at rc.local like time
112+
#runcmd:
113+
#- [ ls, -l, / ]
114+
#- [ sh, -xc, "echo $(date) ': hello world!'" ]
115+
#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ]
116+
117+
runcmd:
118+
- [ touch, /etc/cloud/cloud-init.disabled ]

install_opi5.sh

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,91 @@ if id "$1" >/dev/null 2>&1; then
44
echo 'user found'
55
else
66
echo "creating pi user"
7-
useradd pi -b /home
7+
useradd pi -m -b /home -s /bin/bash
88
usermod -a -G sudo pi
9-
mkdir /home/pi
10-
chown -R pi /home/pi
11-
129
echo 'pi ALL=(ALL) NOPASSWD: ALL' | tee -a /etc/sudoers.d/010_pi-nopasswd >/dev/null
1310
chmod 0440 /etc/sudoers.d/010_pi-nopasswd
1411
fi
1512
echo "pi:raspberry" | chpasswd
1613

17-
apt-get update
14+
apt-get update --quiet
15+
16+
before=$(df --output=used / | tail -n1)
17+
# clean up stuff
18+
echo 'Purging snaps'
19+
# get rid of snaps
20+
rm -rf /var/lib/snapd/seed/snaps/*
21+
rm -f /var/lib/snapd/seed/seed.yaml
22+
apt-get purge --yes --quiet lxd-installer lxd-agent-loader
23+
apt-get purge --yes --quiet snapd
24+
25+
# remove bluetooth daemon
26+
apt-get purge --yes --quiet bluez
27+
28+
apt-get --yes --quiet autoremove
29+
30+
after=$(df --output=used / | tail -n1)
31+
freed=$(( before - after ))
32+
33+
echo "Freed up $freed KiB"
34+
35+
# run Photonvision install script
1836
wget https://git.io/JJrEP -O install.sh
1937
chmod +x install.sh
2038

21-
sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=4-7/g' install.sh
39+
sed -i 's/# AllowedCPUs=4-7/AllowedCPUs=0-7/g' install.sh
2240

23-
./install.sh -n -q
41+
./install.sh -m -q
2442
rm install.sh
2543

44+
echo "Installing additional things"
2645

27-
# Remove extra packages
28-
echo "Purging extra things"
29-
# apt-get remove -y gdb gcc g++ linux-headers* libgcc*-dev
30-
# apt-get remove -y snapd
31-
apt-get autoremove -y
46+
apt-get install --yes --quiet network-manager net-tools libatomic1
3247

48+
# let netplan create the config during cloud-init
49+
rm -f /etc/netplan/00-default-nm-renderer.yaml
3350

34-
echo "Installing additional things"
35-
sudo apt-get update
36-
apt-get install -y network-manager net-tools libatomic1
51+
# set NetworkManager as the renderer in cloud-init
52+
cp -f ./OPi5_CIDATA/network-config /boot/network-config
3753

38-
apt-get install -y libc6 libstdc++6
54+
# add customized user-data file for cloud-init
55+
cp -f ./OPi5_CIDATA/user-data /boot/user-data
3956

40-
# cat > /etc/netplan/00-default-nm-renderer.yaml <<EOF
41-
# network:
42-
# renderer: NetworkManager
57+
# tell NetworkManager not to wait for the carrier on ethernet, which can delay boot
58+
# when the coprocessor isn't connected to the ethernet
59+
# cat > /etc/NetworkManager/conf.d/50-ignore-carrier.conf <<EOF
60+
# [main]
61+
# ignore-carrier=*
4362
# EOF
4463

64+
# modify photonvision.service to wait for the network before starting
65+
# this helps ensure that photonvision detects the network the first time it starts
66+
# but it may cause a startup delay if the coprocessor isn't connected to a network
67+
sed -i '/Description/aAfter=network-online.target' /etc/systemd/system/photonvision.service
68+
cat /etc/systemd/system/photonvision.service
69+
70+
# networkd isn't being used, this causes an unnecessary delay
71+
systemctl disable systemd-networkd-wait-online.service
72+
73+
# the bluetooth service isn't needed and causes a delay at boot
74+
systemctl disable ap6275p-bluetooth.service
75+
76+
apt-get install --yes --quiet libc6 libstdc++6
77+
4578
if [ $(cat /etc/lsb-release | grep -c "24.04") -gt 0 ]; then
4679
# add jammy to apt sources
4780
echo "Adding jammy to list of apt sources"
4881
add-apt-repository -y -S 'deb http://ports.ubuntu.com/ubuntu-ports jammy main universe'
4982
fi
5083

51-
apt-get update
84+
apt-get --quiet update
5285

5386
# mrcal stuff
54-
apt-get install -y libcholmod3 liblapack3 libsuitesparseconfig5
87+
apt-get install --yes --quiet libcholmod3 liblapack3 libsuitesparseconfig5
5588

5689

5790
rm -rf /var/lib/apt/lists/*
58-
apt-get clean
91+
apt-get --yes --quiet clean
5992

6093
rm -rf /usr/share/doc
6194
rm -rf /usr/share/locale/

0 commit comments

Comments
 (0)