Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add orange pi zero2 #189

Merged
merged 75 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
760d3fc
feat: add orange pi zero2
KwadFan Dec 29, 2022
3d49ca4
fix: fix typo due unsaved file
KwadFan Dec 29, 2022
abac2d6
chore: switch to orangepi armbian image
KwadFan Feb 19, 2023
18e0dad
chore: move orangepi images to own config and module
KwadFan Feb 20, 2023
b5a1fae
chore: remove opiconfig module
KwadFan Feb 20, 2023
d0785df
fix: add missing package unzip
KwadFan Feb 20, 2023
39ab3f4
fix: fixes enabling SPI and patching motd
KwadFan Feb 21, 2023
2911bab
chore: changed style of end_chroot_script in orangepi module
KwadFan Feb 21, 2023
3a31d77
chore: changed style of end_chroot_script in armbian module
KwadFan Feb 21, 2023
c18dc25
chore: fix description, changes code style
KwadFan Feb 21, 2023
0aeffe6
chore: replace armbian_net module with orangepi_net module
KwadFan Feb 21, 2023
142c577
chore: change header style
KwadFan Feb 21, 2023
36b11ac
fix: fix orangepi_net module
KwadFan Feb 21, 2023
86e2b7d
chore: removes unneeded step and refactor code style
KwadFan Feb 21, 2023
20879f9
chore: refactor style of orangepi end_chroot_script
KwadFan Feb 21, 2023
93e4056
chore: refactor style of armbian end_chroot_script
KwadFan Feb 21, 2023
916f8a3
chore: refactor style of armbian start_chroot_script
KwadFan Feb 21, 2023
abd2a7e
chore: refactor style of orangepi config
KwadFan Feb 21, 2023
55d5dce
chore: refactor style of armbian config
KwadFan Feb 21, 2023
8a89e0d
fix: fix mainsailos motd header file
KwadFan Feb 21, 2023
c769e0c
fix: fix typo in network_config.txt.template
KwadFan Feb 21, 2023
5c14c76
chore: changes subshell behavior in armbian end_chroot_script
KwadFan Feb 21, 2023
b988842
chore: changes subshell behavior in armbian start_chroot_script
KwadFan Feb 21, 2023
7d2b3fa
chore: refactor style of armbian start_chroot_script
KwadFan Feb 21, 2023
87bf6b4
chore: refactor style of header in config files
KwadFan Feb 21, 2023
78033e9
fix: fix build error during lock root acc
KwadFan Feb 21, 2023
a78f679
fix: wip
KwadFan Feb 21, 2023
7204aed
fix: fix build error due root account locking
KwadFan Feb 21, 2023
8ef675c
chore: add group and udev rule to use gpio
KwadFan Feb 24, 2023
7f1e546
feat: install orangepi-config from git sources
KwadFan Feb 25, 2023
de82d10
fix: fix typo in step 7, substep 4 of orangepi
KwadFan Feb 25, 2023
dd73d8f
fix: add softlink to orangepi-config
KwadFan Feb 25, 2023
4299186
chore: moves orangepi-config install to orangepi
KwadFan Feb 25, 2023
0eae23c
fix: fix typo in orangepi config
KwadFan Feb 25, 2023
f51638f
chore: wip
KwadFan Feb 25, 2023
23e796f
fix: fix copy error of main script
KwadFan Feb 25, 2023
5168296
fix: turn list into array
KwadFan Feb 25, 2023
425388a
chore: finallize and cleanup
KwadFan Feb 25, 2023
9f76d2f
fix: fix execute permission on main script
KwadFan Feb 25, 2023
47d471e
feat: enable uart and i2c by default
KwadFan Feb 25, 2023
9a66ed7
chore: add message to Steps 5 and 6
KwadFan Feb 25, 2023
d601bfb
fix: fix step count and SC2129 error
KwadFan Feb 25, 2023
df4bb0f
chore: replace Armbian with Orange Pi OS in motd
KwadFan Feb 25, 2023
fecf9b3
chore: bump version to 1.1.0-alpha
KwadFan Feb 25, 2023
35b43cf
fix: fix overlay handling in orangepi module
KwadFan Feb 25, 2023
2deb65e
fix: fix typo in overlay handling
KwadFan Feb 25, 2023
acb83bf
chore: update readme
KwadFan Feb 25, 2023
fcf4604
chore: revert update of readme
KwadFan Feb 27, 2023
196c66c
test: test permissions on /boot
KwadFan Mar 3, 2023
c1b0ac9
test: test permissions on /boot
KwadFan Mar 3, 2023
4ed7f39
revert: revert test
KwadFan Mar 3, 2023
99d5a11
chore: wip
KwadFan Mar 3, 2023
05f2ec1
Revert "chore: wip"
KwadFan Mar 3, 2023
04e683c
test: build test with sudo as dependency
KwadFan Mar 5, 2023
87f4605
Revert "test: build test with sudo as dependency"
KwadFan Mar 5, 2023
1cab790
test: install sudo in pre_chroot_script
KwadFan Mar 5, 2023
893e201
fix: fix typo in test
KwadFan Mar 5, 2023
a168806
test: change module order
KwadFan Mar 5, 2023
2d92c4e
chore: wip
KwadFan Mar 5, 2023
c919c33
fix: fix package name
KwadFan Mar 5, 2023
3311114
test: remove links and kernel package content
KwadFan Mar 5, 2023
78bb7f7
chore: wip
KwadFan Mar 5, 2023
0c6fd60
chore: wip
KwadFan Mar 5, 2023
3dd5c9c
chore: wip
KwadFan Mar 5, 2023
1f758a1
fix: fix network_config service
KwadFan Mar 9, 2023
7f39dac
fix: fixes failed build due kernel update
KwadFan Mar 9, 2023
ad73208
chore: test with v23.02 images
meteyou Mar 11, 2023
527cab0
fix: set hold packages depending on board type
KwadFan Mar 11, 2023
60af3dd
fix: patch release file location
KwadFan Mar 12, 2023
332c95a
fix: fix gpio permissions
KwadFan Mar 12, 2023
c042c0a
Merge branch 'develop' into feat/opizero2
KwadFan Mar 12, 2023
1e294e1
chore: change base_url back to mainsail-crew/armbian-builds
meteyou Mar 12, 2023
e8b3cda
Merge branch 'develop' into feat/opizero2
meteyou Mar 12, 2023
46f8878
chore: remove enduser support message
KwadFan Mar 12, 2023
e074b0c
chore: remove unneeded comment in default config
KwadFan Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/armbian/default
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,pkgupgrade,armbian(armbian_net,opiconfig,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"
MODULES="base,armbian_pkgupgrade,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"

# export Variables
export DOWNLOAD_BASE_URL
Expand Down
39 changes: 39 additions & 0 deletions config/orangepi/default
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Shebang for better file detection

# Declare Variables before exporting.
# See https://www.shellcheck.net/wiki/SC2155

# Download Base Url
DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download"

# Base User
BASE_ADD_USER="yes"
BASE_USER="pi"
BASE_USER_PASSWORD="armbian"

# Needed while building for non rpi sbc
BASE_DISTRO="armbian"
BASE_IMAGE_RASPBIAN="no"

# partition resizing
BASE_ROOT_PARTITION="2"
BASE_IMAGE_ENLARGEROOT=2500
BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,pkgupgrade,orangepi(orangepi_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)"

# export Variables
export DOWNLOAD_BASE_URL
export BASE_ADD_USER
export BASE_USER
export BASE_USER_PASSWORD
export BASE_DISTRO
export BASE_IMAGE_RASPBIAN
export BASE_ROOT_PARTITION
export BASE_IMAGE_ENLARGEROOT
export BASE_IMAGE_RESIZEROOT
export BASE_RELEASE_COMPRESS
export MODULES
14 changes: 14 additions & 0 deletions config/orangepi/orangepi_zero2
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Shebang for better file detection
# shellcheck enable=require-variable-braces

BASE_ARCH="arm64"

# Image source
DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz.sha256"
DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz"

# export Variables
export BASE_ARCH
export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE
17 changes: 15 additions & 2 deletions src/modules/armbian/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#!/bin/bash
#!/usr/bin/env bash
# Shebang for better file detection
#### MainsailOS Specific Tweaks for armbian images
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2023 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

# shellcheck disable=all

[ -n "$ARMBIAN_DEPS" ] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \
[[ -n "$ARMBIAN_DEPS" ]] || ARMBIAN_DEPS="armbian-config avahi-daemon iptables \
bash-completion"
[[ -n "$ARMBIAN_CONFIG_TXT_FILE" ]] || ARMBIAN_CONFIG_TXT_FILE="/boot/armbianEnv.txt"
[[ -n "$ARMBIAN_CONFIG_BAK_FILE" ]] || ARMBIAN_CONFIG_BAK_FILE="/boot/armbianEnv.txt.backup"
[[ -n "$ARMBIAN_MODULES_FILE" ]] || ARMBIAN_MODULES_FILE="/etc/modules"
50 changes: 34 additions & 16 deletions src/modules/armbian/end_chroot_script
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
#!/usr/bin/env bash
# MainsailOS Specific Tweaks for armbian images
# written by Stephan Wendel aka KwadFan
# <me@stephanwe.de>
# GPL V3
########
#### MainsailOS Specific Tweaks for armbian images
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2023 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

## functions
# shellcheck enable=require-variable-braces
# Source error handling, leave this in place
set -Ee

# Source CustomPIOS common.sh
# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap

## Helper functions
gen_root_pw() {
tr -dc "[:alnum:]" < /dev/urandom | head -c 50
}

# Clean up
# Remove autologin and lock root account
if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then
## Clean up
## Step 1: Remove autologin and lock root account
if [[ -f "/etc/systemd/system/getty@.service.d/override.conf" ]]; then
rm -f /etc/systemd/system/getty@.service.d/override.conf
fi
## END

# Disable autologin on serial console
if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then
## Step 2: Disable autologin on serial console
if [[ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]]; then
sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf
fi
## END

# Generate random root passwd
yes "$(gen_root_pw)" | passwd root
## Step 3: Delete root passwd
### Deleting root passwd doesn't let you unlock the account
sudo passwd -d root
## END

# lock root account
sudo -u "${BASE_USER}" passwd -l root
## Step 4: Lock root account
sudo passwd -l root
## END

# Remove passwdless sudo
## Step 5: Remove passwdless sudo
sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers
## END
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SUBSYSTEM=="gpio", KERNEL=="gpiochip[0-4]", GROUP="gpio", MODE="0660"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ if [[ -f /etc/armbian-distribution-status ]]; then
[[ -f /etc/lsb-release ]] && DISTRIBUTION_CODENAME=$(grep CODENAME /etc/lsb-release | cut -d"=" -f2)
[[ -z "${DISTRIBUTION_CODENAME}" && -f /etc/os-release ]] && DISTRIBUTION_CODENAME=$(grep VERSION_CODENAME /etc/os-release | cut -d"=" -f2)
[[ -z "${DISTRIBUTION_CODENAME}" && -x /usr/bin/lsb_release ]] && DISTRIBUTION_CODENAME=$(/usr/bin/lsb_release -c | cut -d":" -f2 | tr -d "\t")
DISTRIBUTION_STATUS=$(grep "${DISTRIBUTION_CODENAME}" /etc/armbian-distribution-status | cut -d"=" -f2)
fi
[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd

Expand All @@ -44,23 +43,3 @@ echo -e "Version $(cut -d ' ' -f3 /etc/mainsailos-release), based on \
\e[34mArmbian ${VERSION} ${DISTRIBUTION_CODENAME^}\e[0m $([[ ${BRANCH} == edge ]])"
echo -e "Running on \e[34m$(echo "${BOARD_NAME}" | sed 's/Orange Pi/OPi/' | \
sed 's/NanoPi/NPi/' | sed 's/Banana Pi/BPi/')\e[0m with \e[34mLinux ${KERNELID}\e[0m\n"

# displaying status warnings

if [[ "${IMAGE_TYPE}" != "stable" ]]; then
[[ "${IMAGE_TYPE}" == "user-built" ]] && UNSUPPORTED_TEXT="built from trunk"
[[ "${IMAGE_TYPE}" == "nightly" ]] && UNSUPPORTED_TEXT="untested automated build"
else
[[ "${BOARD_TYPE}" == "csc" || "${BOARD_TYPE}" == "tvb" ]] && UNSUPPORTED_TEXT="community creations"
[[ "${BOARD_TYPE}" == "wip" ]] && UNSUPPORTED_TEXT="work in progress"
[[ "${BOARD_TYPE}" == "eos" ]] && UNSUPPORTED_TEXT="end of life"
fi

if [[ -n ${DISTRIBUTION_STATUS} && ${DISTRIBUTION_STATUS} != supported ]]; then
[[ -n ${UNSUPPORTED_TEXT} ]] && UNSUPPORTED_TEXT+=" & "
UNSUPPORTED_TEXT+="unsupported (${DISTRIBUTION_CODENAME}) userspace!"
fi

if [[ -n ${UNSUPPORTED_TEXT} ]]; then
echo -e "\e[0;91mNo end-user support: \x1B[0m${UNSUPPORTED_TEXT}\n"
fi
119 changes: 96 additions & 23 deletions src/modules/armbian/start_chroot_script
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
#!/usr/bin/env bash
# MainsailOS Specific Tweaks for armbian images
# written by Stephan Wendel aka KwadFan
# <me@stephanwe.de>
# GPL V3
########
#### MainsailOS Specific Tweaks for armbian images
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2023 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

# shellcheck enable=require-variable-braces
# Source error handling, leave this in place
set -xe
set -Ee

# Source CustomPIOS common.sh
# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap

# Install armbian specific packages
apt update
# shellcheck disable=SC2086
check_install_pkgs ${ARMBIAN_DEPS}

# passwordless sudo during install
# Will be removed in cleanup
echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
### Helper func
is_board_type() {
local board releasefile
board=""
releasefile="/etc/armbian-release-info.txt"
if [[ -f "${releasefile}" ]]; then
board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)"
fi
echo "${board}"
}

# Base User groups
# Shameless "stolen" from
Expand All @@ -33,26 +39,93 @@ if_group_exists_run() {
fi
}

# set groups
# passwordless sudo during install
# Will be removed in cleanup
echo "${BASE_USER} ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers

## Step 1: Install armbian specific packages
apt update
# shellcheck disable=SC2086
check_install_pkgs ${ARMBIAN_DEPS}



## Step 1: Manage groups
### Substep 1: Create group for gpio usage
sudo groupadd gpio
### END Substep 1

### Substep 2: Set default groups
if_group_exists_run i2c usermod -aG i2c "${BASE_USER}"
usermod -aG video,audio,plugdev,games,netdev,sudo "${BASE_USER}"
usermod -aG video,audio,plugdev,games,netdev,sudo,systemd-journal,gpio "${BASE_USER}"
### END Substep 2

# Patch sshd_config
## Step 2: patch sshd_config
sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
sed -i 's/^X11Forwarding/#X11Forwarding/' /etc/ssh/sshd_config
sed -i 's/^#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config
## END

# Try patching first login in build stage
if [ -f "/root/.not_logged_in_yet" ]; then
## Step 4: Try patching first login in build stage
if [[ -f "/root/.not_logged_in_yet" ]]; then
rm -f /root/.not_logged_in_yet
fi
## END

# Move armbian-release to display mainsailos-release
mv /etc/armbian-release /etc/armbian-release-info.txt
## Step 5: Move armbian-release to display mainsailos-release
### Substep 1: Move armbian-release
if [[ -f "/etc/armbian-release" ]]; then
echo_green "Armbian release file found! moving to: 'armbian-release-info.txt'"
mv /etc/armbian-release /etc/armbian-release-info.txt
else
echo_red "Armbian release file not found! [SKIPPED]"
fi
### END Substep 1
### Substep 2: patch Armbian scripts to new file location
echo_green "Patching armbian scripts (release file path) ..."
pushd "/usr/lib/armbian" &> /dev/null || exit 1
files=()
while IFS='' read -r line; do
files+=("${line}")
done < <(grep -R "/etc/armbian-release" -- * | cut -d":" -f1)
for f in "${files[@]}"; do
sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}"
done
popd &> /dev/null || exit 1
## END

# update motd
## Step 6: Patch dynamic motd
echo_green "Patch dynamic motd ..."
unpack /filesystem/root /
chmod +x /etc/update-motd.d/*
if [ -f "/etc/default/armbian-motd" ]; then
if [[ -f "/etc/default/armbian-motd" ]]; then
sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd
fi
## END

## Step 7: Enable SPI interface by default
echo_green "Enable SPI interface on Orange Pi SBC's ..."

### Substep 1: Copy default config to backup file
cp "${ARMBIAN_CONFIG_TXT_FILE}" "${ARMBIAN_CONFIG_BAK_FILE}"
### END Substep 1

### Substep 2: Enable SPI in armbianEnv.txt depending on device
#### OrangePi 3 LTS
if [[ "$(is_board_type)" == "orangepi3-lts" ]]; then
echo "overlays=spi-spidev1" >> "${ARMBIAN_CONFIG_TXT_FILE}"
fi

#### OrangePi 4 LTS
if [[ "$(is_board_type)" == "orangepi4-lts" ]]; then
echo "overlays=spi-spidev" >> "${ARMBIAN_CONFIG_TXT_FILE}"
echo "param_spidev_spi_bus=1" >> "${ARMBIAN_CONFIG_TXT_FILE}"
fi
### END Substep 2:

### Substep 3: add spi-dev module to /etc/modules
echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}"
### END Substep 3

echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!"
## END
10 changes: 5 additions & 5 deletions src/modules/armbian_net/config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#Shebang for better file detection
#### mainsail module
# Shebang for better file detection
#### MainsailOS network configurator for armbian images
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2023 - till today
Expand All @@ -11,6 +11,6 @@

# shellcheck disable=all

[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template"
[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config"
[ -n "$ARMBIAN_NET_NC_PATH" ] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator"
[[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ]] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template"
[[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ]] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config"
[[ -n "$ARMBIAN_NET_NC_PATH" ]] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator"
Loading