Build an Application program for Linux on i.MX6q SABRE SD

Hello all,
I have been able to boot the i.MX6 board into Linux following the comprehensive guide written by Robert Nelson. Thanks.

So far, so good. Now, I’d like to build some C programs, beginning with “hello world” then moving on to some hardware manipulation. This immediately exposes how sketchy my understanding is of the whole infrastructure around board support packages, device trees, libraries for C/C++ programs etc.

The NXP documentation is helpful up to a point. By following instructions I was able to build a bootable SD card, but they stop short of giving an example of how to build an application program.

I am generally quite a quick study, but there is sooooo much information out there about specific build systems (Yocto, Buildroot) that I am drowning in a whole lot of detail that I’m not ready for yet, or that isn’t relevant to what I want to do.

I would love to find a guide that explained enough concepts for me to see enough of the big picture to be doing more than just dumbly following along and then, ideally, lead me though an example that I can get working on this board. I’d be happy to pay for a book that did a good job, but I’ve not really found anything that seems a good match yet. Suggestions are welcome.

Robert’s directions for the bootable SD card were accurate and easy to follow, so I’m wondering if he would be willing to make a follow-up article explaining the steps required to cross compile (on Linux, presumably) a simple program for this board?

Along the way, it would be excellent to have some discussion/explanation of how the toolchain fits together. What libraries are required, and why? How do things work with different versions of Linux on the PC and embedded system? Is Eclipse a good system for embedded development? If so, any pointers? Command line is fine too…

I realize it’s a large subject, but a bit of a kickstart would be very much appreciated.

Hi @DougM

So one of the very big advantages of running Debian (or Ubuntu) on this board, instead of Yocto/Buildroot/etc… Is Native compiling… Why mess around with configuring a perfect cross compiler, libraries, etc? When instead you can just “apt” install any library, dependency or runtime that your specific application needs to build or operate.

So, my first answer for how to “cross compile”, is more of a question: Why would you want to even “cross compile”?

Since we are running Debian, every tool (99.9%) that can be installed with apt on your current “x86” based Debian system is also available on the “armhf” based Debian system… Thus if you can build your “application” on “x86” you can build it exactly the same on “armhf” or “risc-v” or “sparc”…

So back to the question, so usually the number one reason to cross compile is “speed or space”… But you can also pick up a PI4 with 8GB of ram for a reasonable price. :wink:

But, Debian has this solved too… Right now is your i.MX6q board running Debian 9 or Debian 10? Go to and install either Debian 9 or Debian 10 to match your i.MX6q’s system on your ultra fast x86 system. Once you get your x86 system up and running, enable the “armhf” architecture in dpkg, such that your “x86” host will be able to install the exact same *.deb packages found on the armhf system.

So on my Debian system (Bullseye/Sid):

sudo dpkg --add-architecture armhf
sudo apt update

Then just install the armhf version of the libraries you need an build against them.

Once you built your “armhf” based package on your “x86” just copy it right over… The exact same libraries are installed on your “armhf” board…

In Debian, there is very little difference between “x86” and “armhf”…

It’s just another tool, most of the time I use nano, gedit, and meld… VSCode is growing in popularity… Tools come and go, just use what ever works for you…


Hi @RobertCNelson

Thanks for the reply. Maybe I used the term “cross compile” inaccurately. What I am attempting to do is write and compile programs on my Ubuntu 18.04 system x86_64 and then run them on a proprietary system running a slimmed-down Linux 3.0.35 running on a i.MX6. I don’t know which, if any, distribution it was assembled from. We have very little support from the manufacturer of this system we are working with. Its purpose is to control some fairly specialized hardware, which we want to interface a device of ours with. Let’s call it “BoardX”.

As an interim/practice project I grabbed the i.MX6 SABRE SD board from Digikey to play with. The idea was that I could monkey around without any risk of “bricking” our more expensive special-purpose board. I don’t have access to source code for everything that’s on BoardX, let alone complete documentation for it. (Maybe it would never be bricked, but I might get it into a very stuck state…)

I used the term cross-compile because I’m planning to compile on one architecture, to run on a different one, but I realize that it’s maybe not the best, or correct, term when they are running from essentially the same source code. (at least with respect to Ubuntu and Debian).

My background is not in embedded Linux. I’m really an optical physicist who’s done a bit of everything from silicon design, to FPGA to MCU code, and PCB design (Such is life in a small company), plus I’ve used Linux (as a user) since the days of installation from floppies!. So, I started by following the NXP documentation, and then various other rat-holes. A lot of that information is aimed at whole system configuration and kernel building. I am now thinking that I should just simplify and figure out what the minimal set of tools I need to build executables for BoardX. I’ve got a bootable SD card working for Linux 3.14.52 on the SABRE SD, so I am thinking that might be a reasonable test system.

I’ve added the armhf architecture, as you suggested. Does this mean that now I can simply tell gcc to build for arm? Something like this?


CC -o main.out hello_world.c

How are the arm libraries found to link to? Is that handled magically with the appropriate (cross)compiler flags? Are there pitfalls to avoid around versioning?

As you can tell, I’m flailing at a fairly fundamental stage, and I’m reading through some large books as my homework! Any help to get the first trivial example going is much appreciated.