11#! /bin/bash
22
3+ # ARM Cross-Compilation Configuration Script
4+ # ==========================================
5+ # Sets up all environment variables and paths needed for ARM cross-compilation
6+ # Usage: source arm_build_config.sh [arm32|arm64]
7+ # Note: This script must be sourced, not executed directly
8+
9+
10+ # Validate and set architecture-specific variables
11+ # arm32: 32-bit ARM (armhf)
12+ # arm64: 64-bit ARM (aarch64)
313if [ " $1 " == " arm64" ]; then
414 echo " Building for aarch64"
515 TOOLCHAIN_HOST=" aarch64-linux-gnu"
1727 exit
1828fi
1929
30+
31+ # These branches/tags define which version of each dependency to build
32+ # Update these when you need to use different versions of dependencies
2033LIBSERIALPORT_BRANCH=master
2134LIBIIO_VERSION=v0.26
2235LIBAD9361_BRANCH=main
@@ -36,74 +49,79 @@ ECM_BRANCH=kf5
3649KARCHIVE_BRANCH=kf5
3750GENALYZER_BRANCH=main
3851
52+ # This environment variable tells the C++ code to use relative paths for libraries
53+ # When set to 1, the application looks for libraries in the AppImage bundle
54+ # instead of system locations, making the package portable
3955export APPIMAGE=1
4056
57+ # SRC_SCRIPT: Directory containing this script (ci/arm)
58+ # STAGING_AREA: Main working directory for builds
4159SRC_SCRIPT=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
4260[ $CI_SCRIPT == " ON" ] && STAGING_AREA=$HOME /scopy/ci/arm/staging || STAGING_AREA=$SRC_SCRIPT /staging
43- SYSROOT=$STAGING_AREA /sysroot
61+
62+ SYSROOT=$STAGING_AREA /sysroot # root filesystem extracted from Kuiper Linux image
4463SYSROOT_TAR=$STAGING_AREA /sysroot.tar.gz
45- TOOLCHAIN=$STAGING_AREA /cross-pi-gcc
64+ TOOLCHAIN=$STAGING_AREA /cross-pi-gcc # Cross-compiler location
4665TOOLCHAIN_BIN=$TOOLCHAIN /bin
4766TOOLCHAIN_FILE=$SRC_SCRIPT /cmake_toolchain.cmake
48- QT_LOCATION=$SYSROOT /usr/lib/$TOOLCHAIN_HOST /qt5
4967
50- if [ $TOOLCHAIN_HOST == " aarch64-linux-gnu" ]; then
51- QT_BUILD_DEVICE=linux-rasp-pi4-v3d-g++
52- elif [ $TOOLCHAIN_HOST == " arm-linux-gnueabihf" ]; then
53- QT_BUILD_DEVICE=linux-rasp-pi3-vc4-g++
54- fi
68+ QT_LOCATION=$SYSROOT /usr/lib/$TOOLCHAIN_HOST /qt5
69+ QT_BUILD_LOCATION=$QT_LOCATION # The location where Qt will be installed in the system
70+ QT_SYSTEM_LOCATION=/usr/lib/$TOOLCHAIN_HOST /qt5 # The Qt location relative to the sysroot folder
5571
5672CMAKE_BIN=$STAGING_AREA /cmake/bin/cmake
5773QMAKE_BIN=$QT_LOCATION /bin/qmake
58- JOBS=-j14
5974
60- APP_DIR=$SRC_SCRIPT /scopy.AppDir
61- APP_IMAGE=$SRC_SCRIPT /Scopy.AppImage
62- APP_RUN=$SRC_SCRIPT /../general/AppRun
63- APP_DESKTOP=$SRC_SCRIPT /../general/scopy.desktop
64- APP_SQUASHFS=$SRC_SCRIPT /scopy.squashfs
65-
66- # Runetimes downloaded from https://github.com/AppImage/type2-runtime/releases/tag/20251108 8 Dec 2025
67- RUNTIME_ARM=$SRC_SCRIPT /runtime-$ARCHITECTURE
68-
69-
70- # The exports below ensure these variables are available to the toolchain file.
71- export CMAKE_SYSROOT=" $SYSROOT "
72- export QT_LOCATION=" $QT_LOCATION "
73- export STAGING_AREA=" $STAGING_AREA "
74- export CMAKE_SYSTEM_PROCESSOR=" $CMAKE_SYSTEM_PROCESSOR "
75- export CMAKE_LIBRARY_ARCHITECTURE=" $CMAKE_LIBRARY_ARCHITECTURE "
75+ JOBS=-j14 # Parallel build configuration
7676
7777CMAKE_OPTS=(\
7878 -DCMAKE_INSTALL_PREFIX=" $SYSROOT " \
7979 -DCMAKE_TOOLCHAIN_FILE=" $TOOLCHAIN_FILE " \
8080 -DCMAKE_BUILD_TYPE=RelWithDebInfo \
8181 )
8282
83- CMAKE=" $CMAKE_BIN ${CMAKE_OPTS[*]} "
83+ CMAKE=" $CMAKE_BIN ${CMAKE_OPTS[*]} " # Complete CMake command with all options
8484
85- QT_BUILD_LOCATION=$QT_LOCATION # the location where Qt will be installed in the system
86- QT_SYSTEM_LOCATION=/usr/lib/$TOOLCHAIN_HOST /qt5 # the Qt location relative to the sysroot folder
8785CROSS_COMPILER=$TOOLCHAIN
8886
89- if [ $TOOLCHAIN_HOST == " aarch64-linux-gnu" ]; then
90- CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Bonus%20Raspberry%20Pi%20GCC%2064-Bit%20Toolchains/Raspberry%20Pi%20GCC%2064-Bit%20Cross-Compiler%20Toolchains/Bookworm/GCC%2012.2.0/cross-gcc-12.2.0-pi_64.tar.gz
91- elif [ $TOOLCHAIN_HOST == " arm-linux-gnueabihf" ]; then
92- # bookwork
93- # CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Bookworm/GCC%2012.2.0/Raspberry%20Pi%202%2C%203/cross-gcc-12.2.0-pi_2-3.tar.gz
94- CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Bullseye/GCC%2010.2.0/Raspberry%20Pi%203A%2B%2C%203B%2B%2C%204%2C%205/cross-gcc-10.2.0-pi_3%2B.tar.gz
95- fi
87+ APP_DIR=$SRC_SCRIPT /scopy.AppDir # Temporary directory structure that becomes the AppImage
88+ APP_IMAGE=$SRC_SCRIPT /Scopy.AppImage # Final AppImage executable file
89+ APP_RUN=$SRC_SCRIPT /../general/AppRun # Entry point script that launches the application
90+ APP_DESKTOP=$SRC_SCRIPT /../general/scopy.desktop # Desktop entry file for Linux desktop integration
91+ APP_SQUASHFS=$SRC_SCRIPT /scopy.squashfs
92+
93+ # AppImage runtime for ARM
94+ # Downloaded from https://github.com/AppImage/AppImageKit/releases/continuous
95+ # The runtime is a small executable that mounts and runs the AppImage
96+ RUNTIME_ARM=$SRC_SCRIPT /runtime-$ARCHITECTURE
97+
98+ # These exports make variables available to cmake_toolchain.cmake
99+ # The toolchain file needs these to properly configure cross-compilation
100+ export CMAKE_SYSROOT=" $SYSROOT "
101+ export QT_LOCATION=" $QT_LOCATION "
102+ export STAGING_AREA=" $STAGING_AREA "
103+ export CMAKE_SYSTEM_PROCESSOR=" $CMAKE_SYSTEM_PROCESSOR "
104+ export CMAKE_LIBRARY_ARCHITECTURE=" $CMAKE_LIBRARY_ARCHITECTURE "
96105
106+ # CMake 3.29
97107CMAKE_DOWNLOAD_LINK=https://github.com/Kitware/CMake/releases/download/v3.29.0-rc2/cmake-3.29.0-rc2-linux-x86_64.tar.gz
108+ # Qt 5.15.16 LTS source code
109+ QT_DOWNLOAD_LINK=https://download.qt.io/archive/qt/5.15/5.15.16/single/qt-everywhere-opensource-src-5.15.16.tar.xz
110+ # Script to fix absolute symlinks in sysroot
111+ SYSROOT_RELATIVE_LINKS=https://raw.githubusercontent.com/abhiTronix/rpi_rootfs/master/scripts/sysroot-relativelinks.py
98112
113+ # Sets download URLs and Qt device specs based on target architecture
99114if [ $TOOLCHAIN_HOST == " aarch64-linux-gnu" ]; then
115+ QT_BUILD_DEVICE=linux-rasp-pi4-v3d-g++
116+ CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Bonus%20Raspberry%20Pi%20GCC%2064-Bit%20Toolchains/Raspberry%20Pi%20GCC%2064-Bit%20Cross-Compiler%20Toolchains/Bookworm/GCC%2012.2.0/cross-gcc-12.2.0-pi_64.tar.gz
100117 KUIPER_DOWNLOAD_LINK=https://github.com/analogdevicesinc/adi-kuiper-gen/releases/download/v2.0.0/image_2025-04-03-ADI-Kuiper-Linux-arm64.zip
101118 IMAGE_NAME=" 2025-04-03-ADI-Kuiper-Linux-arm64"
119+
102120elif [ $TOOLCHAIN_HOST == " arm-linux-gnueabihf" ]; then
121+ QT_BUILD_DEVICE=linux-rasp-pi3-vc4-g++
122+ # Bookworm compiler
123+ # CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Bookworm/GCC%2012.2.0/Raspberry%20Pi%202%2C%203/cross-gcc-12.2.0-pi_2-3.tar.gz
124+ CROSSCOMPILER_DOWNLOAD_LINK=https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/Raspberry%20Pi%20GCC%20Cross-Compiler%20Toolchains/Bullseye/GCC%2010.2.0/Raspberry%20Pi%203A%2B%2C%203B%2B%2C%204%2C%205/cross-gcc-10.2.0-pi_3%2B.tar.gz
103125 KUIPER_DOWNLOAD_LINK=https://swdownloads.analog.com/cse/kuiper/image_2023-12-13-ADI-Kuiper-full.zip
104126 IMAGE_NAME=" 2023-12-13-ADI-Kuiper-full"
105127fi
106-
107- QT_DOWNLOAD_LINK=https://download.qt.io/archive/qt/5.15/5.15.16/single/qt-everywhere-opensource-src-5.15.16.tar.xz
108-
109- SYSROOT_RELATIVE_LINKS=https://raw.githubusercontent.com/abhiTronix/rpi_rootfs/master/scripts/sysroot-relativelinks.py
0 commit comments