diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index ed13291dd..96340b05d 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -2,7 +2,7 @@ name: Build RatOS on: push: branches: - - "v2.x" + - "orange_pi_3lts_using_official_image" paths: - "src/modules/**" - "src/build_dist" @@ -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: diff --git a/config/armbian/CB1 b/config/armbian/CB1 index 8c9a1f042..860458e87 100644 --- a/config/armbian/CB1 +++ b/config/armbian/CB1 @@ -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" \ No newline at end of file +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" diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts new file mode 100644 index 000000000..2ef00137c --- /dev/null +++ b/config/armbian/orangepi3lts @@ -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" \ No newline at end of file diff --git a/src/modules/cb1spi/start_chroot_script b/src/modules/cb1spi/start_chroot_script index 662a6d919..b07c69447 100644 --- a/src/modules/cb1spi/start_chroot_script +++ b/src/modules/cb1spi/start_chroot_script @@ -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 @@ -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 @@ -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!" \ No newline at end of file +echo_green "Enable SPI interface on CB1 SBC ... DONE!" +>>>>>>> upstream/v2.x:src/modules/cb1spi/start_chroot_script diff --git a/src/modules/deb_mirrors/start_chroot_script b/src/modules/deb_mirrors/start_chroot_script new file mode 100644 index 000000000..720eb752b --- /dev/null +++ b/src/modules/deb_mirrors/start_chroot_script @@ -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 \ No newline at end of file diff --git a/src/modules/hotspot_cb1/start_chroot_script b/src/modules/hotspot_cb1/start_chroot_script index b8658576d..ac174422d 100644 --- a/src/modules/hotspot_cb1/start_chroot_script +++ b/src/modules/hotspot_cb1/start_chroot_script @@ -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}" diff --git a/src/modules/hotspot_orangepi/config b/src/modules/hotspot_orangepi/config new file mode 100644 index 000000000..60e3040f9 --- /dev/null +++ b/src/modules/hotspot_orangepi/config @@ -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 diff --git a/src/modules/hotspot_orangepi/filesystem/root/etc/create_ap.conf b/src/modules/hotspot_orangepi/filesystem/root/etc/create_ap.conf new file mode 100644 index 000000000..de2d0c454 --- /dev/null +++ b/src/modules/hotspot_orangepi/filesystem/root/etc/create_ap.conf @@ -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 \ No newline at end of file diff --git a/src/modules/hotspot_orangepi/filesystem/root/usr/bin/start_hotspot.sh b/src/modules/hotspot_orangepi/filesystem/root/usr/bin/start_hotspot.sh new file mode 100644 index 000000000..a052d9cb6 --- /dev/null +++ b/src/modules/hotspot_orangepi/filesystem/root/usr/bin/start_hotspot.sh @@ -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 \ No newline at end of file diff --git a/src/modules/hotspot_orangepi/filesystem/root/usr/lib/systemd/system/create_ap.service b/src/modules/hotspot_orangepi/filesystem/root/usr/lib/systemd/system/create_ap.service new file mode 100644 index 000000000..c4c419472 --- /dev/null +++ b/src/modules/hotspot_orangepi/filesystem/root/usr/lib/systemd/system/create_ap.service @@ -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 \ No newline at end of file diff --git a/src/modules/hotspot_orangepi/start_chroot_script b/src/modules/hotspot_orangepi/start_chroot_script new file mode 100644 index 000000000..d2e567404 --- /dev/null +++ b/src/modules/hotspot_orangepi/start_chroot_script @@ -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!" diff --git a/src/modules/orangepiconfig/config b/src/modules/orangepiconfig/config new file mode 100644 index 000000000..86965e9f0 --- /dev/null +++ b/src/modules/orangepiconfig/config @@ -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" diff --git a/src/modules/orangepiconfig/filesystem/root/etc/udev/rules.d/90-gpio-spi.rules b/src/modules/orangepiconfig/filesystem/root/etc/udev/rules.d/90-gpio-spi.rules new file mode 100644 index 000000000..8da31277e --- /dev/null +++ b/src/modules/orangepiconfig/filesystem/root/etc/udev/rules.d/90-gpio-spi.rules @@ -0,0 +1,2 @@ +KERNEL=="spidev0.0", OWNER="root", GROUP="spi" +KERNEL=="spidev0.1", OWNER="root", GROUP="spi" \ No newline at end of file diff --git a/src/modules/orangepiconfig/start_chroot_script b/src/modules/orangepiconfig/start_chroot_script new file mode 100644 index 000000000..b2c52e8f0 --- /dev/null +++ b/src/modules/orangepiconfig/start_chroot_script @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# Preinstall customized config.txt +# Written by Stephan Wendel 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 diff --git a/src/modules/spi/config b/src/modules/spi/config new file mode 100644 index 000000000..3008296d0 --- /dev/null +++ b/src/modules/spi/config @@ -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" \ No newline at end of file diff --git a/src/modules/spi/start_chroot_script b/src/modules/spi/start_chroot_script new file mode 100644 index 000000000..690f4c9b2 --- /dev/null +++ b/src/modules/spi/start_chroot_script @@ -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!" \ No newline at end of file