We’re going to be walking through how to prepare a Yocto build for use with our i.MX6 products, specifically the TS-4900 which we have a special build recipe for. A build recipe is a friendly term to describe the scripts and environment variables required to build a Yocto distribution. There are many other build recipes available which work on a more generic level as well, so this guide can be applied generally as well. This guide is both an echo and extension of the TS-4900 Build Yocto Distribution wiki page. I’ll be mostly echoing (aka copy/pasting) the steps, but I’ll also add a few notes along the way. I’m going to assume you’ve landed here because you’re using search terms that make you at least familiar with what Yocto is and the terminology that surrounds a basic software development environment. If you have questions, I’m happy to try and answer them in the comments that follow.
Let’s take a quick look at an example C++ program which reads CPU temperature and controls an LED using sysfs. This example is a bit specific in that it’s only been tested on our NXP i.MX6 powered TS-4900 or TS-7970 running Yocto Linux, but the principles could be applied to other embedded systems as well. If you’re interested in the nitty gritty details about sysfs, take a look at The sysfs Filesystem by Patrick Mochel. Suffice it to say for our purposes, sysfs makes it easy for us to interact with system hardware using plain text files located in the /sys/ directory. The file to control the red LED is /sys/class/leds/red-led/brightness. The file to read the CPU temperature is /sys/class/thermal/thermal_zone0/temp. If we want to turn the red LED on, we simply write a ’1’ to the file, and not surprisingly, writing a ’0’ will turn it off. If you’ve booted up your TS-4900 or TS-7970, you can see this by running the shell commands: