# Install Docker in rootless mode sudo apt install uidmap sudo apt-get install -y dbus-user-session sudo apt-get install -y fuse-overlayfs sudo apt-get install -y slirp4netns sudo apt-get install -y iptables curl -fsSL https://get.docker.com/rootless | sh #### To remove run dockerd-rootless-setuptool.sh uninstall systemctl --user start docker # Create docker image for armhf cross compile nano Dockerfile_armhf_CC ######## FROM debian:bullseye RUN dpkg --add-architecture armhf && \ apt-get update && \ apt-get install -y curl git sudo nano && \ apt-get install -y build-essential && \ apt-get install -y libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf && \ apt-get install -y libdbus-1-dev libdbus-1-dev:armhf && \ apt-get install -y libasound2-dev:armhf openssl:armhf libssl-dev:armhf && \ apt-get clean ######## docker build -t dev_armhf_cc:bullseye - < Dockerfile_armhf_CC ## or docker build -t dev_aarch64_cc:bullseye - < Dockerfile_aarch64_CC ### for aarch64 (amlogic_tvbox) # Run docker container for armhf cross compile docker run -it -v /home/mgt/Data/CamillaDSP:/home/CamillaDSP dev_armhf_cc:bullseye ### it for interactive console and v to mount local dir to container dir ## docker run -it -v /home/mgt/Dev/CamillaDSP:/home/CamillaDSP dev_aarch64_cc:bullseye ### for aarch64 (amlogic_tvbox); it for interactive console and v to mount local dir to container dir # Install rustc/cargo (toolchain) and build inside container, NOT NEEDED for aarch64, move straight to build command instead mkdir /home/mgt adduser mgt usermod -aG sudo mgt chown mgt:mgt -R /home/mgt chown mgt:mgt -R /home/CamillaDSP cd /home/mgt su mgt export CARGO_HOME=/home/mgt/.cargo export PATH=/home/mgt/.cargo/bin:$PATH export USER=mgt mkdir /home/mgt/.cargo cat > /home/mgt/.cargo/config << EOF [target.armv7-unknown-linux-gnueabihf] linker = "arm-linux-gnueabihf-gcc" EOF sudo dpkg --add-architecture armhf curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env" rustup default stable rustup target add x86_64-unknown-linux-gnu rustup target add armv7-unknown-linux-gnueabihf export PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig" export PKG_CONFIG_ALLOW_CROSS="true" # Build CamillaDSP cd /home/CamillaDSP cd git tag git checkout ... (version to build) RUSTFLAGS='-C target-feature=+neon' cargo build --target armv7-unknown-linux-gnueabihf --features secure-websocket --features 32bit --release ## RUSTFLAGS='-C target-feature=+neon' cargo build --target aarch64-unknown-linux-gnu --features secure-websocket --release ### for aarch64 (amlogic_tvbox) ## RUSTFLAGS='-C target-feature=+neon -C strip=debuginfo -C codegen-units=1 -C lto=true -C embed-bitcode=yes' cargo build --target aarch64-unknown-linux-gnu --features secure-websocket --release ### for optimized aarch64 (amlogic_tvbox) ### Might need to edit Docker file to change base from bullseye to bookworm in case newer version of libs/tools are needed ### Other refs https://doc.rust-lang.org/cargo/reference/profiles.html https://nnethercote.github.io/perf-book/build-configuration.html https://earthly.dev/blog/cross-compiling-raspberry-pi/ https://jensd.be/1126/linux/cross-compiling-for-arm-or-aarch64-on-debian-or-ubuntu