From 14e6c36c7bc7a0aead46363928476f87309a61ef Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 19:09:53 -0800 Subject: [PATCH 01/15] 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 02/15] 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 03/15] 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 04/15] 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 05/15] 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 06/15] 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 07/15] 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 08/15] 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 09/15] 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 10/15] 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 11/15] 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 12/15] 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 13/15] 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 14/15] 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 15/15] 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