.. _rust_cross_compilation: ===================================== Cross-Compilation for Embedded Linux ===================================== ``rustflexstack`` can be natively cross-compiled to non-x86 architectures without source-level modifications. This guide covers cross-compiling for ``aarch64-unknown-linux-gnu``, targeting platforms such as the **Raspberry Pi 5** and Arm Cortex-A automotive compute units. Method 1: Native Cross-Toolchain (Debian / Ubuntu) ================================================== 1. Add the Target Architecture ------------------------------ .. code-block:: bash rustup target add aarch64-unknown-linux-gnu 2. Install the Cross-Linker --------------------------- .. code-block:: bash sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu 3. Configure Cargo Linker ------------------------- Create or edit ``.cargo/config.toml`` in your project root: .. code-block:: toml [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" 4. Compile ---------- .. code-block:: bash cargo build --release --target aarch64-unknown-linux-gnu The cross-compiled binary will be generated at ``target/aarch64-unknown-linux-gnu/release/``. Method 2: Zero-Config with `cross` (Docker) =========================================== If you prefer a hermetic containerized build without installing host toolchains: 1. Install ``cross``: .. code-block:: bash cargo install cross 2. Build inside Docker: .. code-block:: bash cross build --release --target aarch64-unknown-linux-gnu Deploying to Target Hardware ============================ Copy the compiled binary to your device via SCP: .. code-block:: bash scp target/aarch64-unknown-linux-gnu/release/examples/v2x_cli user@192.168.1.100:/home/user/ On the target Raspberry Pi or embedded board: .. code-block:: bash # Run with raw socket permissions sudo ./v2x_cli --iface eth0 --send cam