From cc583404da90932b76da8e207578bee1c5982247 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Mon, 6 Jan 2025 10:44:08 +0000 Subject: [PATCH 01/31] README.md updated from https://stackedit.io/ --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 561370c..da19c8e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The Luckfox Pico Mini is the postage stamp sized heart of the Femtofox - a compa - How to order - coming soon - DIY instructions - coming soon - [Networking](#networking) -- [USB configuration tool](usbconfig.md) +- [USB configuration tool](usb_config.md) ### Features * Tiny size (63x54mm for the Kitchen Sink Edition, 65x30mm for the Smol Edition). Roughly equivalent to a Raspberry Pi and Pi Zero. @@ -77,3 +77,6 @@ In Meshtasticd's config.yaml we use GPIO bank 1, and subtract 32 from the pin nu > [!NOTE] > The information on this page is given without warranty or guarantee. Links to vendors of products are for informational purposes only. > Meshtastic® is a registered trademark of Meshtastic LLC. Meshtastic software components are released under various licenses, see GitHub for details. No warranty is provided - use at your own risk. + \ No newline at end of file From 10e4c116f7ee0d64014403304d374f1d3d363b4c Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:00:56 +0000 Subject: [PATCH 02/31] Update femto-usb-config-tool.sh Added a check for `dont_run_config_if_log_exists` --- .../usr/local/bin/femto-usb-config-tool.sh | 15 +++++++++++++++ 1 file changed, 15 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 3ef0524..d2803e5 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 @@ -71,6 +71,12 @@ fi wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" usb_config="/tmp/femtofox-config.txt" + # Check if the mounted USB drive contains a file femtofox-config.log +if [ -f "$mount_point/femtofox-config.log" ]; then + log_message "femtofox-config.log found on USB drive." + log_exists=true +fi + # Check if the mounted USB drive contains a file femtofox-config.txt if [ -f "$mount_point/femtofox-config.txt" ]; then log_message "femtofox-config.txt found on USB drive." @@ -88,6 +94,15 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then wifi_command="femto-network-config.sh" meshtastic_security_command="femto-meshtasticd-config.sh" + # Check if the log exits and if the dont_run_config_if_log_exists line is set in the script + if [[ log_exists && -n "$dont_run_config_if_log_exists" ]]; then + log_message "log exists and script is set to exit" + for _ in {1..5}; do #boot code + blink "1.5" && sleep 0.5 + done + exit_script 0 + fi + # Escape and read the fields from the USB config file if they exist while IFS='=' read -r key value; do value=$(echo "$value" | tr -d '"') From b0e34b98402ae3eca42a0cb94e408379d1237d46 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:30:39 +0200 Subject: [PATCH 03/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/usb_config.md b/usb_config.md index 6b37c0b..5b2f5ab 100644 --- a/usb_config.md +++ b/usb_config.md @@ -65,7 +65,10 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in |--|--|--|--| |
⚠️
________________
1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | +| +
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | +| +
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | |
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 seconds, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| |
    ✅
    . . . . . . . . . .
    10 very fast blinks, each lasting 1/8th of a second | USB drive mounted successfully, and femtofox-config.txt was found and contained configuration data which was sent for deployment. Any affected services will now restart. You can disconnect the USB drive. | This does not mean that the information in the config file is correct - only that it was readable.
    Note that the "success" boot code will flash if at least one setting is successfully read - even if the setting was not implemented successfully.| |
    ✅
    \_\_  \_\_  \_\_  \_\_  \_\_
    5 medium blinks, each lasting 0.5 seconds | Boot complete. Appears on every successful boot and always appears last.| | | @@ -73,5 +76,5 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From 6fc853ec3e5a2602af6f8213faec8f21bf57259e Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:32:13 +0200 Subject: [PATCH 04/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/usb_config.md b/usb_config.md index 5b2f5ab..c5696c2 100644 --- a/usb_config.md +++ b/usb_config.md @@ -64,11 +64,9 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in | LED blink pattern | Meaning | Possible causes | Solutions | |--|--|--|--| |
    ⚠️
    ________________
    1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | -| -
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | -| -
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | |
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 seconds, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| |
    ✅
    . . . . . . . . . .
    10 very fast blinks, each lasting 1/8th of a second | USB drive mounted successfully, and femtofox-config.txt was found and contained configuration data which was sent for deployment. Any affected services will now restart. You can disconnect the USB drive. | This does not mean that the information in the config file is correct - only that it was readable.
    Note that the "success" boot code will flash if at least one setting is successfully read - even if the setting was not implemented successfully.| |
    ✅
    \_\_  \_\_  \_\_  \_\_  \_\_
    5 medium blinks, each lasting 0.5 seconds | Boot complete. Appears on every successful boot and always appears last.| | | @@ -76,5 +74,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From a97ebdfc181bb32827bb33dd778c2eb6bf468073 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:33:47 +0200 Subject: [PATCH 05/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usb_config.md b/usb_config.md index c5696c2..5b1705b 100644 --- a/usb_config.md +++ b/usb_config.md @@ -64,16 +64,16 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in | LED blink pattern | Meaning | Possible causes | Solutions | |--|--|--|--| |
    ⚠️
    ________________
    1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains the `dont_run_config_if_log_exists` line and a log is present on the USB drive... Ignoring.| Config file missing. | Create configuration file as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | -|
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 seconds, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| +|
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 second, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| |
    ✅
    . . . . . . . . . .
    10 very fast blinks, each lasting 1/8th of a second | USB drive mounted successfully, and femtofox-config.txt was found and contained configuration data which was sent for deployment. Any affected services will now restart. You can disconnect the USB drive. | This does not mean that the information in the config file is correct - only that it was readable.
    Note that the "success" boot code will flash if at least one setting is successfully read - even if the setting was not implemented successfully.| |
    ✅
    \_\_  \_\_  \_\_  \_\_  \_\_
    5 medium blinks, each lasting 0.5 seconds | Boot complete. Appears on every successful boot and always appears last.| | | > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From cb779c57f1fee78975ccd2128d2c5f6693c2889f Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:35:21 +0200 Subject: [PATCH 06/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index 5b1705b..4c088c2 100644 --- a/usb_config.md +++ b/usb_config.md @@ -64,7 +64,7 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in | LED blink pattern | Meaning | Possible causes | Solutions | |--|--|--|--| |
    ⚠️
    ________________
    1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains the `dont_run_config_if_log_exists` line and a log is present on the USB drive... Ignoring.| Config file missing. | Create configuration file as described above. | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains the `dont_run_config_if_log_exists` line and a log is present on the USB drive. Ignoring.| Misconfiguration. | Remove log from USB drive or remove `dont_run_config_if_log_exists` line from femtofox-config.txt | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | |
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 second, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| @@ -74,6 +74,5 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From 830ddffbf8ff91e6fbce154af0ee687719ca153c Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:36:31 +0200 Subject: [PATCH 07/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usb_config.md b/usb_config.md index 4c088c2..d8de72a 100644 --- a/usb_config.md +++ b/usb_config.md @@ -27,6 +27,7 @@ meshtastic_lora_radio="ebyte-e22-900m30s" meshtastic_url="https://meshtastic.org/e/#CgMSAQESCAgBOAFAA0gB" meshtastic_admin_key="T/b8EGvi/Nqi6GyGefJt/jOQr+5uWHHZuBavkNcUwWQ=" meshtastic_legacy_admin="true" +dont_run_if_log_exists ``` > [!NOTE] > Enter as many or as few settings as you like. @@ -74,5 +75,5 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From eb6bb3c37af44fdac7117d6a883d562ccba32f04 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Mon, 6 Jan 2025 16:38:46 +0000 Subject: [PATCH 08/31] Update femto-usb-config-tool.sh --- .../usr/local/bin/femto-usb-config-tool.sh | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) 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 d2803e5..7fe9b4d 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 @@ -93,16 +93,8 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then update_wifi="false" wifi_command="femto-network-config.sh" meshtastic_security_command="femto-meshtasticd-config.sh" - - # Check if the log exits and if the dont_run_config_if_log_exists line is set in the script - if [[ log_exists && -n "$dont_run_config_if_log_exists" ]]; then - log_message "log exists and script is set to exit" - for _ in {1..5}; do #boot code - blink "1.5" && sleep 0.5 - done - exit_script 0 - fi - + dont_run_config_if_log_exists="false" + # Escape and read the fields from the USB config file if they exist while IFS='=' read -r key value; do value=$(echo "$value" | tr -d '"') @@ -115,9 +107,18 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then meshtastic_url) meshtastic_url=$(escape_sed "$value") ;; meshtastic_legacy_admin) meshtastic_legacy_admin=$(escape_sed "$value") ;; meshtastic_admin_key) meshtastic_admin_key=$(escape_sed "$value") ;; + dont_run_config_if_log_exists) dont_run_config_if_log_exists=$(escape_sed "$value") ;; esac done < <(grep -E '^(wifi_ssid|wifi_psk|wifi_country|meshtastic_lora_radio|timezone|meshtastic_url|meshtastic_legacy_admin|meshtastic_admin_key)=' "$usb_config") + # Check if the log exits and if the dont_run_config_if_log_exists line is set in the script + if [[ $log_exists="true" && $dont_run_config_if_log_exists="true" ]]; then + log_message "log exists and script is set to exit" + for _ in {1..5}; do #boot code + blink "1.5" && sleep 0.5 + done + exit_script 1 + fi # Update wpa_supplicant.conf with the new values, if specified if [[ -n "$wifi_country" ]]; then From d92ac547c32f48d9c347711f0884d23f93054ee4 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:43:35 +0200 Subject: [PATCH 09/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usb_config.md b/usb_config.md index d8de72a..ebd5c97 100644 --- a/usb_config.md +++ b/usb_config.md @@ -56,6 +56,9 @@ dont_run_if_log_exists > [!CAUTION] > Attempting to set wifi settings via USB configuration tool without a wifi adapter connected will lead to a 5 minute hang while the configuration tool runs - either disconnect and reconnect power or wait the full 5 minutes to to recover. +> [!NOTE] +> `dont_run_if_log_exists` will prevent the USB configuration tool from working if there's a log present on the USB drive, indicating it has already been run. There is also an LED boot code for this, descri + **To apply your configuration, reboot the Femtofox with the USB drive plugged in. No other USB drives can be plugged in at the same time.** A log (`femtofox-config.log`) is saved to `/home/femto` and the USB drive (except on NTFS, which is read only).
    @@ -75,5 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From f1e4f82d52aed221e338b28aee1e883f6cbe873d Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Mon, 6 Jan 2025 18:43:45 +0200 Subject: [PATCH 10/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index ebd5c97..5da6e92 100644 --- a/usb_config.md +++ b/usb_config.md @@ -57,7 +57,7 @@ dont_run_if_log_exists > Attempting to set wifi settings via USB configuration tool without a wifi adapter connected will lead to a 5 minute hang while the configuration tool runs - either disconnect and reconnect power or wait the full 5 minutes to to recover. > [!NOTE] -> `dont_run_if_log_exists` will prevent the USB configuration tool from working if there's a log present on the USB drive, indicating it has already been run. There is also an LED boot code for this, descri +> `dont_run_if_log_exists` will prevent the USB configuration tool from working if there's a log present on the USB drive, indicating it has already been run. There is also an LED boot code for this, described below. **To apply your configuration, reboot the Femtofox with the USB drive plugged in. No other USB drives can be plugged in at the same time.** A log (`femtofox-config.log`) is saved to `/home/femto` and the USB drive (except on NTFS, which is read only). @@ -78,6 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From dd9277c55d9c438496c1f85d4adf295a3f9eafa0 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:21:53 +0000 Subject: [PATCH 11/31] Update femto-usb-config-tool.sh --- .../usr/local/bin/femto-usb-config-tool.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 7fe9b4d..dbfb096 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 @@ -75,6 +75,8 @@ usb_config="/tmp/femtofox-config.txt" if [ -f "$mount_point/femtofox-config.log" ]; then log_message "femtofox-config.log found on USB drive." log_exists=true +else + log_exists=false fi # Check if the mounted USB drive contains a file femtofox-config.txt @@ -109,12 +111,12 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then meshtastic_admin_key) meshtastic_admin_key=$(escape_sed "$value") ;; dont_run_config_if_log_exists) dont_run_config_if_log_exists=$(escape_sed "$value") ;; esac - done < <(grep -E '^(wifi_ssid|wifi_psk|wifi_country|meshtastic_lora_radio|timezone|meshtastic_url|meshtastic_legacy_admin|meshtastic_admin_key)=' "$usb_config") + done < <(grep -E '^(wifi_ssid|wifi_psk|wifi_country|meshtastic_lora_radio|timezone|meshtastic_url|meshtastic_legacy_admin|meshtastic_admin_key|dont_run_if_log_exists)=' "$usb_config") - # Check if the log exits and if the dont_run_config_if_log_exists line is set in the script - if [[ $log_exists="true" && $dont_run_config_if_log_exists="true" ]]; then + # Check if the log exits and if the dont_run_if_log_exists line is set in the script + if $log_exists && [[ $dont_run_if_log_exists="true" ]]; then log_message "log exists and script is set to exit" - for _ in {1..5}; do #boot code + for _ in {1..2}; do #boot code blink "1.5" && sleep 0.5 done exit_script 1 From da0b5e59c271a7dadab3b32dd65259b87cfb7c26 Mon Sep 17 00:00:00 2001 From: joshbowyer <37744796+joshbowyer@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:29:01 -0600 Subject: [PATCH 12/31] Update wifi-mesh-control.sh encapsulated variables, also added grep for wifi line only to meshtastic command --- .../usr/local/bin/wifi-mesh-control.sh | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 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 e39c8ba..4bd67d8 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 @@ -5,29 +5,29 @@ WIFI_STATE_FILE="/etc/wifi_state.txt" PROTO_FILE="/root/.portduino/default/prefs/config.proto" log() { - echo "$(date) - $1" | tee -a "$LOG_FILE" + echo "$(date) - ${1}" | tee -a "${LOG_FILE}" } get_mobile_wifi_state() { local proto_output - proto_output=$(cat "$PROTO_FILE" | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}') - [[ "$proto_output" == "1" ]] && echo "up" || echo "down" + proto_output=$(cat "${PROTO_FILE}" | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}') + [[ "${proto_output}" == "1" ]] && echo "up" || echo "down" } set_mobile_wifi_state() { - local state="$1" + local state="${1}" local meshtastic_output - if [[ "$state" == "up" ]]; then - meshtastic_output=$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1) + if [[ "${state}" == "up" ]]; then + meshtastic_output="$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1 | grep -i wifi)" else - meshtastic_output=$(meshtastic --host 127.0.0.1 --set network.wifi_enabled false 2>&1) + meshtastic_output="$(meshtastic --host 127.0.0.1 --set network.wifi_enabled false 2>&1 | grep -i wifi)" fi - log "Set Meshtastic Wi-Fi state to $state. Output: $meshtastic_output" + log "Set Meshtastic Wi-Fi state to ${state}. Output: ${meshtastic_output}" } set_wlan_state() { - local state="$1" - if [[ "$state" == "up" ]]; then + local state="${1}" + if [[ "${state}" == "up" ]]; then ip link set wlan0 up && log "Set wlan0 UP." else ip link set wlan0 down && log "Set wlan0 DOWN." @@ -36,27 +36,27 @@ set_wlan_state() { validate_wifi_state_file() { local state - state=$(cat "$WIFI_STATE_FILE" 2>/dev/null) - if [[ "$state" != "up" && "$state" != "down" ]]; then - echo "up" > "$WIFI_STATE_FILE" + state=$(cat "${WIFI_STATE_FILE}" 2>/dev/null) + if [[ "${state}" != "up" && "${state}" != "down" ]]; then + echo "up" > "${WIFI_STATE_FILE}" log "Invalid wifi_state.txt content. Defaulting to up." fi } sync_states() { local text_state mobile_state - text_state=$(cat "$WIFI_STATE_FILE") + text_state=$(cat "${WIFI_STATE_FILE}") mobile_state=$(get_mobile_wifi_state) - if [[ "$text_state" != "$mobile_state" ]]; then - set_mobile_wifi_state "$text_state" - log "Synced mobile Wi-Fi state to $text_state." + if [[ "${text_state}" != "${mobile_state}" ]]; then + set_mobile_wifi_state "${text_state}" + 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") - if [[ "$text_state" != "$current_wlan_state" ]]; then - set_wlan_state "$text_state" - log "Synced wlan0 state to $text_state." + if [[ "${text_state}" != "${current_wlan_state}" ]]; then + set_wlan_state "${text_state}" + log "Synced wlan0 state to ${text_state}." fi } @@ -70,18 +70,18 @@ monitor_changes() { current_mobile_state=$(get_mobile_wifi_state) current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") - if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then - log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" - echo "$current_mobile_state" > "$WIFI_STATE_FILE" - set_wlan_state "$current_mobile_state" - previous_mobile_state="$current_mobile_state" + if [[ "${current_mobile_state}" != "${previous_mobile_state}" ]]; then + log "Detected mobile Wi-Fi state change: ${previous_mobile_state} -> ${current_mobile_state}" + echo "${current_mobile_state}" > "${WIFI_STATE_FILE}" + set_wlan_state "${current_mobile_state}" + previous_mobile_state="${current_mobile_state}" fi - if [[ "$current_wlan_state" != "$previous_wlan_state" ]]; then - log "Detected wlan0 state change: $previous_wlan_state -> $current_wlan_state" - echo "$current_wlan_state" > "$WIFI_STATE_FILE" - set_mobile_wifi_state "$current_wlan_state" - previous_wlan_state="$current_wlan_state" + if [[ "${current_wlan_state}" != "${previous_wlan_state}" ]]; then + log "Detected wlan0 state change: ${previous_wlan_state} -> ${current_wlan_state}" + echo "${current_wlan_state}" > "${WIFI_STATE_FILE}" + set_mobile_wifi_state "${current_wlan_state}" + previous_wlan_state="${current_wlan_state}" fi sleep 5 @@ -92,4 +92,3 @@ monitor_changes() { validate_wifi_state_file sync_states monitor_changes - From 19ae8f636be24999f79849307f5bdd15d5197906 Mon Sep 17 00:00:00 2001 From: joshbowyer <37744796+joshbowyer@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:35:37 -0600 Subject: [PATCH 13/31] Update wifi-mesh-control.sh Added error handling --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 4 ++++ 1 file changed, 4 insertions(+) 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 4bd67d8..6d0e1ce 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 @@ -17,6 +17,10 @@ get_mobile_wifi_state() { set_mobile_wifi_state() { local state="${1}" local meshtastic_output + if [[ "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled 2>&1 | grep -i refused)" ]] || [[ ! "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled)" ]]; then + log "Error connecting to MeshtasticD. Aborting." + exit 2 + fi if [[ "${state}" == "up" ]]; then meshtastic_output="$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1 | grep -i wifi)" else From 7db4596fde62b321ec2955625320c737b310ba54 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:02:23 +0000 Subject: [PATCH 14/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index 5da6e92..579f86f 100644 --- a/usb_config.md +++ b/usb_config.md @@ -32,7 +32,7 @@ dont_run_if_log_exists > [!NOTE] > Enter as many or as few settings as you like. > -> For `wifi_country`, insert your country's two letter code (such as US or IN) in capital letters. +> For `wifi_country`, insert your country's ISO/IEC alpha2 two letter country code (such as US, GB, DE, IN, etc.) in capital letters. > > Use a timezone as it appears in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). > @@ -78,6 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From f72d7fd500e481f075a57f6be04ab124b23d7de9 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:03:55 +0000 Subject: [PATCH 15/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usb_config.md b/usb_config.md index 579f86f..3938482 100644 --- a/usb_config.md +++ b/usb_config.md @@ -32,7 +32,7 @@ dont_run_if_log_exists > [!NOTE] > Enter as many or as few settings as you like. > -> For `wifi_country`, insert your country's ISO/IEC alpha2 two letter country code (such as US, GB, DE, IN, etc.) in capital letters. +> For `wifi_country`, insert your country's [ISO/IEC alpha2 two letter country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) (such as US, GB, DE, IN, etc.) in capital letters. > > Use a timezone as it appears in [the tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). > @@ -78,6 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From fe45a9485042ed029d594cabe7fd91ab6aad90a7 Mon Sep 17 00:00:00 2001 From: Tom <116762865+Nestpebble@users.noreply.github.com> Date: Wed, 8 Jan 2025 01:27:02 +0000 Subject: [PATCH 16/31] Update femto-usb-config-tool.sh --- .../usr/local/bin/femto-usb-config-tool.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 dbfb096..f7ee418 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 @@ -95,10 +95,14 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then update_wifi="false" wifi_command="femto-network-config.sh" meshtastic_security_command="femto-meshtasticd-config.sh" - dont_run_config_if_log_exists="false" + dont_run_if_log_exists="" # Escape and read the fields from the USB config file if they exist while IFS='=' read -r key value; do + # Skip lines starting with # + if [[ "$key" =~ ^# ]]; then + continue + fi value=$(echo "$value" | tr -d '"') case "$key" in wifi_ssid) wifi_ssid=$(escape_sed "$value") ;; @@ -109,12 +113,12 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then meshtastic_url) meshtastic_url=$(escape_sed "$value") ;; meshtastic_legacy_admin) meshtastic_legacy_admin=$(escape_sed "$value") ;; meshtastic_admin_key) meshtastic_admin_key=$(escape_sed "$value") ;; - dont_run_config_if_log_exists) dont_run_config_if_log_exists=$(escape_sed "$value") ;; + dont_run_if_log_exists) dont_run_if_log_exists=$(escape_sed "$value") ;; esac done < <(grep -E '^(wifi_ssid|wifi_psk|wifi_country|meshtastic_lora_radio|timezone|meshtastic_url|meshtastic_legacy_admin|meshtastic_admin_key|dont_run_if_log_exists)=' "$usb_config") # Check if the log exits and if the dont_run_if_log_exists line is set in the script - if $log_exists && [[ $dont_run_if_log_exists="true" ]]; then + if $log_exists && [[ $dont_run_if_log_exists = "true" ]]; then log_message "log exists and script is set to exit" for _ in {1..2}; do #boot code blink "1.5" && sleep 0.5 From cba28a8eb7bc2c6d060af79734012147dd2d8b8d Mon Sep 17 00:00:00 2001 From: Ruledo Date: Tue, 7 Jan 2025 22:27:04 -0800 Subject: [PATCH 17/31] Image Builder Fix and Chroot Changes Fix for Image Update not including env changes. Added python-is-python3 python3.10-venv to aid in python development. Added software-properties-common so we can take advantage of the new Meshtastic PPA. --- environment-setup/femtofox.chroot | 4 ++-- environment-setup/foxbuntu-builder.sh | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index b231965..6dfd6d3 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -27,7 +27,7 @@ ln -sf /usr/share/zoneinfo/UTC /etc/localtime echo "Installing packages..." apt update -DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode +DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi DEBIAN_FRONTEND=noninteractive apt upgrade -y --option Dpkg::Options::="--force-confold" @@ -93,4 +93,4 @@ usermod -a -G dialout femto echo "Cleaning up chroot..." apt clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && rm -rf /var/tmp/* && find /var/log -type f -exec truncate -s 0 {} + && : > /root/.bash_history && history -c -exit \ No newline at end of file +exit diff --git a/environment-setup/foxbuntu-builder.sh b/environment-setup/foxbuntu-builder.sh index fe00573..5f9d0dd 100644 --- a/environment-setup/foxbuntu-builder.sh +++ b/environment-setup/foxbuntu-builder.sh @@ -227,10 +227,11 @@ inject_chroot() { build_rootfs build_firmware create_image + } - update_image() { + build_env echo "Updating repo..." cd /home/${sudoer}/femtofox git pull From 222180fcba71ee7c4687e94f4604c09a7114d65e Mon Sep 17 00:00:00 2001 From: Ruledo Date: Tue, 7 Jan 2025 23:19:53 -0800 Subject: [PATCH 18/31] Added an error handler from Josh. Checks to make sure meshtastic is running and responsive. --- .../rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh | 6 ++++++ 1 file changed, 6 insertions(+) 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 e39c8ba..4ef054b 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 @@ -17,6 +17,12 @@ get_mobile_wifi_state() { set_mobile_wifi_state() { local state="$1" local meshtastic_output + + if [[ "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled 2>&1 | grep -i refused)" ]] || [[ ! "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled)" ]]; then + log "Error connecting to MeshtasticD. Aborting." + exit 2 + fi + if [[ "$state" == "up" ]]; then meshtastic_output=$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1) else From caca167b3783a45e9249454bc696d4bb50182cbd Mon Sep 17 00:00:00 2001 From: Ruledo Date: Tue, 7 Jan 2025 23:22:35 -0800 Subject: [PATCH 19/31] File had errors. Reverted but with 1 added error check. The last commit had multiple errors. Reverted but used Josh's error handler to check if meshtastic is running and responsive. --- .../usr/local/bin/wifi-mesh-control.sh | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 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 6d0e1ce..4ef054b 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 @@ -5,33 +5,35 @@ WIFI_STATE_FILE="/etc/wifi_state.txt" PROTO_FILE="/root/.portduino/default/prefs/config.proto" log() { - echo "$(date) - ${1}" | tee -a "${LOG_FILE}" + echo "$(date) - $1" | tee -a "$LOG_FILE" } get_mobile_wifi_state() { local proto_output - proto_output=$(cat "${PROTO_FILE}" | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}') - [[ "${proto_output}" == "1" ]] && echo "up" || echo "down" + proto_output=$(cat "$PROTO_FILE" | protoc --decode_raw | awk '/4 {/, /}/ {if ($1 == "1:") print $2}') + [[ "$proto_output" == "1" ]] && echo "up" || echo "down" } set_mobile_wifi_state() { - local state="${1}" + local state="$1" local meshtastic_output + if [[ "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled 2>&1 | grep -i refused)" ]] || [[ ! "$(meshtastic --host 127.0.0.1 --get network.wifi_enabled)" ]]; then log "Error connecting to MeshtasticD. Aborting." exit 2 fi - if [[ "${state}" == "up" ]]; then - meshtastic_output="$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1 | grep -i wifi)" + + if [[ "$state" == "up" ]]; then + meshtastic_output=$(meshtastic --host 127.0.0.1 --set network.wifi_enabled true 2>&1) else - meshtastic_output="$(meshtastic --host 127.0.0.1 --set network.wifi_enabled false 2>&1 | grep -i wifi)" + meshtastic_output=$(meshtastic --host 127.0.0.1 --set network.wifi_enabled false 2>&1) fi - log "Set Meshtastic Wi-Fi state to ${state}. Output: ${meshtastic_output}" + log "Set Meshtastic Wi-Fi state to $state. Output: $meshtastic_output" } set_wlan_state() { - local state="${1}" - if [[ "${state}" == "up" ]]; then + local state="$1" + if [[ "$state" == "up" ]]; then ip link set wlan0 up && log "Set wlan0 UP." else ip link set wlan0 down && log "Set wlan0 DOWN." @@ -40,27 +42,27 @@ set_wlan_state() { validate_wifi_state_file() { local state - state=$(cat "${WIFI_STATE_FILE}" 2>/dev/null) - if [[ "${state}" != "up" && "${state}" != "down" ]]; then - echo "up" > "${WIFI_STATE_FILE}" + state=$(cat "$WIFI_STATE_FILE" 2>/dev/null) + if [[ "$state" != "up" && "$state" != "down" ]]; then + echo "up" > "$WIFI_STATE_FILE" log "Invalid wifi_state.txt content. Defaulting to up." fi } sync_states() { local text_state mobile_state - text_state=$(cat "${WIFI_STATE_FILE}") + text_state=$(cat "$WIFI_STATE_FILE") mobile_state=$(get_mobile_wifi_state) - if [[ "${text_state}" != "${mobile_state}" ]]; then - set_mobile_wifi_state "${text_state}" - log "Synced mobile Wi-Fi state to ${text_state}." + if [[ "$text_state" != "$mobile_state" ]]; then + set_mobile_wifi_state "$text_state" + 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") - if [[ "${text_state}" != "${current_wlan_state}" ]]; then - set_wlan_state "${text_state}" - log "Synced wlan0 state to ${text_state}." + if [[ "$text_state" != "$current_wlan_state" ]]; then + set_wlan_state "$text_state" + log "Synced wlan0 state to $text_state." fi } @@ -74,18 +76,18 @@ monitor_changes() { current_mobile_state=$(get_mobile_wifi_state) current_wlan_state=$(ip link show wlan0 | grep -q 'state UP' && echo "up" || echo "down") - if [[ "${current_mobile_state}" != "${previous_mobile_state}" ]]; then - log "Detected mobile Wi-Fi state change: ${previous_mobile_state} -> ${current_mobile_state}" - echo "${current_mobile_state}" > "${WIFI_STATE_FILE}" - set_wlan_state "${current_mobile_state}" - previous_mobile_state="${current_mobile_state}" + if [[ "$current_mobile_state" != "$previous_mobile_state" ]]; then + log "Detected mobile Wi-Fi state change: $previous_mobile_state -> $current_mobile_state" + echo "$current_mobile_state" > "$WIFI_STATE_FILE" + set_wlan_state "$current_mobile_state" + previous_mobile_state="$current_mobile_state" fi - if [[ "${current_wlan_state}" != "${previous_wlan_state}" ]]; then - log "Detected wlan0 state change: ${previous_wlan_state} -> ${current_wlan_state}" - echo "${current_wlan_state}" > "${WIFI_STATE_FILE}" - set_mobile_wifi_state "${current_wlan_state}" - previous_wlan_state="${current_wlan_state}" + if [[ "$current_wlan_state" != "$previous_wlan_state" ]]; then + log "Detected wlan0 state change: $previous_wlan_state -> $current_wlan_state" + echo "$current_wlan_state" > "$WIFI_STATE_FILE" + set_mobile_wifi_state "$current_wlan_state" + previous_wlan_state="$current_wlan_state" fi sleep 5 @@ -96,3 +98,4 @@ monitor_changes() { validate_wifi_state_file sync_states monitor_changes + From ab506dc14a396605108c0fb47ca9fdfe5eeae3f0 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Wed, 8 Jan 2025 01:03:50 -0800 Subject: [PATCH 20/31] Fixed --chroot-script arg --chroot-script arg didn't work. It's fixed now. Also included but left commented out piwheel in my search to defeat the wheel of pain. --- environment-setup/femtofox.chroot | 2 +- environment-setup/foxbuntu-builder.sh | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 6dfd6d3..8341963 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -37,7 +37,7 @@ DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force- echo "Installing dependencies for meshing-around and meshtastic cli..." - +#pip config set global.extra-index-url https://www.piwheels.org/simple pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi diff --git a/environment-setup/foxbuntu-builder.sh b/environment-setup/foxbuntu-builder.sh index 5f9d0dd..e60f002 100644 --- a/environment-setup/foxbuntu-builder.sh +++ b/environment-setup/foxbuntu-builder.sh @@ -349,13 +349,23 @@ usage() { echo "To install the development environment use the arg 'sdk_install' and is intended to be run ONCE only." echo "To modify the chroot and build an updated image use the arg 'modify_chroot'." echo "To modify the kernel and build an updated image use the arg 'modify_kernel'." + echo "To specify a custom chroot script use the arg '--chroot-script /full/path/to/custom.chroot'" echo "other args: build_env sync_foxbuntu_changes build_kernelconfig install_rootfs build_rootfs build_uboot build_firmware create_image" echo "Example: sudo ~/foxbunto_env_setup.sh sdk_install" echo "Example: sudo ~/foxbunto_env_setup.sh modify_chroot" + echo "Example: sudo ~/foxbunto_env_setup.sh --chroot-script /home/user/custom.chroot" exit 0 } ################### MENU SYSTEM ################### +if [[ "${1}" == "--chroot-script" ]]; then + CHROOT_SCRIPT=${2} + echo "CHROOT_SCRIPT is set to '${CHROOT_SCRIPT}'" + echo "Press any key to continue..." + read -n 1 -s -r + shift 2 # Remove --chroot-script and its argument from the arguments list +fi + if [[ "${1}" =~ ^(-h|--help|h|help)$ ]]; then usage elif [[ -z ${1} ]]; then @@ -405,9 +415,6 @@ elif [[ -z ${1} ]]; then read -n 1 -s -r done else - if [[ "${1}" == "--chroot-script" ]]; then - CHROOT_SCRIPT=${2} - fi if declare -f "${1}" > /dev/null; then "${1}" else From 13d1e6fc41ae74058260f7b8634ccac4e80e8ef7 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:58:31 +0200 Subject: [PATCH 21/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index 3938482..a02cad3 100644 --- a/usb_config.md +++ b/usb_config.md @@ -68,7 +68,7 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in | LED blink pattern | Meaning | Possible causes | Solutions | |--|--|--|--| |
    ⚠️
    ________________
    1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains the `dont_run_config_if_log_exists` line and a log is present on the USB drive. Ignoring.| Misconfiguration. | Remove log from USB drive or remove `dont_run_config_if_log_exists` line from femtofox-config.txt | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains `dont_run_if_log_exists="true"` and a log is present on the USB drive. Ignoring.| Misconfiguration. | Remove log from USB drive or remove `dont_run_if_log_exists` line from femtofox-config.txt | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | |
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 second, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| @@ -78,6 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From f8c70fbdf6cf80f689f73962eb07e87f81482e4f Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:00:05 +0200 Subject: [PATCH 22/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index a02cad3..f212389 100644 --- a/usb_config.md +++ b/usb_config.md @@ -68,7 +68,7 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in | LED blink pattern | Meaning | Possible causes | Solutions | |--|--|--|--| |
    ⚠️
    ________________
    1 very long blink, lasting 5 seconds| Failed to mount USB drive. Ignoring.|
  • Invalid filesystem
  • Corrupted partition table
  • Defective USB drive
  • Defective USB OTG adapter |
  • Use a supported partition (FAT32, exFAT, NTFS, ext4)
  • Repair partition table
  • Try another USB drive
  • Try another USB OTG adapter | -|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt contains `dont_run_if_log_exists="true"` and a log is present on the USB drive. Ignoring.| Misconfiguration. | Remove log from USB drive or remove `dont_run_if_log_exists` line from femtofox-config.txt | +|
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_
    2 long blinks, each lasting 1.5 seconds | femtofox-config.txt is configured to skip if log exists. | USB drive mounted successfully but femtofox-config.txt contains `dont_run_if_log_exists="true"` and a log is present on the USB drive. Ignoring. | Remove log from USB drive or remove `dont_run_if_log_exists` line from femtofox-config.txt | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    3 long blinks, each lasting 1.5 seconds | USB drive mounted successfully but femtofox-config.txt was not found. Ignoring.| Config file missing. | Create configuration file as described above. | |
    ⚠️
    \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_  \_\_\_\_\_
    5 long blinks, each lasting 1.5 seconds | USB drive mounted successfully and femtofox-config.txt was found but did not contain readable configuration data. Ignoring.| Configuration file improperly formatted or contains no data. | Check configuration file contents as described above. | |
    ⚠️
    \_\_\_  \_\_\_  \_  \_  \_\_\_  \_\_\_  \_  \_
    2 long blinks, each lasting 1 second, then 2 short blinks, each lasting 1/4 of a second. Repeats twice | Error while trying to implement a Meshtastic setting after 3 attempts. Some settings may have been implemented successfully.|
  • The error may be transient.
  • Configuration file may contain improper data. |
  • Try again.
  • Check configuration file contents as described above.
  • Check the log.

    This pattern may flash before other patterns. The pattern will repeat once for each failed setting.| @@ -78,6 +78,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. \ No newline at end of file From 8152bcb152ef975a41d8b70d49aa37f73e16dd0f Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:01:14 +0200 Subject: [PATCH 23/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/usb_config.md b/usb_config.md index f212389..f34a26c 100644 --- a/usb_config.md +++ b/usb_config.md @@ -27,7 +27,7 @@ meshtastic_lora_radio="ebyte-e22-900m30s" meshtastic_url="https://meshtastic.org/e/#CgMSAQESCAgBOAFAA0gB" meshtastic_admin_key="T/b8EGvi/Nqi6GyGefJt/jOQr+5uWHHZuBavkNcUwWQ=" meshtastic_legacy_admin="true" -dont_run_if_log_exists +dont_run_if_log_exists="true" ``` > [!NOTE] > Enter as many or as few settings as you like. @@ -53,11 +53,8 @@ dont_run_if_log_exists > > Clearing the `meshtastic_admin_key` list: The admin key list can contain up to three keys - *if more are added they will be ignored*. The USB configuration tool supports clearing the admin key list, after which you will need to re-add your admin key/s in a second operation. To clear the admin key list, enter `meshtastic_admin_key="clear"`. -> [!CAUTION] -> Attempting to set wifi settings via USB configuration tool without a wifi adapter connected will lead to a 5 minute hang while the configuration tool runs - either disconnect and reconnect power or wait the full 5 minutes to to recover. - > [!NOTE] -> `dont_run_if_log_exists` will prevent the USB configuration tool from working if there's a log present on the USB drive, indicating it has already been run. There is also an LED boot code for this, described below. +> `dont_run_if_log_exists="true"` will prevent the USB configuration tool from working if there's a log present on the USB drive, indicating it has already been run. There is also an LED boot code for this, described below. **To apply your configuration, reboot the Femtofox with the USB drive plugged in. No other USB drives can be plugged in at the same time.** A log (`femtofox-config.log`) is saved to `/home/femto` and the USB drive (except on NTFS, which is read only). @@ -77,7 +74,3 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. - \ No newline at end of file From d8115c4b5abd15e865d61ba33583dc634623ed79 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:01:39 +0200 Subject: [PATCH 24/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usb_config.md b/usb_config.md index f34a26c..a907dad 100644 --- a/usb_config.md +++ b/usb_config.md @@ -74,3 +74,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. + \ No newline at end of file From 3201106dde3ac973a37d3ae82275e8ac2ade8fcc Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:04:09 +0200 Subject: [PATCH 25/31] Update femto-usb-config-tool.sh --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh | 2 +- 1 file changed, 1 insertion(+), 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 f7ee418..2416c92 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 @@ -119,7 +119,7 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then # Check if the log exits and if the dont_run_if_log_exists line is set in the script if $log_exists && [[ $dont_run_if_log_exists = "true" ]]; then - log_message "log exists and script is set to exit" + log_message "\`dont_run_if_log_exists\` is set to \"true\" and log exists, ignoring..." for _ in {1..2}; do #boot code blink "1.5" && sleep 0.5 done From 4afe8a2167dea1859901694fbb84b6ae68955486 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:10:32 +0200 Subject: [PATCH 26/31] Update femto-usb-config-tool.sh --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh | 2 +- 1 file changed, 1 insertion(+), 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 2416c92..1328565 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 @@ -119,7 +119,7 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then # Check if the log exits and if the dont_run_if_log_exists line is set in the script if $log_exists && [[ $dont_run_if_log_exists = "true" ]]; then - log_message "\`dont_run_if_log_exists\` is set to \"true\" and log exists, ignoring..." + log_message "\`dont_run_if_log_exists\` is set to \"true\" and log exists, ignoring." for _ in {1..2}; do #boot code blink "1.5" && sleep 0.5 done From 36222d39556baab2520975da2a474a6ade5f42d6 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:48:38 +0200 Subject: [PATCH 27/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/usb_config.md b/usb_config.md index a907dad..f34a26c 100644 --- a/usb_config.md +++ b/usb_config.md @@ -74,6 +74,3 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. - \ No newline at end of file From e5fbe9fb6b90dd7935a1444e3506e2c081b3aa0f Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:50:07 +0200 Subject: [PATCH 28/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usb_config.md b/usb_config.md index f34a26c..a907dad 100644 --- a/usb_config.md +++ b/usb_config.md @@ -74,3 +74,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. + \ No newline at end of file From b42f340a83820f18d4bfb2893403928d43e87e68 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:14:28 +0200 Subject: [PATCH 29/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usb_config.md b/usb_config.md index a907dad..bacc92d 100644 --- a/usb_config.md +++ b/usb_config.md @@ -1,6 +1,6 @@ ## USB Configuration Tool -To configure some Femtofox settings such as wifi, you can insert a USB flash drive containing a configuration file. The system will automatically recognize, mount and implement the settings you specify. +To configure some Femtofox settings such as wifi, you can insert a USB flash drive containing a configuration file. On boot, the system will automatically recognize, mount and implement the settings you specify. The tool can also be run from the `femto-config` tool, in the `Utilities` menu. Configurable settings are: - Wifi SSID @@ -74,6 +74,3 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. - \ No newline at end of file From 1f33a5acb11d38c34de2131aa0c5d8fd2e578b30 Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Wed, 8 Jan 2025 16:15:24 +0200 Subject: [PATCH 30/31] usb_config.md updated from https://stackedit.io/ --- usb_config.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usb_config.md b/usb_config.md index bacc92d..887b5b3 100644 --- a/usb_config.md +++ b/usb_config.md @@ -74,3 +74,6 @@ When the Femtofox is finished booting, it will blink its User LED (see below) in > [!NOTE] > Boot codes can appear in sequence - for example: one long (4 second) blink, followed by 5 medium (half second) blinks means the USB drive failed to mount, and that the boot sequence is complete. + \ No newline at end of file From d625491318234dc1925d4674f13fbe91043653d1 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 9 Jan 2025 02:35:54 -0800 Subject: [PATCH 31/31] Added Rebuild Chroot menu option. Added rebuild chroot and did some cleanup. --- environment-setup/foxbuntu-builder.sh | 92 ++++++++++++++------------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/environment-setup/foxbuntu-builder.sh b/environment-setup/foxbuntu-builder.sh index e60f002..f117dc2 100644 --- a/environment-setup/foxbuntu-builder.sh +++ b/environment-setup/foxbuntu-builder.sh @@ -2,7 +2,6 @@ ################ TODO ################ # Add more error handling -# Address potential issues in comments # Package selection with curses # Switch chroot packages install # Modify DTS etc to enable SPI1 @@ -39,18 +38,10 @@ install_prerequisites() { apt install -y git ssh make gcc gcc-multilib g++-multilib module-assistant expect g++ gawk texinfo libssl-dev bison flex fakeroot cmake unzip gperf autoconf device-tree-compiler libncurses5-dev pkg-config bc python-is-python3 passwd openssl openssh-server openssh-client vim file cpio rsync qemu-user-static binfmt-support dialog } -#clone_repos() { -# echo "Cloning repos..." -# cd /home/${sudoer}/ -# git clone https://github.com/LuckfoxTECH/luckfox-pico.git -# git clone https://github.com/noon92/femtofox.git -#} - clone_repos() { echo "Cloning repos..." - cd /home/${sudoer}/ || return 1 # Ensure we successfully change the directory + cd /home/${sudoer}/ || return 1 - # Helper function to retry cloning a repo clone_with_retries() { local repo_url="$1" local retries=3 @@ -70,11 +61,10 @@ clone_repos() { fi } - # Clone both repos clone_with_retries "https://github.com/LuckfoxTECH/luckfox-pico.git" || return 1 clone_with_retries "https://github.com/noon92/femtofox.git" || return 1 - return 0 # Indicate success if all repos cloned + return 0 } build_env() { @@ -108,20 +98,17 @@ sync_foxbuntu_changes() { SOURCE_DIR=/home/${sudoer}/femtofox/foxbuntu DEST_DIR=/home/${sudoer}/luckfox-pico - # Ensure the source is updated cd "$SOURCE_DIR" || exit git pull - # Get a list of all Git-tracked files in the source cd "$SOURCE_DIR" || exit git ls-files > /tmp/source_files.txt - + echo "Merging in Foxbuntu modifications..." rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/sysdrv/ /home/${sudoer}/luckfox-pico/sysdrv/ rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/project/ /home/${sudoer}/luckfox-pico/project/ - rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/output/image/ /home/${sudoer}/luckfox-pico/output/image/ - - # Remove files in the destination that are no longer in the source repository + rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/output/image/ /home/${sudoer}/luckfox-pico/output/image/ + while read -r file; do src_file="$SOURCE_DIR/$file" dest_file="$DEST_DIR/$file" @@ -132,10 +119,9 @@ sync_foxbuntu_changes() { fi done < /tmp/source_files.txt - # Clean up rm /tmp/source_files.txt - echo "Synchronization complete." + echo "Synchronization complete." } build_kernelconfig() { @@ -199,6 +185,29 @@ modify_chroot() { create_image } +rebuild_chroot() { + chroot_script=${CHROOT_SCRIPT:-/home/${sudoer}/femtofox/environment-setup/femtofox.chroot} + if [[ ! -f $chroot_script ]]; then + echo "Error: Chroot script $chroot_script not found." + exit 1 + fi + + echo "Press any key to wipe and rebuild chroot..." + read -n 1 -s -r + cd /home/${sudoer}/luckfox-pico + ./build.sh clean rootfs + cd /home/${sudoer}/ + rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/sysdrv/ /home/${sudoer}/luckfox-pico/sysdrv/ + rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/project/ /home/${sudoer}/luckfox-pico/project/ + build_rootfs + rsync -aHAXv --progress --keep-dirlinks --itemize-changes /home/${sudoer}/femtofox/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/ /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/ + build_firmware + install_rootfs + build_rootfs + build_firmware + create_image +} + inject_chroot() { chroot_script=${CHROOT_SCRIPT:-/home/${sudoer}/femtofox/environment-setup/femtofox.chroot} if [[ ! -f $chroot_script ]]; then @@ -266,9 +275,7 @@ install_rootfs() { mount --bind /sys /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/sys mount --bind /dev /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/dev mount --bind /dev/pts /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/dev/pts - chroot /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106 /tmp/chroot_script.sh - umount /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/dev/pts umount /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/proc umount /home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106/sys @@ -303,7 +310,6 @@ create_image() { sdk_install() { echo "Installing Foxbuntu SDK Disk Image Builder..." - # get the luckfox build environment if [ -d /home/${sudoer}/femtofox ]; then echo "WARNING: ~/femtofox exists, this script will DESTROY and recreate it." echo "Press Ctrl+C to cancel, or Enter to continue." @@ -350,12 +356,13 @@ usage() { echo "To modify the chroot and build an updated image use the arg 'modify_chroot'." echo "To modify the kernel and build an updated image use the arg 'modify_kernel'." echo "To specify a custom chroot script use the arg '--chroot-script /full/path/to/custom.chroot'" - echo "other args: build_env sync_foxbuntu_changes build_kernelconfig install_rootfs build_rootfs build_uboot build_firmware create_image" + echo "other args: rebuild_chroot inject_chroot build_env sync_foxbuntu_changes build_kernelconfig install_rootfs build_rootfs build_uboot build_firmware create_image" echo "Example: sudo ~/foxbunto_env_setup.sh sdk_install" echo "Example: sudo ~/foxbunto_env_setup.sh modify_chroot" echo "Example: sudo ~/foxbunto_env_setup.sh --chroot-script /home/user/custom.chroot" exit 0 } + ################### MENU SYSTEM ################### if [[ "${1}" == "--chroot-script" ]]; then @@ -381,16 +388,15 @@ elif [[ -z ${1} ]]; then 1 "Get Image Updates" \ 2 "Modify Kernel Menu" \ 3 "Enter and Modify Chroot" \ - 4 "Inject Chroot Script" \ - 5 "Manual Build Environment" \ - 6 "Manual Build U-Boot" \ - 7 "Manual Build RootFS" \ - 8 "Manual Build Firmware" \ - 9 "Manual Create Final Image" \ - "" "" \ - 10 "SDK Install (Run this first.)" \ - "" "" \ - 11 "Exit" \ + 4 "Rebuild Chroot" \ + 5 "Inject Chroot Script (CAUTION)" \ + 6 "Manual Build Environment" \ + 7 "Manual Build U-Boot" \ + 8 "Manual Build RootFS" \ + 9 "Manual Build Firmware" \ + 10 "Manual Create Final Image" \ + 11 "SDK Install (Run this first.)" \ + 12 "Exit" \ 2>&1 >/dev/tty) clear @@ -399,18 +405,18 @@ elif [[ -z ${1} ]]; then 1) update_image ;; 2) modify_kernel ;; 3) modify_chroot ;; - 4) inject_chroot ;; - 5) build_env ;; - 6) build_uboot ;; - 7) build_rootfs ;; - 8) build_firmware ;; - 9) create_image ;; - 10) sdk_install ;; - 11) echo "Exiting..."; break ;; + 4) rebuild_chroot ;; + 5) inject_chroot ;; + 6) build_env ;; + 7) build_uboot ;; + 8) build_rootfs ;; + 9) build_firmware ;; + 10) create_image ;; + 11) sdk_install ;; + 12) echo "Exiting..."; break ;; *) echo "Invalid option, please try again." ;; esac - # Pause after executing a command echo "Menu selection completed. Press any key to return to the menu." read -n 1 -s -r done