I have an Apalis i.MX8 and an Ixora carrier board. I installed the minimal Linux image using the Toradex Easy Installer.
I didn’t found a clear/proper documentation to help me cross-compile C/C++ programs for the embedded system.
In fact, I have downloaded the cross-compiler from ARM website but I don’t have a proper sysroot (the compiler can’t find stdio.h). The /usr/include is empty (on both an archive I downloaded from Toradex, the OS image I guess, and in the embedded system file system).
Can someone explain me how to set up the toolchain so I can build C/C++ applications for the Apalis i.MX8 running the minimal Linux image ?
Linux apalis-imx8-06548561 5.4.193-5.7.0+git.f78299297185 #1 SMP PREEMPT Mon Jul 11 14:42:03 UTC 2022 aarch64 GNU/Linux
Hello @embeddedmz ,
It seems that the article that I gave to you will need some reworking. In the meantime ,here you can find the image you are looking for:
This way is nowhere recommended, but you may like it on Ubuntu to cross compile avoiding the need to build commonish -dev libraries from sources. Those dev libs may be installed via apt
From now your Eclipse new Empty Project->Cross GCC project should be buildable when you specify in project settings C/C++ Build → Cross Settings → Prefix = aarch64-linux-gnu-
Thank you for your answer. But usually, how people develop programs for the Toradex minimal Linux kernel ? Until now, I only tested .NET Core but I do need to have some programs on my system (pppd for example).
Do they use Yocto to build an image that contains the programs/libraries they need ?
Toradex docs are outdated/missing for the Apalis i.MX8. I know they want people to use the containers but we are going to choose a SoM that doesn’t have enough memory for Torizon and that’s why I’m trying to understand how to build libraries/programs for a minimalist Linux system. I don’t know Yocto, I’ve played a bit with buildroot in the past.
Can’t say I’m doing things right way, but yes, Yocto is the way to build target image with pppd and other required components. Once you know component list it is ± just a matter of creating bb or bbappend file for image with required packages listed in IMAGE_INSTALL. Lazy way you may try editing layers/meta-toradex-demos/recipes-images/images/tdx-reference-minimal-image.bb and add there missing packages to IMAGE_INSTALL. If you don’t know whole set of packages, you may look in yocto build/deploy/ipk folder for required ipk’s. Some of rootfs-missing packages still may be built. Ones, which are not present in deploy/ipk can be built with bitbake your_package. Then you scp those packages to target and opkg install them. Not very convenien but OK way for packages with no or short dependency list. Don’t try to install something like python the same way, it’s better to bitbake image.
For C/C++ I’m using eclipse, proper debugger setup scp’s executable / library and other files I specify to target and uses gdb for debug as usual. Of course gdbserver should be present on target.
Once your executables are done, you still need to get in touch with Yocto creating your own recipes. Or… take rootfs *.xz file from your TEZI files set, uncompress it, add your files and compress back rootfs to *.xz :-).
Is there a non-dispersed, non-outdated, clear and straightforward documentation that explains how to create a minimal Linux image with Yocto for the Apalis i.MX8? Yocto seems to me very complex and initimidating. I don’t know where to start.
In addition to the link that @Edward sent you, you may be interested in having a look at our webinars: Toradex | Embedded Computing Solutions - Webinars. There you can find some hands-on presentations that show you how to build your custom image.
curl is just an example, I don’t really need it. In fact, I need ppp (commands pon/poff), bash (I don’t know if it’s feasible) and maybe some I2C tools (not mandatory).
If it is easy to do, can someone give me the procedure to add packages to the image ? (conf files to modify + bitbake command).
Would any of these options work for you? Also, when you want to add a new package, it’s always worth checking if the recipes are already available. You can check this with: bitbake-layers show-recipes. This command will list all the recipes available. You can browse https://layers.openembedded.org/layerindex/branch/master/layers/ for any missing recipes.
Can you please tell us how did you try to install it?
Your original question was, as subject suggests, about cross-compile. My advice with apt install package:arm64 was only about -dev packages, which may be used to provide static compile libs and header files needed to cross-compile on your Ubuntu amd64 machine. Of course apt on Ubuntu can’t be used to install to your target machine rootfs, this is exactly what you see, either curl for amd64 or curl for arm64, but not both simultaneously. But -dev packages for both amd64 and arm64 can be installed, link libs and headers get installed to arm64 gcc folders, so no problems with them.
I have a “Apalis-iMX8_Reference-Minimal-Image.rootfs.tar.xz” how can I install it ? I have already copied that file on a thumb drive, launched the Toradex Easy Installer, but the “mass storage” icon is still gray after I plugged the thumb drive.
Otherwise, I succeeded in cross-compiling a simple hello world program, this is what I have done :
I used this article How to setup environment for Embedded Linux application development | Toradex Developer Center to download an ARM compiler and this one Hello World application on Embedded Linux (C/C++) | Toradex Developer Center to compile the program. I used this path as a sysroot (compiler --sysroot argument, by the way this argument is not recognized by the aarch64-none-linux-gnu-gcc compiler : -mfloat-abi=hard) : /home/[user]/oe-core/build/tmp/work/apalis_imx8-tdx-linux/tdx-reference-minimal-image/1.0-r0/recipe-sysroot. Is this the official sysroot of the built image ?
I have one last request: is there a document that explains how to configure CMake to use the new compiler and sysroot ?
Hi @embeddedmz! I’m glad we could help you succeed in this task.
All the files that will be used on the final image will be inside the deploy folder. On the tmp you’ll have some temporary files that are used during the build process and may be deleted or changed once you run bitbake again.
It was to know if I could use CMake to cross-compile a C/C++ program with the ARM compiler and the sysroot I found in tmp. We often program in C# .NET Core, I just tested that it works (SDK downloaded from Microsoft site, I saw that the ‘dotnet’ package is not available when I ran the bitbake command) and we can generate an image that contains the software packages we need so it’s not really important for the moment.