mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-20 15:06:36 -05:00
- Created foxbuntu-lyra-builder.sh for Luckfox Lyra Zero W migration - Preserves Ubuntu rootfs and femto utilities from Pico Mini build - Integrates with Luckfox-Lyra-SDK for RK3506 platform - Updated WARP.md with Ubuntu 24.04.3 LTS environment info - Added comprehensive migration strategy and workflow documentation
202 lines
6.5 KiB
Bash
Executable file
202 lines
6.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
################ LYRA MIGRATION BUILDER ################
|
|
# Foxbuntu Lyra Zero W Builder
|
|
# Migrates existing Ubuntu-based Foxbuntu to Luckfox Lyra Zero W (RK3506)
|
|
# Preserves Ubuntu rootfs and femto utilities from original Pico Mini build
|
|
##########################################################
|
|
|
|
if [[ $(id -u) != 0 ]]; then
|
|
echo "This script must be run as root; use sudo"
|
|
exit 1
|
|
fi
|
|
|
|
sudoer=$(echo $SUDO_USER)
|
|
|
|
# Environment variables for Lyra SDK
|
|
export RK_KERNEL_VERSION=6.1
|
|
export RK_TARGET_SOC=rk3506
|
|
export RK_TARGET_PRODUCT=lyra_zero_w
|
|
|
|
echo "=============================================="
|
|
echo " Foxbuntu Lyra Zero W Migration Builder"
|
|
echo "=============================================="
|
|
echo "Target: Luckfox Lyra Zero W (RK3506)"
|
|
echo "Kernel: Linux 6.1"
|
|
echo "Base: Ubuntu 22.04 LTS (preserved from Pico build)"
|
|
echo "=============================================="
|
|
|
|
# Check if 'dialog' is installed, install it if missing
|
|
if ! command -v dialog &> /dev/null; then
|
|
echo "The 'dialog' package is required to run this script. Press any key to install it."
|
|
read -n 1 -s -r
|
|
apt update && apt install -y dialog
|
|
fi
|
|
|
|
install_prerequisites() {
|
|
echo "Setting up Foxbuntu Lyra build environment..."
|
|
echo "Note: Adding Python 2.7 for repo tool compatibility"
|
|
apt update
|
|
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 python2.7 passwd openssl openssh-server openssh-client vim file cpio rsync qemu-user-static binfmt-support dialog repo
|
|
}
|
|
|
|
init_lyra_sdk() {
|
|
echo "Initializing Luckfox Lyra SDK..."
|
|
cd /home/${sudoer}/femtofox/Luckfox-Lyra-SDK || {
|
|
echo "Error: Luckfox-Lyra-SDK directory not found!"
|
|
return 1
|
|
}
|
|
|
|
# Try to use system repo tool first, fallback to local
|
|
if command -v repo >/dev/null 2>&1; then
|
|
echo "Using system repo tool..."
|
|
repo sync
|
|
else
|
|
echo "Using local repo tool..."
|
|
python2.7 repo/repo sync || {
|
|
echo "Repo sync failed. SDK may need manual initialization."
|
|
return 1
|
|
}
|
|
fi
|
|
}
|
|
|
|
setup_lyra_toolchain() {
|
|
echo "Setting up RK3506 cross-compilation toolchain..."
|
|
LYRA_SDK_PATH="/home/${sudoer}/femtofox/Luckfox-Lyra-SDK"
|
|
TOOLCHAIN_PATH="$LYRA_SDK_PATH/prebuilts/gcc/linux-x86/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin"
|
|
|
|
if [ -d "$TOOLCHAIN_PATH" ]; then
|
|
export PATH="$TOOLCHAIN_PATH:$PATH"
|
|
echo "Toolchain path: $TOOLCHAIN_PATH"
|
|
echo "Testing toolchain..."
|
|
arm-none-linux-gnueabihf-gcc --version | head -2
|
|
else
|
|
echo "Warning: RK3506 toolchain not found at expected path"
|
|
echo "Expected: $TOOLCHAIN_PATH"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
preserve_ubuntu_rootfs() {
|
|
echo "Preserving existing Ubuntu rootfs from Pico build..."
|
|
PICO_ROOTFS="/home/${sudoer}/luckfox-pico/sysdrv/out/rootfs_uclibc_rv1106"
|
|
BACKUP_ROOTFS="/home/${sudoer}/femtofox-ubuntu-rootfs-backup"
|
|
|
|
if [ -d "$PICO_ROOTFS" ]; then
|
|
echo "Creating backup of Ubuntu rootfs..."
|
|
rsync -aHAXv --progress "$PICO_ROOTFS/" "$BACKUP_ROOTFS/"
|
|
echo "Ubuntu rootfs backed up to: $BACKUP_ROOTFS"
|
|
else
|
|
echo "Warning: Original Ubuntu rootfs not found at $PICO_ROOTFS"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
analyze_lyra_sdk() {
|
|
echo "Analyzing Luckfox Lyra SDK structure..."
|
|
LYRA_SDK_PATH="/home/${sudoer}/femtofox/Luckfox-Lyra-SDK"
|
|
cd "$LYRA_SDK_PATH" || return 1
|
|
|
|
echo "=== SDK Components ==="
|
|
find . -maxdepth 2 -type d -name "*rk3506*" -o -name "*lyra*" | sort
|
|
|
|
echo "=== Available Device Configurations ==="
|
|
find . -name "*.mk" -exec grep -l "rk3506\|lyra" {} \; 2>/dev/null | head -10
|
|
|
|
echo "=== Kernel Device Trees ==="
|
|
find . -name "*.dts*" -path "*/rk3506*" -o -name "*lyra*.dts*" 2>/dev/null | head -10
|
|
|
|
echo "=== Build Scripts ==="
|
|
find . -name "build.sh" -o -name "envsetup.sh" | head -10
|
|
}
|
|
|
|
test_migration_setup() {
|
|
echo "Testing migration setup..."
|
|
|
|
echo "1. Checking Ubuntu rootfs backup..."
|
|
if [ -d "/home/${sudoer}/femtofox-ubuntu-rootfs-backup/usr/local/bin" ]; then
|
|
echo " ✓ Ubuntu rootfs preserved"
|
|
echo " ✓ Femto utilities found: $(ls /home/${sudoer}/femtofox-ubuntu-rootfs-backup/usr/local/bin/femto-* | wc -l) scripts"
|
|
else
|
|
echo " ✗ Ubuntu rootfs backup incomplete"
|
|
fi
|
|
|
|
echo "2. Checking Lyra SDK..."
|
|
if [ -d "/home/${sudoer}/femtofox/Luckfox-Lyra-SDK/buildroot" ]; then
|
|
echo " ✓ Lyra SDK initialized"
|
|
else
|
|
echo " ⚠ Lyra SDK may need initialization (run init_lyra_sdk)"
|
|
fi
|
|
|
|
echo "3. Checking toolchain..."
|
|
if command -v arm-none-linux-gnueabihf-gcc >/dev/null 2>&1; then
|
|
echo " ✓ RK3506 toolchain available"
|
|
else
|
|
echo " ⚠ RK3506 toolchain not in PATH"
|
|
fi
|
|
}
|
|
|
|
usage() {
|
|
echo "Foxbuntu Lyra Zero W Migration Builder"
|
|
echo ""
|
|
echo "Available functions:"
|
|
echo " install_prerequisites - Install build dependencies"
|
|
echo " init_lyra_sdk - Initialize the Luckfox Lyra SDK"
|
|
echo " setup_lyra_toolchain - Set up RK3506 cross-compilation"
|
|
echo " preserve_ubuntu_rootfs - Backup existing Ubuntu rootfs"
|
|
echo " analyze_lyra_sdk - Analyze SDK structure"
|
|
echo " test_migration_setup - Test current setup status"
|
|
echo ""
|
|
echo "Example: sudo ./foxbuntu-lyra-builder.sh install_prerequisites"
|
|
exit 0
|
|
}
|
|
|
|
################### MENU SYSTEM ###################
|
|
|
|
if [[ -z ${1} ]]; then
|
|
if ! command -v dialog &> /dev/null; then
|
|
echo "The 'dialog' package is required to load the menu."
|
|
echo "Please install it using: sudo apt install dialog"
|
|
exit 1
|
|
fi
|
|
|
|
while true; do
|
|
CHOICE=$(dialog --clear --no-cancel --backtitle "Foxbuntu Lyra Zero W Migration Builder" \
|
|
--title "Main Menu" \
|
|
--menu "Choose an action:" 20 80 12 \
|
|
1 "Install Prerequisites" \
|
|
2 "Initialize Lyra SDK" \
|
|
3 "Set up Lyra Toolchain" \
|
|
4 "Preserve Ubuntu Rootfs" \
|
|
5 "Analyze Lyra SDK Structure" \
|
|
6 "Test Migration Setup" \
|
|
7 "Exit" \
|
|
2>&1 >/dev/tty)
|
|
|
|
clear
|
|
|
|
case $CHOICE in
|
|
1) install_prerequisites ;;
|
|
2) init_lyra_sdk ;;
|
|
3) setup_lyra_toolchain ;;
|
|
4) preserve_ubuntu_rootfs ;;
|
|
5) analyze_lyra_sdk ;;
|
|
6) test_migration_setup ;;
|
|
7) echo "Exiting..."; break ;;
|
|
*) echo "Invalid option, please try again." ;;
|
|
esac
|
|
|
|
echo "Menu selection completed. Press any key to return to the menu."
|
|
read -n 1 -s -r
|
|
done
|
|
else
|
|
if declare -f "${1}" > /dev/null; then
|
|
"${1}"
|
|
else
|
|
echo "Error: Function '${1}' not found."
|
|
usage
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
exit 0
|