This commit is contained in:
nagumii 2024-11-16 16:08:41 +02:00
parent 874fc1fe3d
commit 2b4be38de5
4 changed files with 173 additions and 0 deletions

4
scripts/issue Normal file
View file

@ -0,0 +1,4 @@
Ubuntu 22.04.3 LTS \n \l
[username:password] root:root femto:fox

101
scripts/luckfox-install.sh Normal file
View file

@ -0,0 +1,101 @@
sudo mount -t tmpfs tmpfs /run -o remount,size=32M,nosuid,noexec,relatime,mode=755 #Embiggen tmpfs - prevents problems.
sudo sh -c 'echo "tmpfs /run tmpfs size=32M,nosuid,noexec,relatime,mode=755 0 0" >> /etc/fstab' #Embiggen tmpfs - for future boots.
echo "Enlarged tmpfs\n"
sudo timedatectl set-timezone UTC #Set timezone to UTC.
date -d "$(wget --method=HEAD -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f4-10)" #Set time/date.
echo "Changed timezone to UTC and got network time\n"
#update system and install dependencies
echo "Updating Ubuntu and installing dependencies...\n"
sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y update && sudo DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -y upgrade
sudo apt-get install linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev -y
pip3 install pytap2 meshtastic pypubsub
echo "Done updating and installing dependencies\n"
#get latest meshtasticd beta
echo "Getting latest Meshtasticd beta..."
URL=$(wget -qO- https://api.github.com/repos/meshtastic/firmware/releases/latest | grep -oP '"browser_download_url": "\K[^"]*armhf\.deb' | head -n 1); FILENAME=$(basename $URL); wget -O /tmp/$FILENAME $URL && sudo apt install /tmp/$FILENAME -y && sudo rm /tmp/$FILENAME
echo "Installed latest Meshtasticd beta\n"
echo "Getting custom FemtoFox files...\n"
git clone https://github.com/noon92/femtofox.git
sudo cp ../liborcania_2.3_armhf/* /usr/lib/arm-linux-gnueabihf/
sudo mv /etc/meshtasticd/config.yaml /etc/meshtasticd/config.yaml.bak
sudo cp ../meshtasticd/config.yaml /etc/meshtasticd/
sudo cp /etc/update-motd.d/00-header /etc/update-motd.d/00-header.bak
sudo mv 00-header /etc/update-motd.d/
sudo chmod +x /etc/update-motd.d/00-header
echo "Installed custom FemtoFox files\n"
#serial port permissions
sudo usermod -a -G tty $USER
sudo usermod -a -G dialout $USER
echo "Set serial port permissions\n"
#disable redundant services
sudo systemctl disable vsftpd.service
sudo systemctl disable ModemManager.service
sudo systemctl disable polkit.service
sudo systemctl disable getty@tty1.service
sudo systemctl disable alsa-restore.service
echo "Disabled redundant services\n"
#change luckfox system config
echo "Changing Luckfox system config\n"
sudo mv luckfox.cfg /etc/
sudo luckfox-config load
echo "Set Luckfox system config\n"
sudo chmod +x networkinterfaces.sh
sudo ./networkinterfaces.sh
#replace /etc/rc.local
sudo cp /etc/rc.local /etc/rc.local.bak
sudo cp ./rc.local /etc/rc.local
sudo chmod +x /etc/rc.local
echo "Replaced /etc/rc.local system config\n"
#replace /etc/issue
sudo cp /etc/issue /etc/issue.bak
sudo cp ./issue /etc/issue
echo "Replaced /etc/issue\n"
#add daily reboot to cron
echo -e "# reboot pi every 7. Default timezone is GMT. To change timezone run \`sudo tzselect\`\n0 6 * * * /sbin/reboot\n\n# restart bbs server script every odd hour\n#0 23/2 * * * sudo systemctl restart mesh-bbs.service" | sudo tee -a /var/spool/cron/crontabs/root > /dev/null
echo "Scheduled daily reboot at 06:00 UTC\n"
#wifi support
echo "Adding wifi support...\n"
sudo mkdir /lib/modules
sudo mkdir /lib/modules/5.10.160
sudo find /oem/usr/ko/ -name '*.ko' ! -name 'ipv6.ko' -exec cp {} /lib/modules/5.10.160/ \;
sudo touch /lib/modules/5.10.160/modules.order
sudo touch /lib/modules/5.10.160/modules.builtin
sudo depmod -a 5.10.160
sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null <<EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US # Change to your country code
network={
ssid="YourSSID" #replace with SSID
psk="YourPassword" #replace with password
key_mgmt=WPA-PSK
}
EOF
echo 'SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?", ATTR{type}=="1", KERNEL=="wl*", NAME="wlan%n"' | sudo tee /etc/udev/rules.d/70-network.rules > /dev/null
sudo ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
sudo udevadm control --reload-rules
sudo udevadm trigger
sudo systemctl stop NetworkManager
sudo systemctl disable NetworkManager
echo "Added wifi support\n"
sudo rm -rf ~/femtofox
echo "Cleaning up...\n"
echo "Configuration complete, rebooting...\n"
sudo sleep 5 && sudo reboot

9
scripts/luckfox.cfg Normal file
View file

@ -0,0 +1,9 @@
SPI0_M0_CS_ENABLE=1
SPI0_M0_MODE=1
UART4_M1_STATUS=1
UART3_M1_STATUS=1
I2C3_M1_STATUS=1
I2C3_M1_SPEED=100000
SPI0_M0_STATUS=1
SPI0_M0_MISO_ENABLE=1
SPI0_M0_SPEED=2000001

59
scripts/rc.local Normal file
View file

@ -0,0 +1,59 @@
#!/bin/bash
#not really needed after first boot
#/usr/bin/filesystem_resize.sh
#supposedly needed for usb storage, but works anyway
#/etc/init.d/S50usbdevice start
luckfox-config load
#try enable RTC
echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1
#if RTC recognized
if ls /dev/rtc* 1> /dev/null 2>&1; then
rtc="true"
if sudo hwclock -s 2>&1 | grep -a failed > /dev/null 2>&1; then
echo "RTC device found but failed to get time."
else
hwclock -s > /dev/null 2>&1 &
echo "RTC device found! $(date +"%Y-%m-%d %H:%M:%S %Z")."
fi
else
echo "RTC not found."
sudo date -s "1 JAN 2024 00:00:00" > /dev/null 2>&1 &
fi
#try get network time
date_str=$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')
if [ -n "$date_str" ]; then
sudo date -s "$date_str" > /dev/null 2>&1
sudo echo "Got network time: $(date +"%Y-%m-%d %H:%M:%S %Z")."
if [ "$rtc" = "true" ]; then
echo "Setting RTC to network time."
sudo hwclock -w &
fi
else
echo "Failed to fetch network time, using $(date +"%Y-%m-%d %H:%M:%S %Z") instead."
fi
echo "Disabling LED..."
echo "none" > /sys/class/leds/work/trigger &
# necessary for internet over usb in otg mode (see https://web.archive.org/web/20241006173648/https://wiki.luckfox.com/Luckfox-Pico/Luckfox-Pico-Network-Sharing-1/)
# sleep 5 && route add default gw 172.32.0.100 && echo "nameserver 8.8.8.8" >> /etc/resolv.conf
#does not appear to lower power consumption, but needs more testing
#(sleep 5 && cpufreq-set -u 408000 && echo "Boot complete, setting CPU frequency to 408mhz.") &
#boot complete, blink USER LED 5 times in background
echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction && (
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