Failure compling RIOT example app as native in Raspberry Pi 4

Hello everyone,

My name is Alfret Nara. I am a Master’s Student who has just started a project related to RIOT, with which I have little experience.

Currently, I’m trying to compile RIOT “Hello-World” as a native application in Raspberrpi 4, but it creates this error:

This problem occurs only when compiling applications as a native board, and it applies to other RIOT application examples as well. Flashing applications (blinky or hello-world) to an MCU board, such as nrf52840dk from Nordic Semiconductor, runs without any problem.

The OS used:

  • Operating System: Debian GNU/Linux 12 (bookworm)
  • Kernel: Linux 6.6.31+rpt-rpi-v8
  • Architecture: arm64

Compiler installed: gcc, gcc-arm-none-eabi.

Does anyone know what could be the problem or having a similar issue? I really appreciate any help or hints. Thank you very much in advance.

Best regards, Alfret Nara.

The problem is that GCC does not support 32 bit cross compilation on ARM. RIOT native only has support for ARM32/AArch32, there is a WIP PR to add support for AArch64 to native, but task switching doesn’t work yet.

The gcc-arm-none-eabi does not matter in this scenario, since you try to compile and run on your Raspberrry Pi. That’s why the flashing and compiling works fine.

As @benpicco mentioned, RIOT only support 32-Bit systems at the moment. Which is also available on 64-Bit systems, but you have to do a little work to get there.

You most likely have a gcc without the capability of compiling 32-Bit binaries. In your case this should be armhf. When you check the gcc options with `gcc -v --help | grep ‘m32’ you should see armhf support with gcc, which you likely are not.

So, how do we fix that? We need to get multiarch gcc onto your system. Enable armhf on your system.

sudo dpkg --add-architecture armhf
sudo apt update

install some additional libraries

sudo apt install gcc-multilib g++-multilib libc6-dev-armhf

Maybe also

sudo apt install libc6:armhf

Completly untested though. I don’t have a Rasperry Pi here. Maybe another arm64, but no time to test it. But this is most likely your issue here.

@benpicco thank you very much for the hints. This explains why it can’t work only on ARM, but no problem for other architectures such x86.

Thank you very much for your feedback @citrullin. But it still doesn’t work. I’ve tried to enable armhf, and install ‘llibc6-dev-armhf’ and ‘libc6:armhf’

But failed to install ‘gcc-multilib’ and “g++multilib” Here are the error results: When installing ‘gcc-multilib’

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 binutils-i686-linux-gnu:i386 : Depends: libc6:i386 (>= 2.36) but it is not going to be installed
 cpp-12:i386 : Depends: libc6:i386 (>= 2.36) but it is not going to be installed
 gcc-12:i386 : Depends: libc6:i386 (>= 2.36) but it is not going to be installed
               Recommends: libc6-dev:i386 (>= 2.23-1~) but it is not going to be installed
 libasan8:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libatomic1:i386 : Depends: libc6:i386 (>= 2.1.3) but it is not going to be installed
 libbinutils:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libc6-amd64:i386 : Depends: libc6:i386 (= 2.36-9+deb12u8) but it is not going to be installed
 libc6-dev-amd64:i386 : Depends: libc6-dev:i386 (= 2.36-9+deb12u8) but it is not going to be installed
 libc6-dev-x32:i386 : Depends: libc6-dev:i386 (= 2.36-9+deb12u8) but it is not going to be installed
 libc6-x32:i386 : Depends: libc6:i386 (= 2.36-9+deb12u8) but it is not going to be installed
 libcc1-0:i386 : Depends: libc6:i386 (>= 2.3) but it is not going to be installed
 libctf-nobfd0:i386 : Depends: libc6:i386 (>= 2.8) but it is not going to be installed
 libctf0:i386 : Depends: libc6:i386 (>= 2.33) but it is not going to be installed
 libgcc-s1:i386 : Depends: libc6:i386 (>= 2.35) but it is not going to be installed
 libgmp10:i386 : Depends: libc6:i386 (>= 2.7) but it is not going to be installed
 libgomp1:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libgprofng0:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libisl23:i386 : Depends: libc6:i386 (>= 2.4) but it is not going to be installed
 libitm1:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libjansson4:i386 : Depends: libc6:i386 (>= 2.4) but it is not going to be installed
 libmpc3:i386 : Depends: libc6:i386 (>= 2.4) but it is not going to be installed
 libmpfr6:i386 : Depends: libc6:i386 (>= 2.4) but it is not going to be installed
 libquadmath0:i386 : Depends: libc6:i386 (>= 2.23) but it is not going to be installed
 libstdc++6:i386 : Depends: libc6:i386 (>= 2.36) but it is not going to be installed
 libubsan1:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 libzstd1:i386 : Depends: libc6:i386 (>= 2.34) but it is not going to be installed
 zlib1g:i386 : Depends: libc6:i386 (>= 2.4) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I’ve figure out from here, that ‘gcc-multilib’ is unavailable on ARM.

Maybe I am wrong, but I really can’t imagine that cross-compiling armhf on aarch64 is impossible. Rarely done, probably, but I don’t see a reason why it should be impossible.

Someone mentioned here the gcc doesn’t support ARMv6 properly on Debian. Which seems weird to me. Only Debian? They mentioned clang as alternative, which might be worth a try, since RIOT also has support for clang in the Makefiles.

Someone else said they made it somewhat work in a hacky way. Might be worth asking how.

In worst case, you can still run RIOT native in a docker container and just let QEMU emulate x86. It’s a little overhead though. A more typical setup is to cross compile armhf/aarch64 on x64.

Since you added sudo dpkg --add-architecture armhf on your Raspberry Pi, you should now be also able to run armhf binaries. So, from that point you should be ready to go to execute the native binary RIOT compiles, once you get it compiled.

Thank you very much for your guidance @citrullin.

Yes, I think I can use Docker to solve this problem in the worst case. But I’ll try to run the armf binaries to see if it could work.

I wish you a great weekend!