I have begun to work on a Beaglebone Black for a school project, and we have been using buildroot in order to build our custom images. Right now we are working with a basic 5.3 image.
We use builroot-2022.02.9.
For the image, we go from a beaglebone_defconfig using a make beaglebone_defconfig
we use a custom "Kernel version" in buildroot -5.3 version. And in the Toolchain menu, in the Kernel Headers we choose it to be the same as the kernel being built, and in Custom kernel headers series we choose 5.3.x.
The objective is to cross-compile a C program which will utilize the LEDs of the Beaglebone, but I am running tests with only a helloworld program and it doesn't work.
Also, the helloworld file is transfered using tftp and I see it in my directory using ls, and I've added the executable flag, just to tell you that it exists on my beaglebone.
Here's the issue:
When I run the helloworld file on my beaglebone after I've compiled it on my VM - , I get this error message :
-sh: ./helloworld: not found
At first, I thought I was using the wrong compiler, so I've used many. I can list :
arm-linux-gnueabihf
arm-linux-gnueabi
And I've tried many versions of those two toolchains. The prompt I give is simply:
arm-linux-gnueabihf-gcc helloworld.c –o helloworld
So I've done my research, and I've found that the message -sh: ./helloworld: not found
was missleading - see the verified answer on this post : Why can't I run custom application on my Beaglebone board?
So it is a dynamic linker problem, which in my case for the file when I look for it using readelf -a
is: /lib/ld-linux.so.3.
So, considering that it wasn't being found, I proceeded to search it on the /lib/ directory on my Beagleboard.
Turns out I don't even have it, not any single version of it.
My guess is that I should include it in my configuration when customizing it with buildroot, but I don't know how to set it and which one to choose being new on the topic.
Thus, what I need to do is use the correct cross-toolchain (which uses the same C library version) for the rootfs I am using or build a new rootfs with the same toolchain.
In buildroot, the C-library used when I go to the toolchain menu is uClibc-ng
,so I've tried to set it to glibc
but all I get is an error during the make process.
I found where the adapted toolchain compiler is :
~/Documents/buildroot/output/host/bin/arm-buildroot-linux-uclibcgnueabihf-gcc
The command line is then very simple:
~/Documents/buildroot/output/host/bin/arm-buildroot-linux-uclibcgnueabihf-gcc -o hello hello.c
You can obviously add it to PATH environment variable.