Run a C language program compiled on Ubuntu on a Raspberry Pi Zero. That's all.
Host: Ubuntu 20.04.1 <Virtual Box 6.1 <Windows 10 Target: Raspberry Pi Zero WH
$ sudo apt install g++-arm-linux-gnueabi
I need gcc this time, but I may use it in the future, so install g ++. It also installs gcc and whatever you need.
There is also an article that installs g ++-arm-linux-gnueabihf
as a cross-compiler for Raspberry Pi, but this does not support Zero CPUs (ARMv6 series).
The program to be built this time before
hogehoge.c
#include <stdio.h>
int main()
{
printf("Hogehoge Cross!!\n");
return 0;
}
It ’s the first time, so it ’s like this. Build this like this.
$ arm-linux-gnueabi-gcc -march=armv6 hogehoge.c -o hogehoge_armv6
Specify the ARM architecture with -march =
.
Since Raspberry Pi Zero is ARMv6 series, I specified it as such, but in this program
All worked with armv4
, armv5t
, armv5te
, armv5tej
, armv6
.
The one with armv7
was displayed as" Segmentation fault "and didn't work.
I wrote "It worked" above, but I copied the built hogehoge_armv6 file to an appropriate directory on the Raspberry Pi Zero,
$ ./hogehoge_armv6
Hogehoge Cross!!
It worked like this.
It's a simple program, but it worked surprisingly easily.
I wrote the following article
Recommended Posts