Update as of August 8th, 2015: You’ll need to update your u-boot if you’re building from scratch or using the newly provided images. See the post here with instructions on how to do it.
This is one of the more common questions I receive. Maybe you’ve read our recent Yocto Fido post and want more information. It’s not a short or easy question to answer. The Yocto “Mega-Manual” is 453 pages long and the Bitbake User Manual is 55 pages long. If you really want to be an expert, you’ll need to read through both of those very thoroughly, but for now how about we create our own getting-started guide here.
Here are some quick cheat sheets I use to remember commands or reference various variable names. Bookmark these, they’ll help.
You’re going to need lots of disk space(100G+), a rather decent build machine, and I recommend Ubuntu. For the purposes of this guide, I’m going to assume you’re on Ubuntu although you should have no problems with Fedora, openSUSE, CentOS, or Debian. You’ll need the following packages installed on your system:
~$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \ build-essential chrpath socat libsdl1.2-dev xterm
Now for a basic image. Lets first initialize the Freescale community board support package.
~$ mkdir ~/fido ~$ cd ~/fido ~/fido$ repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b fido ~/fido$ repo sync
This will pull in all the Yocto Fido branch recipes, configurations, and everything you need to build a Yocto image for our boards. We tend to give out an image called core-image-sato, it has a nice X11 desktop people are used to. So let’s build that, I’ll get more in-depth into how the core-image-sato image recipe works later.
For the sabre-lite, nitrogen6x, nitrogen6x_max boards and all their variants, the MACHINE name is nitrogen6x. For the nitrogen6x-lite, the MACHINE name is nitrogen6x-lite. For the Nitrogen6_SoloX, the MACHINE name is nitrogen6sx. For the purposes of the example, I’ll build for the nitrogen6x, replace that according to whatever you’re using.
~$ cd ~/fido ~/fido$ MACHINE=nitrogen6x . setup-environment core-image-sato (accept the license agreement) ~/fido/core-image-sato$ bitbake core-image-sato
Let that run, it will build the whole image and deploy a sdcard file to ~/fido/core-image-sato/tmp/deploy/images/nitrogen6x/core-image-sato-nitrogen6x.sdcard. Once this is done, you can write this sdcard file to a sdcard and it will boot the core-image-sato image on your board.
Write Image to SD Card
To write a sdcard on Linux we use a utility called dd. Sometimes I receive general confusion as to exactly what this command does. Some people wonder if they need to format the sdcard first or if I left out other steps. The answer here is simply no. All dd does is write bits from one location to another, converting for block size differences if applicable. In fact, dd probably just stands for “covert and copy”, but the C compiler uses the “cc” command so they opted to use “dd”. The core-image-sato-nitrogen6x.sdcard file includes all partition table information and is a complete image file, although we use the .sdcard file extension and not .img.
The core-image-sato recipe just expands upon the core-image class and that just expands upon the image class which defines the image creation class to include image_types. There you will see how the rootfs ext3 file is created, among other image deployment types. Also our machine configurations include Freescale’s image creation class image_types_fsl. There you will see how the .sdcard file is created and how you can modify certain global variables to change the size of the rootfs or boot partitions. Also, for those who’ve used the mkfs.ext3 command before, no there isn’t a -d option, but Yocto’s build process includes a different mkfs executable which does include this option. So, you couldn’t achieve the same results by running these commands by hand.
To dd the image file to a sdcard, first plugin and mount your sdcard to your computer. It will mount itself somewhere in /dev/sdX where X is the letter it mounts to. I have two hard drives and a DVD drive that take up /dev/sda /dev/sdb and /dev/sdc, so when I plugin sdcards Linux mounts my sdcards at /dev/sdd. Tail your syslog(run command “tail -f /var/log/syslog” then plugin your sdcard) to find out where your sdcard mounted and replace the letter X appropriately in the following instructions.
~$ cd ~/fido/core-image-sato/tmp/deploy/images/nitrogen6x/ ~/fido/core-image-sato/tmp/deploy/images/nitrogen6x$ sudo umount /dev/sdX* ~/fido/core-image-sato/tmp/deploy/images/nitrogen6x$ sudo dd if=core-image-sato-nitrogen6x.sdcard of=/dev/sdX bs=1M
So now you’ve built and deployed an image to your device. Lets drill down deeper into the details, look at exactly what just happened, add some things to the image, modify existing elements of the image, and create our own recipes. I cover this in the next blog post.