From b2c3af18879ee8c4e4d2eca9ae27ddf64a66153f Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 01:36:40 -0800 Subject: [PATCH 01/23] Fixed getting interface state ip link was reporting interface as down when wifi was not connected. --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh old mode 100755 new mode 100644 index 4757a4f..0ff79a6 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh @@ -53,7 +53,7 @@ sync_states() { log "Synced mobile Wi-Fi state to $text_state." fi - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$text_state" != "$current_wlan_state" ]]; then set_wlan_state "$text_state" log "Synced wlan0 state to $text_state." @@ -63,7 +63,7 @@ sync_states() { monitor_changes() { local previous_mobile_state previous_wlan_state previous_mobile_state=$(get_mobile_wifi_state) - previous_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + previous_wlan_state=$(cat /sys/class/net/wlan0/operstate) while true; do PID=$(ps -C meshtasticd -o pid= | tr -d ' ') @@ -71,7 +71,7 @@ monitor_changes() { #if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then local current_mobile_state current_wlan_state current_mobile_state=$(get_mobile_wifi_state) - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" From 8dcc88e961c4adf050f2d25fedd2b54a056eda66 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 01:43:55 -0800 Subject: [PATCH 02/23] Change the way wifi mesh control gets the state of the interface ip link was reporting the interface as down when wifi was disconnected so switched to operstate to get authoritative interface state. --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh old mode 100755 new mode 100644 index 4757a4f..0ff79a6 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh @@ -53,7 +53,7 @@ sync_states() { log "Synced mobile Wi-Fi state to $text_state." fi - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$text_state" != "$current_wlan_state" ]]; then set_wlan_state "$text_state" log "Synced wlan0 state to $text_state." @@ -63,7 +63,7 @@ sync_states() { monitor_changes() { local previous_mobile_state previous_wlan_state previous_mobile_state=$(get_mobile_wifi_state) - previous_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + previous_wlan_state=$(cat /sys/class/net/wlan0/operstate) while true; do PID=$(ps -C meshtasticd -o pid= | tr -d ' ') @@ -71,7 +71,7 @@ monitor_changes() { #if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then local current_mobile_state current_wlan_state current_mobile_state=$(get_mobile_wifi_state) - current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") + current_wlan_state=$(cat /sys/class/net/wlan0/operstate) if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" From 0528e075ebf615ea9c2e34d5482a126c10230d3c Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 02:11:33 -0800 Subject: [PATCH 03/23] wifi mesh control checks for wlan0 existence If wlan0 does not exist, do nothing, --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh index 0ff79a6..9192e03 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh @@ -67,8 +67,8 @@ monitor_changes() { while true; do PID=$(ps -C meshtasticd -o pid= | tr -d ' ') - if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID"; then - #if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then + #if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID"; then + if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID" && [[ -d /sys/class/net/wlan0 ]]; then local current_mobile_state current_wlan_state current_mobile_state=$(get_mobile_wifi_state) current_wlan_state=$(cat /sys/class/net/wlan0/operstate) From 9ddd4625858fa95d8bcca0e303e9ea3315238cee Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 16 Jan 2025 20:47:07 -0800 Subject: [PATCH 04/23] Added DTS files for Luckfox Pico U I have not tested this. A full sdk install would be needed and the correct board selected. --- .../boot/dts/rv1106g-luckfox-pico-ultra-w.dts | 147 ++++++++++++++++++ .../boot/dts/rv1106g-luckfox-pico-ultra.dts | 81 ++++++++++ 2 files changed, 228 insertions(+) create mode 100644 foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts create mode 100644 foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts diff --git a/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts new file mode 100644 index 0000000..2465807 --- /dev/null +++ b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra-w.dts @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2022 Rockchip Electronics Co., Ltd. + */ + +/dts-v1/; +#include "rv1106.dtsi" +#include "rv1106-luckfox-pico-ultra-ipc.dtsi" +#include +#include + +/ { + model = "Luckfox Pico Ultra W"; + compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3"; + + restart-poweroff { + compatible = "restart-poweroff"; + }; + + sdio_pwrseq: sdio-pwrseq { + compatible = "mmc-pwrseq-simple"; + pinctrl-names = "default"; + reset-gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_LOW>; + }; + + wireless_bluetooth: wireless-bluetooth { + compatible = "bluetooth-platdata"; + uart_rts_gpios = <&gpio0 RK_PA5 GPIO_ACTIVE_LOW>; + pinctrl-names = "default", "rts_gpio"; + pinctrl-0 = <&uart1m0_rtsn>; + pinctrl-1 = <&uart1_gpios>; + BT,wake_gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>; + BT,wake_host_irq = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>; + status = "okay"; + }; +}; + +/**********CRU**********/ +//&cru { +// assigned-clocks = +// <&cru PLL_GPLL>, <&cru PLL_CPLL>, +// <&cru ARMCLK>, +// <&cru ACLK_PERI_ROOT>, <&cru HCLK_PERI_ROOT>, +// <&cru PCLK_PERI_ROOT>, <&cru ACLK_BUS_ROOT>, +// <&cru PCLK_TOP_ROOT>, <&cru PCLK_PMU_ROOT>, +// <&cru HCLK_PMU_ROOT>, <&cru CLK_500M_SRC>; +// assigned-clock-rates = +// <1188000000>, <700000000>, +// <1104000000>, +// <400000000>, <200000000>, +// <100000000>, <300000000>, +// <100000000>, <100000000>, +// <200000000>, <700000000>; +//}; + +/**********NPU**********/ +//&npu { +// assigned-clock-rates = <700000000>; +//}; + +/**********EMMC**********/ +&emmc { + bus-width = <8>; + cap-mmc-highspeed; + non-removable; + // mmc-hs200-1_8v; + rockchip,default-sample-phase = <90>; + no-sdio; + no-sd; + memory-region-ecsd = <&mmc_ecsd>; + post-power-on-delay-ms = <0>; + status = "okay"; +}; + +&fiq_debugger { + rockchip,irq-mode-enable = <1>; + status = "okay"; +}; + +/**********SDIO-WIFI**********/ +&sdmmc { + max-frequency = <50000000>; + bus-width = <4>; + cap-sd-highspeed; + cap-sdio-irq; + keep-power-in-suspend; + non-removable; + rockchip,default-sample-phase = <90>; + // no-sd; + // no-mmc; + supports-sdio; + mmc-pwrseq = <&sdio_pwrseq>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_bus4 &sdmmc0_det>; + status = "okay"; +}; + +&pinctrl{ + sdmmc0{ + sdmmc0_det: sdmmc0-det { + rockchip,pins = + /* sdmmc0_det */ + <3 RK_PA1 1 &pcfg_pull_down>; + }; + }; +}; + + +/**********ETH**********/ +&gmac { + status = "okay"; +}; + +/**********USB**********/ +&usbdrd_dwc3 { + status = "okay"; + dr_mode = "host"; + #dr_mode = "host"; +}; + +/**********RTC**********/ +&rtc { + status = "okay"; +}; + +/**********BT**********/ +&uart1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&uart1m0_xfer &uart1m0_ctsn>; +}; + +&pinctrl { + wireless-bluetooth { + uart1_gpios: uart1-gpios { + rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +}; + +/**********SPI**********/ +&spi0 { + status = "okay"; + spidev@0 { + spi-max-frequency = <50000000>; + }; +}; diff --git a/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts new file mode 100644 index 0000000..c988795 --- /dev/null +++ b/foxbuntu/sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-ultra.dts @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2022 Rockchip Electronics Co., Ltd. + */ + +/dts-v1/; +#include "rv1106.dtsi" +#include "rv1106-luckfox-pico-ultra-ipc.dtsi" +#include +#include + +/ { + model = "Luckfox Pico Ultra"; + compatible = "rockchip,rv1103g-38x38-ipc-v10", "rockchip,rv1106g3"; +}; + +/**********CRU**********/ +//&cru { +// assigned-clocks = +// <&cru PLL_GPLL>, <&cru PLL_CPLL>, +// <&cru ARMCLK>, +// <&cru ACLK_PERI_ROOT>, <&cru HCLK_PERI_ROOT>, +// <&cru PCLK_PERI_ROOT>, <&cru ACLK_BUS_ROOT>, +// <&cru PCLK_TOP_ROOT>, <&cru PCLK_PMU_ROOT>, +// <&cru HCLK_PMU_ROOT>, <&cru CLK_500M_SRC>; +// assigned-clock-rates = +// <1188000000>, <700000000>, +// <1104000000>, +// <400000000>, <200000000>, +// <100000000>, <300000000>, +// <100000000>, <100000000>, +// <200000000>, <700000000>; +//}; + +/**********NPU**********/ +//&npu { +// assigned-clock-rates = <700000000>; +//}; + +/**********EMMC**********/ +&emmc { + bus-width = <8>; + cap-mmc-highspeed; + non-removable; + // mmc-hs200-1_8v; + rockchip,default-sample-phase = <90>; + no-sdio; + no-sd; + memory-region-ecsd = <&mmc_ecsd>; + post-power-on-delay-ms = <0>; + status = "okay"; +}; + +&fiq_debugger { + rockchip,irq-mode-enable = <1>; + status = "okay"; +}; + +/**********ETH**********/ +&gmac { + status = "okay"; +}; + +/**********USB**********/ +&usbdrd_dwc3 { + status = "okay"; + dr_mode = "host"; +}; + +/**********RTC**********/ +&rtc { + status = "okay"; +}; + +/**********SPI**********/ +&spi0 { + status = "okay"; + spidev@0 { + spi-max-frequency = <50000000>; + }; +}; From 9992c7ab4241d7ec4cca02cf1e249493c3cf791e Mon Sep 17 00:00:00 2001 From: Ruledo Date: Fri, 17 Jan 2025 23:26:47 -0800 Subject: [PATCH 05/23] Had to change avahi back to 80 temporarily 4403 is unreliable and I am guessing it's because we are on an old version of meshtastic. Will revisit this when we move to the meshtastic package repo. --- .../etc/avahi/services/meshtasticd.service | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service index e0e3ece..8240266 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/avahi/services/meshtasticd.service @@ -3,7 +3,7 @@ Meshtastic - _meshtastic._tcp - 4403 + _http._tcp + 80 - \ No newline at end of file + From 3bc3d6d008107c80d30d510cc0c327acae963c53 Mon Sep 17 00:00:00 2001 From: joshbowyer <37744796+joshbowyer@users.noreply.github.com> Date: Sat, 18 Jan 2025 15:01:28 -0600 Subject: [PATCH 06/23] Update wifi-mesh-control.service Add Requires so wifi-mesh-control wont start until meshtasticd is fully up. Also removed After directive for network.target as meshtasticd service file already has this. Meshtasticd should be up before this service runs. --- .../lib/systemd/system/wifi-mesh-control.service | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/wifi-mesh-control.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/wifi-mesh-control.service index d07e1c7..3860f53 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/wifi-mesh-control.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/wifi-mesh-control.service @@ -1,6 +1,7 @@ [Unit] Description=Meshtastic control of wifi -After=network.target +After=meshtasticd.service +Requires=meshtasticd.service [Service] ExecStart=/usr/local/bin/wifi-mesh-control.sh From 26e4297064f2ea2e46e8041aafe55e83342b2dbf Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 03:02:53 -0800 Subject: [PATCH 07/23] Override for meshtasticd boot order. meshtasticd api wouldn't respond when started too early. Thx @noon92 for pushing this across the finish line. --- .../etc/systemd/system/meshtasticd.service.d/override.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 9afc90b..a28f864 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,3 +1,6 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +[Unit] +After=rc-local.service +Wants=rc-local.service From 2c038a41726f3fb9dd2a22ec18e3872b7dcfb1da Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Sun, 19 Jan 2025 15:09:33 +0200 Subject: [PATCH 08/23] Revert "Override for meshtasticd boot order." --- .../etc/systemd/system/meshtasticd.service.d/override.conf | 3 --- 1 file changed, 3 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index a28f864..9afc90b 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,6 +1,3 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' -[Unit] -After=rc-local.service -Wants=rc-local.service From 14e6c36c7bc7a0aead46363928476f87309a61ef Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 19:09:53 -0800 Subject: [PATCH 09/23] Fixed bad permission +x --- .../out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh old mode 100644 new mode 100755 From c7c627f0d91aa60d239c241210be9a16d96d3cdf Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 19:17:26 -0800 Subject: [PATCH 10/23] Re-engineered rc.local Moved femto-runonce to a service Moved femto-usb-config-tool to a service re-added override for meshtasticd to execute after rc-local small fix in femto-network-config ro removed uneeded steps (same as I did in wifi config) added a step in runonce that if no user logged in and already has been been run once, exit and do not run menu. --- .../overlay/overlay-luckfox-ubuntu/etc/rc.local | 12 +++++------- .../etc/systemd/system/femto-runonce.service | 16 ++++++++++++++++ .../system/femto-usb-config-tool.service | 17 +++++++++++++++++ .../system/meshtasticd.service.d/override.conf | 3 +++ .../usr/local/bin/femto-network-config.sh | 4 ++-- .../usr/local/bin/femto-runonce.sh | 5 ++++- .../usr/local/bin/femto-usb-config-tool.sh | 0 7 files changed, 47 insertions(+), 10 deletions(-) mode change 100755 => 100644 foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh diff --git a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local old mode 100755 new mode 100644 index 067210a..8fb738c --- a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local +++ b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local @@ -4,14 +4,12 @@ #/etc/init.d/S50usbdevice start #run only on first boot -if [ -e "/etc/.firstboot" ]; then - /usr/local/bin/femto-runonce.sh -fi +#if [ -e "/etc/.firstboot" ]; then +# /usr/local/bin/femto-runonce.sh +#fi luckfox-config load -systemctl restart meshtasticd #TEMPORARY bugfix - # try enable RTC echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1 @@ -25,14 +23,14 @@ echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction #(sleep 5 && cpufreq-set -u 408000 && echo "Boot complete, setting CPU frequency to 408mhz.") & # run USB automount and config tool -/usr/local/bin/femto-usb-config-tool.sh +#/usr/local/bin/femto-usb-config-tool.sh # boot complete ( echo "Disabling ACT LED..." echo "none" > /sys/class/leds/work/trigger & sleep 1 - + # blink successful boot code for i in $(seq 1 5); do echo 1 > /sys/class/gpio/gpio34/value; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service new file mode 100644 index 0000000..eb4c075 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service @@ -0,0 +1,16 @@ +[Unit] +Description=Foxbuntu First Boot +After=meshtasticd.service +Requires=meshtasticd.service +Before=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-runonce.sh +Type=oneshot +RemainAfterExit=true +StandardOutput=tty +StandardError=tty + +[Install] +WantedBy=serial-getty@ttyFIQ0.service diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service new file mode 100644 index 0000000..a675c9f --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service @@ -0,0 +1,17 @@ +[Unit] +Description=Foxbuntu USB Configuration Tool +After=femto-runonce.service meshtasticd.service +Before=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-usb-config-tool.sh +Type=oneshot +RemainAfterExit=true +StandardOutput=journal+console +StandardError=journal+console +TTYPath=/dev/console + +[Install] +WantedBy=serial-getty@ttyFIQ0.service + diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 9afc90b..1d992e3 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,3 +1,6 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +[Unit] +After=rc-local.service +Wants=rc-local.service diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh old mode 100755 new mode 100644 index aae75e8..50140c2 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh @@ -155,7 +155,7 @@ done if [ "$updated_wifi" = true ]; then ip link set wlan0 up - systemctl restart wpa_supplicant + #systemctl restart wpa_supplicant wpa_cli -i wlan0 reconfigure # <-------- add watch for FAIL response, error out - timeout 30s dhclient -v + #timeout 30s dhclient -v fi diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh old mode 100755 new mode 100644 index 4891e8e..831f797 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -5,6 +5,9 @@ log_message() { } if [ ! -e "/etc/.firstboot" ]; then + + who | grep -q . || exit 1 + # prevents weirdness over tty export NCURSES_NO_UTF8_ACS=1 export TERM=xterm-256color @@ -83,4 +86,4 @@ systemctl restart meshtasticd rm /etc/.firstboot log_message "Removing first boot flag and rebooting in 5 seconds..." sleep 5 -reboot \ No newline at end of file +reboot diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh old mode 100755 new mode 100644 From ba690b2250921b3169ee5c28303cc0b736c5fd24 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 20:17:45 -0800 Subject: [PATCH 11/23] Enable new services Chroot changes to enable new services --- environment-setup/femtofox.chroot | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 6168a8c..cc366b1 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -52,8 +52,10 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." -systemctl enable button +systemctl enable femto-runonce.service +systemctl enable femto-usb-config-tool.service systemctl enable wifi-mesh-control + systemctl disable NetworkManager systemctl disable NetworkManager-dispatcher systemctl disable NetworkManager-wait-online From 1f211d7cf91ba7877ef362486c2054fd0a8084b0 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 21:44:27 -0800 Subject: [PATCH 12/23] Fixed permissions Missed these. --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh | 0 .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 0 .../rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh mode change 100644 => 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh mode change 100644 => 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh old mode 100644 new mode 100755 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh old mode 100644 new mode 100755 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh old mode 100644 new mode 100755 From 27652fecb1de56e1cfd54830c5765ab5fdd2baf4 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 22:38:32 -0800 Subject: [PATCH 13/23] Nicer console output for runonce Switched from tty to journal and console for output. --- .../etc/systemd/system/femto-runonce.service | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service index eb4c075..80e3b7e 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service @@ -9,8 +9,9 @@ DefaultDependencies=no ExecStart=/usr/local/bin/femto-runonce.sh Type=oneshot RemainAfterExit=true -StandardOutput=tty -StandardError=tty +StandardOutput=journal+console +StandardError=journal+console +TTYPath=/dev/console [Install] WantedBy=serial-getty@ttyFIQ0.service From eba5b4c217d8617586b588b94aab80f74dc7190f Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 23:01:31 -0800 Subject: [PATCH 14/23] Should be successful exit Change to successful exit for run once when it has already been run once and on boot screen. --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 831f797..c713aac 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -6,7 +6,7 @@ log_message() { if [ ! -e "/etc/.firstboot" ]; then - who | grep -q . || exit 1 + who | grep -q . || exit 0 # prevents weirdness over tty export NCURSES_NO_UTF8_ACS=1 From 2e8a3f71367f6af143ee1979446a51e40f668a67 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 23:16:12 -0800 Subject: [PATCH 15/23] Do not run usb tool on first boot. Checks for first boot flag and exits gracefully. --- .../usr/local/bin/femto-usb-config-tool.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh index e76f999..587564e 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh @@ -1,4 +1,8 @@ #!/bin/bash + +if [ ! -e "/etc/.firstboot" ]; then + exit 0 + mount_point="/mnt/usb" # Set the mount point # Function to log to screen, syslog and logfile to be saved to usb drive From 83a95e5c69f7ff4c3c18ed3a1974225aac25ef3d Mon Sep 17 00:00:00 2001 From: Ruledo Date: Mon, 20 Jan 2025 00:46:48 -0800 Subject: [PATCH 16/23] run once and usb service fixes I forgot to +x rc local and as a result found some issues --- .../overlay/overlay-luckfox-ubuntu/etc/rc.local | 0 .../etc/systemd/system/femto-runonce.service | 7 +++---- .../etc/systemd/system/femto-usb-config-tool.service | 7 +++---- .../usr/local/bin/femto-usb-config-tool.sh | 9 ++++++++- 4 files changed, 14 insertions(+), 9 deletions(-) mode change 100644 => 100755 foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local diff --git a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local old mode 100644 new mode 100755 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service index 80e3b7e..d5692f4 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service @@ -1,17 +1,16 @@ [Unit] Description=Foxbuntu First Boot After=meshtasticd.service -Requires=meshtasticd.service Before=serial-getty@ttyFIQ0.service DefaultDependencies=no [Service] ExecStart=/usr/local/bin/femto-runonce.sh Type=oneshot -RemainAfterExit=true +Restart=no StandardOutput=journal+console StandardError=journal+console -TTYPath=/dev/console [Install] -WantedBy=serial-getty@ttyFIQ0.service +WantedBy=default.target + diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service index a675c9f..679b722 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service @@ -1,17 +1,16 @@ [Unit] Description=Foxbuntu USB Configuration Tool -After=femto-runonce.service meshtasticd.service +After=meshtasticd.service Before=serial-getty@ttyFIQ0.service DefaultDependencies=no [Service] ExecStart=/usr/local/bin/femto-usb-config-tool.sh Type=oneshot -RemainAfterExit=true +Restart=no StandardOutput=journal+console StandardError=journal+console -TTYPath=/dev/console [Install] -WantedBy=serial-getty@ttyFIQ0.service +WantedBy=default.target diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh index 587564e..2fa8bea 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh @@ -12,6 +12,12 @@ log_message() { echo "$(date +"%Y-%m-%d %H:%M:%S") $1" >> /tmp/femtofox-config.log } +if [ -e "/etc/.firstboot" ]; then + echo "First boot, skipping USB Configuration Tool." + logger "First boot, skipping USB Configuration Tool." + exit 0 +fi + exit_script() { if [ ! -z "$usb_path" ]; then #if usb path is populated if ! df -T /mnt/usb 2>/dev/null | grep -qw 'ntfs'; then @@ -150,7 +156,8 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then if [[ -n "$wifi_psk" ]]; then # Update the psk in the network block wifi_command="$wifi_command -p \"$wifi_psk\"" - log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to \`$wifi_psk\`." + #log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to \`$wifi_psk\`." + log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to *HIDDEN*." found_config="true" update_wifi="true" fi From 71f3ee6b42de8f5e8f3f7ced73c59d7fa8fdeb8d Mon Sep 17 00:00:00 2001 From: Ruledo Date: Mon, 20 Jan 2025 03:00:31 -0800 Subject: [PATCH 17/23] fixed run once check for usb tool Check if run once flag exists, if so exit silently. --- .../usr/local/bin/femto-usb-config-tool.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh index 2fa8bea..18e7d62 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh @@ -1,7 +1,10 @@ #!/bin/bash -if [ ! -e "/etc/.firstboot" ]; then +if [ -e "/etc/.firstboot" ]; then + echo "First boot, skipping USB Configuration Tool." + logger "First boot, skipping USB Configuration Tool." exit 0 +fi mount_point="/mnt/usb" # Set the mount point From 19123a00e5bdf68a8bf705c2bae42b300b605efa Mon Sep 17 00:00:00 2001 From: Ruledo Date: Mon, 20 Jan 2025 04:06:54 -0800 Subject: [PATCH 18/23] put back button service I accidentally removed this earlier. --- environment-setup/femtofox.chroot | 1 + 1 file changed, 1 insertion(+) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index cc366b1..96a5153 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -52,6 +52,7 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." +systemctl enable button systemctl enable femto-runonce.service systemctl enable femto-usb-config-tool.service systemctl enable wifi-mesh-control From 86bdb7157870f00809a9c1cb967e9d6680d1ce5d Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 17:38:35 +0200 Subject: [PATCH 19/23] Finishing touches --- .../usr/local/bin/femto-boot-complete.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh new file mode 100755 index 0000000..2875bc7 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh @@ -0,0 +1,15 @@ +#!/bin/bash +echo "Boot complete" + +echo "Disabling ACT LED..." +echo "none" > /sys/class/leds/work/trigger & +sleep 1 + +# blink successful boot code +for i in $(seq 1 5); do + echo 1 > /sys/class/gpio/gpio34/value; + sleep 0.5; + echo 0 > /sys/class/gpio/gpio34/value; + sleep 0.5; +done +exit 0 \ No newline at end of file From fae26cc1787909d4a57a1d39d240c021c64ed691 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 17:39:19 +0200 Subject: [PATCH 20/23] Move meshtasticd -h argument to service override --- environment-setup/femtofox.chroot | 2 ++ .../overlay-luckfox-ubuntu/etc/rc.local | 26 +++++++++---------- .../system/femto-boot-complete.service | 14 ++++++++++ .../meshtasticd.service.d/override.conf | 3 +++ .../usr/local/bin/femto-runonce.sh | 22 +++++++--------- 5 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 96a5153..e45fae5 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -53,8 +53,10 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." systemctl enable button +systemctl enable meshtasticd systemctl enable femto-runonce.service systemctl enable femto-usb-config-tool.service +systemctl enable femto-boot-complete.service systemctl enable wifi-mesh-control systemctl disable NetworkManager diff --git a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local index 8fb738c..4e7b166 100755 --- a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local +++ b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local @@ -26,18 +26,18 @@ echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction #/usr/local/bin/femto-usb-config-tool.sh # boot complete -( - echo "Disabling ACT LED..." - echo "none" > /sys/class/leds/work/trigger & - sleep 1 - - # blink successful boot code - for i in $(seq 1 5); do - echo 1 > /sys/class/gpio/gpio34/value; - sleep 0.5; - echo 0 > /sys/class/gpio/gpio34/value; - sleep 0.5; - done -) & +#( +# echo "Disabling ACT LED..." +# echo "none" > /sys/class/leds/work/trigger & +# sleep 1 +# +# # blink successful boot code +# for i in $(seq 1 5); do +# echo 1 > /sys/class/gpio/gpio34/value; +# sleep 0.5; +# echo 0 > /sys/class/gpio/gpio34/value; +# sleep 0.5; +# done +#) & exit 0 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service new file mode 100644 index 0000000..ae450b3 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service @@ -0,0 +1,14 @@ +[Unit] +Description=Boot Complete +After=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-boot-complete.sh +Type=oneshot +Restart=no +StandardOutput=journal+console +StandardError=journal+console + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 1d992e3..3ef95db 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,6 +1,9 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +ExecStart= +ExecStart=/bin/sh -c '/usr/sbin/meshtasticd -h $(sed -n "/Serial/ s/^.*: \(.*\)$/\U\1/p" /proc/cpuinfo | bc | tail -c 9)' [Unit] After=rc-local.service Wants=rc-local.service +After=network-online.target \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index c713aac..a62552a 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -14,7 +14,7 @@ if [ ! -e "/etc/.firstboot" ]; then export LANG=C.UTF-8 dialog --title "Femtofox run once utility" --yesno "\ This does not appear to be this system's first boot.\n\ -Re-running this script will restore RTC support, set the Meshtastic nodeid and eth0 MAC address to be derivative of the CPU serial number, set the Meshtastic wifi status to \`enabled\` and then reboot.\n\ +Re-running this script will resize the filesystem to fit the SD card, allocate a swap file, add RTC support, add terminal type to .bashrc, set the eth0 MAC address to be derivative of the CPU serial number and then reboot.\n\ \n\ Re-running this script after first boot should not cause any harm, but may not work as expected.\n\ \n\ @@ -31,13 +31,13 @@ fi sudo resize2fs /dev/mmcblk1p7 # allocate swap file -if [ ! -f /etc/.filesystem_swap ]; then # check if swap file already exists +if [ ! -f /swapfile ]; then # check if swap file already exists sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile > /dev/null sudo swapon /swapfile > /dev/null echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab > /dev/null - touch /etc/.filesystem_swap +# touch /etc/.filesystem_swap # no longer used log_message "Swap file allocated." else log_message "Swap file already allocated, skipping." @@ -64,9 +64,7 @@ fi lines="export NCURSES_NO_UTF8_ACS=1 export TERM=xterm-256color export LANG=C.UTF-8" - -# Check if the lines are already in .bashrc -if ! grep -Fxq "$lines" /home/femto/.bashrc; then +if ! grep -Fxq "$lines" /home/femto/.bashrc; then # Check if the lines are already in .bashrc echo "$lines" >> /home/femto/.bashrc echo "Added TERM, LANG and NCURSES_NO_UTF8_ACS to .bashrc" else @@ -74,13 +72,13 @@ else fi # set meshtastic nodeid to derivative of CPU serial number (unique to this board) -seed=$(sed -n '/Serial/ s/^.*: \(.*\)$/\U\1/p' /proc/cpuinfo | bc | tail -c 9) +#seed=$(sed -n '/Serial/ s/^.*: \(.*\)$/\U\1/p' /proc/cpuinfo | bc | tail -c 9) #seed=$((0x$(awk '/Serial/ {print $3}' /proc/cpuinfo) & 0x3B9AC9FF)) #alternate method for generating seed - not in use -sed -i "s|^ExecStart=/usr/sbin/meshtasticd.*|ExecStart=/usr/sbin/meshtasticd -h $seed|" /usr/lib/systemd/system/meshtasticd.service -log_message "Using Luckfox CPU S/N to generate nodeid for Meshtastic." -systemctl daemon-reload -systemctl enable meshtasticd -systemctl restart meshtasticd +#sed -i "s|^ExecStart=/usr/sbin/meshtasticd.*|ExecStart=/usr/sbin/meshtasticd -h $seed|" /usr/lib/systemd/system/meshtasticd.service +#log_message "Using Luckfox CPU S/N to generate nodeid for Meshtastic." +#systemctl daemon-reload +#systemctl enable meshtasticd +#systemctl restart meshtasticd # remove first boot flag rm /etc/.firstboot From 73150d882fb634c0d9e1935d7b2d9db22d7e8de2 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 18:32:15 +0200 Subject: [PATCH 21/23] Reorder lines in meshtasticd service override --- .../etc/systemd/system/meshtasticd.service.d/override.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 3ef95db..0108eaf 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,9 +1,9 @@ [Service] -ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' ExecStart= ExecStart=/bin/sh -c '/usr/sbin/meshtasticd -h $(sed -n "/Serial/ s/^.*: \(.*\)$/\U\1/p" /proc/cpuinfo | bc | tail -c 9)' +ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' [Unit] After=rc-local.service Wants=rc-local.service -After=network-online.target \ No newline at end of file +After=network-online.target From c27760d4ec3a2ee14408c0c04b0b983d2a9ef391 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 22:50:39 +0200 Subject: [PATCH 22/23] Disable LED to prevent boot codes from showing during first boot --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index a62552a..2d78e45 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -24,6 +24,9 @@ Proceed?" 14 60 fi fi +# Disable LED to prevent boot codes from showing during this boot +echo 34 > /sys/class/gpio/unexport + # Perform filesystem resize log_message "Resizing filesystem. This can take up to 10 minutes, depending on microSD card size and speed" sudo resize2fs /dev/mmcblk1p5 From ce7b9607af1272d5a1e820e005d526b5235ffad1 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 23:03:03 +0200 Subject: [PATCH 23/23] Improve process priority setting for meshtasticd service override --- .../etc/systemd/system/meshtasticd.service.d/override.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 0108eaf..4016f36 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,7 +1,7 @@ [Service] ExecStart= ExecStart=/bin/sh -c '/usr/sbin/meshtasticd -h $(sed -n "/Serial/ s/^.*: \(.*\)$/\U\1/p" /proc/cpuinfo | bc | tail -c 9)' -ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +Nice=-20 [Unit] After=rc-local.service