Skip to content

Instantly share code, notes, and snippets.

@Ludorg
Last active March 8, 2024 12:30
Show Gist options
  • Save Ludorg/3ce85b30db367492d762e35fa433ea84 to your computer and use it in GitHub Desktop.
Save Ludorg/3ce85b30db367492d762e35fa433ea84 to your computer and use it in GitHub Desktop.
Notes about Wandboard use with Rust

Notes about testing Rust on a Wandboard

About Wandboard

The Wandboard is a Cortex-A9 ARM device sporting a single, dual, or quad core Freescale i.MX6 SoC

Source: http://www.armhf.com/boards/wandboard/

Installing Linux on Wandboard

Based on: https://forum.digikey.com/t/debian-getting-started-with-the-wandboard/12707

GNU Triplet: arm-linux-gnueabihf

Wandboard CPU is : Freescale / iMX6 / armv7 / VFPv3 / NEON / Cortex-A9

ARM Cross Compiler: GCC

Update version of gcc (Linaro).

https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/

https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz

wget https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
wget https://releases.linaro.org/components/toolchain/binaries/7.5-2019.12/arm-linux-gnueabihf/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz.asc
md5sum gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz
tar xvf gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf.tar.xz 
export CC=`pwd`/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

Bump of kernel version

Update version of kernel to v6.6.12-rt.

git clone https://github.com/RobertCNelson/armv7-multiplatform ./kernelbuildscripts
cd kernelbuildscripts/
git checkout origin/v6.6.x-rt -b tmp
sudo apt-get install lz4
sudo apt install lzma gettext libmpc-dev u-boot-tools 
export kernel_version=6.6.12-armv7-rt-x7

Bump of Root Filesystem version

wget https://rcn-ee.com/rootfs/eewiki/minfs/debian-12.1-minimal-armhf-2023-08-22.tar.xz
wget https://rcn-ee.com/rootfs/eewiki/minfs/debian-12.1-minimal-armhf-2023-08-22.tar.xz.sha256sum
cat debian-12.1-minimal-armhf-2023-08-22.tar.xz.sha256sum 
sha256sum debian-12.1-minimal-armhf-2023-08-22.tar.xz

Options for booting kernel with debug information

cmdline=video=HDMI-A-1:1920x1080@60e loglevel=7 debug

Installed versions check

U-Boot

U-Boot 2019.04-dirty (Feb 14 2024 - 21:53:06 +0100)

arm-linux-gnueabihf-gcc (Linaro GCC 7.5-2019.12) 7.5.0
GNU ld (Linaro_Binutils-2019.12) 2.28.2.20170706

uname -a

Linux arm 6.6.12-armv7-rt-x7 #1 SMP PREEMPT_RT Wed Feb 14 22:48:05 CET 2024 armv7l GNU/Linux

cat /etc/os-release

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

Let's go rusty !

First, add target compatible with Wandboard for cross-compilation.

rustup target add armv7-unknown-linux-gnueabihf

Update .cargo/config.toml file, either globally or locally to the project.

[target.armv7-unknown-linux-gnueabihf]
linker = "${PATH_TO_GCC_LINARO}/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc"

Compile the project with cargo.

cargo build --target=armv7-unknown-linux-gnueabihf --release

Copy the executable from target/armv7-unknown-linux-gnueabihf/release/ to the board and run it. Et voilà :)

On errors

When you get error about relocations in generic ELF (EM: 40), this is due to a misconfiguration of the linker in file .cargo/config.toml. This configuration is not Cargo.toml file of the project (this was my mistake).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment