avionic design with actual uboot and tooling
submodule of avionic design uboot bootloader and with included tools to get you started , read readme.md and readme-tk1-loader.md
This commit is contained in:
102
u-boot/build.sh
Executable file
102
u-boot/build.sh
Executable file
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
|
||||
# --- Configuration ---
|
||||
ARCH="arm"
|
||||
CROSS_COMPILE="arm-none-eabi-"
|
||||
DEFCONFIG="jetson-tk1_defconfig"
|
||||
FDT_HEADER="/usr/include/libfdt.h"
|
||||
FDT_ENV_HEADER="/usr/include/libfdt_env.h"
|
||||
CHECK_SCRIPT="scripts/kconfig/lxdialog/check-lxdialog.sh"
|
||||
|
||||
# Flags needed for modern GCC and Ncurses paths
|
||||
export HOSTCFLAGS="-fcommon -I/usr/include/ncursesw"
|
||||
|
||||
# --- Helper Functions ---
|
||||
|
||||
# Safety: Restore headers if script exits or crashes
|
||||
cleanup() {
|
||||
if [ -f "${FDT_HEADER}.bak" ]; then
|
||||
echo "--> Restoring system headers..."
|
||||
sudo mv "${FDT_HEADER}.bak" "$FDT_HEADER"
|
||||
sudo mv "${FDT_ENV_HEADER}.bak" "$FDT_ENV_HEADER"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# --- Commands ---
|
||||
|
||||
do_setup() {
|
||||
echo "--> Installing dependencies (Arch/CachyOS)..."
|
||||
sudo pacman -S --needed base-devel ncurses lib32-ncurses pkgconf bc arm-none-eabi-gcc arm-none-eabi-binutils
|
||||
|
||||
# Fix ncurses directory symlink
|
||||
if [ ! -d "/usr/include/ncurses" ]; then
|
||||
echo "--> Creating ncurses header symlink..."
|
||||
sudo ln -s /usr/include/ncursesw /usr/include/ncurses
|
||||
fi
|
||||
|
||||
# cut DTC version check
|
||||
if [ -f "scripts/dtc-version.sh" ]; then
|
||||
echo "--> Neutralizing DTC version check..."
|
||||
echo -e '#!/bin/sh\necho "0104"\nexit 0' >scripts/dtc-version.sh
|
||||
chmod +x scripts/dtc-version.sh
|
||||
fi
|
||||
|
||||
#fix lxdialog for modern GCC
|
||||
if [ -f "$CHECK_SCRIPT" ]; then
|
||||
echo "--> Patching $CHECK_SCRIPT for modern GCC..."
|
||||
sed -i 's/main() {}/int main() { return 0; }/' "$CHECK_SCRIPT"
|
||||
else
|
||||
echo "!! Warning: Could not find $CHECK_SCRIPT. Are you in the root directory?"
|
||||
fi
|
||||
echo "--> Setup complete."
|
||||
}
|
||||
|
||||
do_clear() {
|
||||
echo "--> Cleaning build artifacts..."
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE distclean
|
||||
}
|
||||
|
||||
do_config() {
|
||||
echo "--> Configuring with $DEFCONFIG..."
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE $DEFCONFIG
|
||||
}
|
||||
|
||||
do_menuconfig() {
|
||||
echo "--> Launching menuconfig..."
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE menuconfig
|
||||
}
|
||||
|
||||
do_build() {
|
||||
# Move headers to prevent conflict with U-Boot's internal libfdt
|
||||
echo "--> Temporarily hiding system FDT headers..."
|
||||
[ -f "$FDT_HEADER" ] && sudo mv "$FDT_HEADER" "${FDT_HEADER}.bak"
|
||||
[ -f "$FDT_ENV_HEADER" ] && sudo mv "$FDT_ENV_HEADER" "${FDT_ENV_HEADER}.bak"
|
||||
|
||||
echo "--> Starting build..."
|
||||
make ARCH=$ARCH CROSS_COMPILE=$CROSS_COMPILE -j$(nproc)
|
||||
}
|
||||
|
||||
# --- Argument Parser ---
|
||||
|
||||
case "$1" in
|
||||
setup)
|
||||
do_setup
|
||||
;;
|
||||
clear)
|
||||
do_clear
|
||||
;;
|
||||
default_config)
|
||||
do_config
|
||||
;;
|
||||
menuconfig)
|
||||
do_menuconfig
|
||||
;;
|
||||
"")
|
||||
do_build
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {setup|clear|default_config|menuconfig| (no args for build)}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user