Files
r36ultra_app/CROSS_COMPILE.md
2026-02-01 16:41:07 -03:00

2.6 KiB

Cross-Compilation Guide for ARM64

This guide explains how to cross-compile the framebuffer demo for ARM64 (aarch64) architecture, which is used by the R36 Ultra device.

Prerequisites

Install ARM64 Cross-Compiler

On Ubuntu/Debian:

sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install valac

Verify Installation

aarch64-linux-gnu-gcc --version

Compilation Methods

./compile.sh arm64

This will:

  1. Compile Vala code to C
  2. Cross-compile C code to ARM64 using aarch64-linux-gnu-gcc
  3. Create a statically-linked binary for ARM64

Method 2: Manual Cross-Compilation

Step 1: Compile Vala to C

valac --pkg posix -C framebuffer_demo.vala

Step 2: Cross-compile C to ARM64

aarch64-linux-gnu-gcc framebuffer_demo.c -o framebuffer_demo \
    $(pkg-config --cflags --libs glib-2.0 gobject-2.0) \
    -static

Method 3: Native Compilation (on R36 Ultra)

If you prefer to compile directly on the R36 Ultra device:

./compile.sh

Verifying the Binary

Check the compiled binary architecture:

file framebuffer_demo

Expected output:

framebuffer_demo: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, ...

Transferring to R36 Ultra

Using SCP

scp framebuffer_demo user@r36ultra:/home/user/

Using USB/SD Card

  1. Copy framebuffer_demo to USB drive or SD card
  2. Insert into R36 Ultra
  3. Copy to device storage

Running on R36 Ultra

chmod +x framebuffer_demo
sudo ./framebuffer_demo

Troubleshooting

Cross-compiler not found

sudo apt-get install gcc-aarch64-linux-gnu

Missing GLib dependencies

sudo apt-get install libglib2.0-dev

Binary won't run on device

  • Ensure you compiled for the correct architecture (ARM64/aarch64)
  • Try static linking: add -static flag to gcc command
  • Check device architecture: uname -m (should show aarch64)

Permission denied on /dev/fb0

sudo ./framebuffer_demo

Static vs Dynamic Linking

  • Binary includes all dependencies
  • Larger file size
  • No dependency issues on target device
  • Use -static flag

Dynamic Linking

  • Smaller binary
  • Requires compatible libraries on target device
  • May have compatibility issues
  • Remove -static flag

Architecture Information

  • R36 Ultra: ARM64 (aarch64)
  • Cross-compiler: aarch64-linux-gnu-gcc
  • Target: Linux ARM 64-bit