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

Add Orange pi 3lts support #93

Open
wants to merge 21 commits into
base: v2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fd5c3bc
feat: support orange pi 3 lts
jscancella Mar 7, 2023
b10b48a
fix: update armbian image
jscancella Mar 7, 2023
c85be1b
fix: check for file before trying to copy it
jscancella Mar 7, 2023
2a1ad7f
fix: add hostapd and spi to orangepi
jscancella Mar 8, 2023
b5dd2ea
fix: startup wifi after configurator sets ssid and password
jscancella Mar 11, 2023
33ffa5e
fix: update variable name to match
jscancella Mar 11, 2023
8a6017d
fix: enable spi
jscancella Mar 16, 2023
7d280da
Merge branch 'orange_pi_3lts' of https://github.com/jscancella/RatOS …
jscancella Mar 16, 2023
6b0d257
feat: use official orange pi os instead of armbian
jscancella Mar 18, 2023
a01c56c
ci: make the workflow run on this branch
jscancella Mar 18, 2023
5f6ef51
fix: only one partition
jscancella Mar 18, 2023
7908fd2
fix: update the correct file for SPI
jscancella Mar 19, 2023
9a3cb87
ci: update deb mirrors so it is faster to build
jscancella Mar 20, 2023
78d829d
ci: add mirrors earlier in build
jscancella Mar 20, 2023
20fc7a2
fix: quote the SSID and password because people use spaces...
jscancella Mar 21, 2023
d037ce8
fix: add link to /etc/board-release for orange pi
jscancella Mar 21, 2023
f51d1f3
fix: remove sudo because script is already running as root
jscancella Mar 22, 2023
3893f09
feat: add more log information when starting hotspot and wifi
jscancella Mar 24, 2023
bd97f16
fix: add pause to allow wifi to be up fully before continuing to chec…
jscancella Mar 26, 2023
6bf3f99
Merge remote-tracking branch 'upstream/v2.x' into orange_pi_3lts_usin…
jscancella May 30, 2023
1014ab8
Merge branch 'v2.x' into orange_pi_3lts_using_official_image
jscancella Aug 8, 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
4 changes: 2 additions & 2 deletions .github/workflows/BuildImages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build RatOS
on:
push:
branches:
- "v2.x"
- "orange_pi_3lts_using_official_image"
paths:
- "src/modules/**"
- "src/build_dist"
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Create Matrix
id: set-matrix
run: |
ARRAY=$(find ${{ github.workspace }}/config -type f -printf '%P\n' | sed '/default/d' | sort | jq -R -s -c 'split("\n")[:-1]')
ARRAY=$(find ${{ github.workspace }}/config -type f -name orangepi3lts -printf '%P\n' | sed '/default/d' | sort | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${ARRAY}" >> $GITHUB_OUTPUT

build:
Expand Down
2 changes: 1 addition & 1 deletion config/armbian/CB1
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export BASE_IMAGE_RESIZEROOT
export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE

export MODULES="base,deb_namserver,passwordless_sudo,pkgupgrade(network,cb1config,klipper,node,is_req_preinstall,moonraker,cb1spi,ratos(mainsail,crowsnest,linear_movement_analysis,timelapse,klipperscreen,rpi_mcu,disable-services(hotspot_cb1),dfu-util),password-for-sudo),postrename"
export MODULES="base,deb_namserver,passwordless_sudo,pkgupgrade(network,cb1config,klipper,node,is_req_preinstall,moonraker,cb1spi,ratos(mainsail,crowsnest,linear_movement_analysis,timelapse,klipperscreen,rpi_mcu,disable-services(hotspot_cb1),dfu-util),password-for-sudo),postrename"
26 changes: 26 additions & 0 deletions config/armbian/orangepi3lts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# Shebang for better file detection
# shellcheck enable=require-variable-braces

BASE_ARCH="arm64"
BASE_IMAGE_ENLARGEROOT=10500
BASE_IMAGE_RESIZEROOT=600
BASE_ADD_USER="yes"
BASE_USER="pi"
BASE_USER_PASSWORD="raspberry"
#only needed for official armbian images
#export BASE_DISTRO=armbian
export BASE_ROOT_PARTITION=1

# Image source
DOWNLOAD_URL_CHECKSUM="https://github.com/jscancella/RatOS/releases/download/orange_pi_os/Orangepi3-lts_3.0.8_debian_bullseye_server_linux5.16.17.img.sha256"
DOWNLOAD_URL_IMAGE="https://github.com/jscancella/RatOS/releases/download/orange_pi_os/Orangepi3-lts_3.0.8_debian_bullseye_server_linux5.16.17.img.xz"

# export Variables
export BASE_ARCH
export BASE_IMAGE_ENLARGEROOT
export BASE_IMAGE_RESIZEROOT
export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE

export MODULES="base,deb_mirrors,passwordless_sudo,pkgupgrade(network,orangepiconfig,klipper,node,is_req_preinstall,moonraker,spi,ratos(mainsail,crowsnest,linear_movement_analysis,timelapse,klipperscreen,rpi_mcu,disable-services(hotspot_orangepi),dfu-util),password-for-sudo),postrename"
25 changes: 24 additions & 1 deletion src/modules/cb1spi/start_chroot_script
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash
<<<<<<< HEAD:src/modules/spi/start_chroot_script
#### enable SPI
=======
#### CB1SPI - SB1 Configuration Module
>>>>>>> upstream/v2.x:src/modules/cb1spi/start_chroot_script
#from https://www.reddit.com/r/BIGTREETECH/comments/xfom6n/comment/it32e6v/

# shellcheck enable=require-variable-braces
Expand All @@ -17,6 +21,24 @@ fi
source /common.sh
install_cleanup_trap

<<<<<<< HEAD:src/modules/spi/start_chroot_script
echo_green "Enable SPI interface on SBC's ..."

# Step 1: Copy default config to backup file

if [[ -e "${SPI_CONFIG_TXT_FILE}" ]]
then
cp "${SPI_CONFIG_TXT_FILE}" "${SPI_CONFIG_BAK_FILE}"
fi

# Step 2: Enable SPI
echo "overlays=spi" >> "${SPI_CONFIG_TXT_FILE}"
echo "spidevparam_spidev_spi_bus=1" >> "${SPI_CONFIG_TXT_FILE}"
echo "param_spidev_spi_cs=1" >> "${SPI_CONFIG_TXT_FILE}"
echo "param_spidev_max_freq=1000000" >> "${SPI_CONFIG_TXT_FILE}"

echo_green "Enable SPI interface on SBC ... DONE!"
=======
echo_green "Enable SPI interface on CB1 SBC's ..."

# Step 1: Copy default config to backup file
Expand All @@ -25,4 +47,5 @@ cp "${CB1SPI_CONFIG_TXT_FILE}" "${CB1SPI_CONFIG_BAK_FILE}"
# Step 2: Enable SPI
sed -i 's/^#overlays=spidev1_2.*/overlays=spidev1_2/' "${CB1SPI_CONFIG_TXT_FILE}"

echo_green "Enable SPI interface on CB1 SBC ... DONE!"
echo_green "Enable SPI interface on CB1 SBC ... DONE!"
>>>>>>> upstream/v2.x:src/modules/cb1spi/start_chroot_script
17 changes: 17 additions & 0 deletions src/modules/deb_mirrors/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# because orangepi os uses china mirrors and that is too slow for building on github
########

# Source error handling, leave this in place
set -xe

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

echo "deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free

deb http://deb.debian.org/debian bullseye-backports main contrib non-free
#deb http://deb.debian.org/debian bullseye-security main contrib non-free" > /etc/apt/sources.list
2 changes: 1 addition & 1 deletion src/modules/hotspot_cb1/start_chroot_script
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source /common.sh
install_cleanup_trap

echo_green "Install ratos hotspot tool dependencies..."
check_install_pkgs dnsmasq
check_install_pkgs dnsmasq hostapd

echo_green "Downloading ratos hotspot tool..."
pushd "/home/${BASE_USER}"
Expand Down
2 changes: 2 additions & 0 deletions src/modules/hotspot_orangepi/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[ -n "$HOTSPOT_ORANGEPI_SHIP" ] || HOTSPOT_ORANGEPI_SHIP=https://github.com/oblique/create_ap
[ -n "$HOTSPOT_ORANGEPI_BRANCH" ] || HOTSPOT_ORANGEPI_BRANCH=master
28 changes: 28 additions & 0 deletions src/modules/hotspot_orangepi/filesystem/root/etc/create_ap.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
CHANNEL=default
GATEWAY=192.168.50.1
WPA_VERSION=2
ETC_HOSTS=0
DHCP_DNS=gateway
NO_DNS=0
NO_DNSMASQ=0
HIDDEN=0
MAC_FILTER=0
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
ISOLATE_CLIENTS=0
SHARE_METHOD=nat
IEEE80211N=0
IEEE80211AC=0
HT_CAPAB=[HT40+]
VHT_CAPAB=
DRIVER=nl80211
NO_VIRT=1
COUNTRY=
FREQ_BAND=2.4
NEW_MACADDR=
DAEMONIZE=0
NO_HAVEGED=0
WIFI_IFACE=wlan0
INTERNET_IFACE=eth0
SSID=RatOS
PASSPHRASE=raspberry
USE_PSK=0
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
#because it takes some time before the wifi is up and able to detect networks
sleep 30

if [[ -e /etc/wpa_supplicant/wpa_supplicant.conf ]]
then
#get info from wpa_supplicant
SSID=`grep -E "^\s+ssid" /etc/wpa_supplicant/wpa_supplicant.conf | sed 's/^[[:space:]]*//g' | cut -c 7- | sed 's/.$//'`
#PASSWORD=`grep -E "^\s+#psk" /etc/wpa_supplicant/wpa_supplicant.conf | sed 's/^[[:space:]]*//g' | cut -c 6-`
PASSWORD=`grep -E "^\s+psk" /etc/wpa_supplicant/wpa_supplicant.conf | sed 's/^[[:space:]]*//g' | cut -c 5-`
echo "preparing to connect to wifi with SSID: '${SSID}' and password: '${PASSWORD}'"
nmcli dev wifi connect "${SSID}" password "${PASSWORD}"
fi

#if wifi is not connected
ip link show dev wlan0 | grep -q "state UP"
check=$?
if [ "$check" -ne 0 ]
then
echo "starting RatOS hotspot"
/usr/bin/create_ap --config /etc/create_ap.conf
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Generate hotspot or connect to SSID
After=network-online.target
Requires=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/start_hotspot.sh

[Install]
WantedBy=multi-user.target
29 changes: 29 additions & 0 deletions src/modules/hotspot_orangepi/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# install ratos wifi hotspot on cb1
# GPL V3
########

# Error handling
set -xe

source /common.sh
install_cleanup_trap

echo_green "Install ratos hotspot tool dependencies..."
check_install_pkgs dnsmasq hostapd

echo_green "Downloading ratos hotspot tool..."
pushd "/home/${BASE_USER}"
gitclone HOTSPOT_ORANGEPI create_ap

echo_green "Installing ratos hotspot tool..."
pushd "/home/${BASE_USER}/create_ap"
make install

#edit the config
unpack /filesystem/root /

chmod +x /usr/bin/start_hotspot.sh

systemctl enable create_ap
echo_green "Installing ratos hotspot tool ... DONE!"
6 changes: 6 additions & 0 deletions src/modules/orangepiconfig/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Shebang for better file detection

[ -n "$PICONFIG_SWAP_CONF_FILE" ] || PICONFIG_SWAP_CONF_FILE="/etc/dphys-swapfile"
[ -n "$PICONFIG_SWAP_SIZE" ] || PICONFIG_SWAP_SIZE="256"
[ -n "$PICONFIG_SWAP_MAX" ] || PICONFIG_SWAP_MAX="1024"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KERNEL=="spidev0.0", OWNER="root", GROUP="spi"
KERNEL=="spidev0.1", OWNER="root", GROUP="spi"
68 changes: 68 additions & 0 deletions src/modules/orangepiconfig/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# Preinstall customized config.txt
# Written by Stephan Wendel <[email protected]> aka KwadFan
# This file may distributed under GPLv3
# Copyright 2021
########

# shellcheck enable=require-variable-braces

## Source error handling, leave this in place
set -Eex

# Set DEBIAN_FRONTEND to noninteractive
if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then
export DEBIAN_FRONTEND=noninteractive
fi

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

# Step 1: Copy 90-gpio-spi.rules
echo_green "Copying 90-gpio-spi.rules..."
unpack /filesystem/root /

# Step 2: enable SPI
groupadd -f --system spi
usermod -a -G spi "${BASE_USER}"

# for armbian images
if [[ "$BASE_DISTRO" == "armbian" ]]
then
echo "overlays=spi-spidev1
param_spidev_spi_bus=1" >> /boot/armbianEnv.txt
else
# for orangepi os images
echo "overlays=spi-spidev1
param_spidev_spi_bus=1" >> orangepiEnv.txt
fi

echo "spidev" >> /etc/modules

# Step 3: Disable bluetooth and related services
echo_green "Disabling Bluetooth related services..."
systemctl_if_exists disable hciuart.service
systemctl_if_exists disable bluetooth.service
systemctl_if_exists disable bluealsa.service

# Step 4: Increase swapfile size
if [[ -f "${PICONFIG_SWAP_CONF_FILE}" ]]; then
echo_green "Increasing swap file size to ${PICONFIG_SWAP_SIZE} Mb. Limit to ${PICONFIG_SWAP_MAX} Mb"
sed -i 's/^CONF_SWAPSIZE.*/'CONF_SWAPSIZE="${PICONFIG_SWAP_SIZE}"'/' "${PICONFIG_SWAP_CONF_FILE}"
sed -i 's/^#CONF_MAXSWAP.*/'CONF_MAXSWAP="${PICONFIG_SWAP_MAX}"'/' "${PICONFIG_SWAP_CONF_FILE}"
fi

# install avahi so ratos.local works
check_install_pkgs avahi

#add the same groups as the biqu user
usermod -a -G disk,audio,plugdev,games,users,systemd-journal,input,netdev,ssh "${BASE_USER}"

#make sure /etc/board-release exists
if [ ! -f /etc/board-release ]
then
#using the orange pi os image which doesn't have /etc/board-release but has /etc/orangepi-release
ln -s /etc/orangepi-release /etc/board-release
fi
8 changes: 8 additions & 0 deletions src/modules/spi/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
#### enable SPI

# Shebang for better file detection
# shellcheck disable=all

[ -n "$SPI_CONFIG_TXT_FILE" ] || SPI_CONFIG_TXT_FILE="/boot/BoardEnv.txt"
[ -n "$SPI_CONFIG_BAK_FILE" ] || SPI_CONFIG_BAK_FILE="/boot/BoardEnv.txt.backup"
35 changes: 35 additions & 0 deletions src/modules/spi/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
#### enable SPI
#from https://www.reddit.com/r/BIGTREETECH/comments/xfom6n/comment/it32e6v/

# shellcheck enable=require-variable-braces

## Source error handling, leave this in place
set -Ee

# Set DEBIAN_FRONTEND to noninteractive
if [[ "${DEBIAN_FRONTEND}" != "noninteractive" ]]; then
export DEBIAN_FRONTEND=noninteractive
fi

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

echo_green "Enable SPI interface on SBC's ..."

# Step 1: Copy default config to backup file

if [[ -e "${SPI_CONFIG_TXT_FILE}" ]]
then
cp "${SPI_CONFIG_TXT_FILE}" "${SPI_CONFIG_BAK_FILE}"
fi

# Step 2: Enable SPI
echo "overlays=spi" >> "${SPI_CONFIG_TXT_FILE}"
echo "spidevparam_spidev_spi_bus=1" >> "${SPI_CONFIG_TXT_FILE}"
echo "param_spidev_spi_cs=1" >> "${SPI_CONFIG_TXT_FILE}"
echo "param_spidev_max_freq=1000000" >> "${SPI_CONFIG_TXT_FILE}"

echo_green "Enable SPI interface on SBC ... DONE!"