Yocto is an interesting beast. And when did SW developers come up with the cooking references? Seriously, when I was messing with compiling Paranoid Android for my Samsung Galaxy Tab 2 7.0 the build environment was littered with lunch, brunch, etc. The one set of commands that really through me for a loop was: mka bacon. I spent weeks trying to figure out what mka did in this bash script.
Tangent over.
Yocto is all about recipes and uses a tool called bitbake to build your custom operating system. See, there is the cooking theme again.
I am going off on another tangent here to say that Yocto isn't what is actually built. The OS you end up building is called Poky and then there is another codename for the specific release of Poky you download and build. Not going to lie, I have no idea what the codename is for what I've built for the CarHUD. I don't think it matters; in the end we're going to end up with a pretty kickass embedded OS that will be lean and mean (all the while creating a wasteland of extra space on an 8GB SD Card).
Another excellent bit of news is that I didn't have to figure out how to get Yocto to build an OS for the Raspberry Pi. The following fine people have done a fantastic job of doing it for us.
- John Willis (Raspberry Pi Layer Maintainer)
- Andrei Gherzan (Raspberry Pi Layer Maintainer)
- Jack Mitchell (Pimp-my-Pi blog, the guy who's tutorial I followed, but not to the letter)
You also need to have a ton of harddrive space. The Yocto Project documentation says up to 50GB. According to the super awesome command: ($ is the command line prompt)
$ du -ch | grep totalI have 11GB in the directory I downloaded Yocto into and have subsequently built numerous times.
If you just tried that command in Windows and it didn't work, I'm here to tell you that you have to do this on a Linux box with a newer distribution installed. You could possibly use a Virtual Machine for this, but your mileage may vary.
Let's install the needed system dependencies in order for this to work. Navigate to http://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-project-qs.html and find the Packages section and install the ones for your system.
We'll be using the method detailed here: http://www.pimpmypi.com/blog/blogPost.php?blogPostID=7. We should all thank Jack Mitchell for his tutorial.
First up, open up the terminal. If you aren't a command line junkie, I feel a little sorry for you. It is a great place to hang out.
In the terminal go to the directory you want to download Yocto. I have a folder in my home directory called Projects. I forgot to use lower case when I created the folder and for some reason decided to follow the non-standard Linux way of using all lower case. Way to go Ubuntu, way to go...
$ cd; mkdir ~/Projects; cd ~/ProjectsNow that we're in the Projects directory, we're going to pull down a copy of the Yocto build system and recipes using Git. Git is a version control system. If you don't know what version control systems are, they allow you to keep track of modifications to files. Git is relatively new to me, I've been a Subversion user for a long time. If you don't have Git on your computer, install it with your distros' package manager.
Let's clone!
$ git clone git://git.yoctoproject.org/pokyThe result of the cloning produced a directory called poky inside of Projects, we need to go there:
$ cd pokyAnyone else thinking of Gumby?
Once inside the poky directory, you can do the following to see the build structure. The following is output from my current setup:
$ ls -g -oYou can see all sorts of meta directories. These contain the recipes, think of them as sections of a cookbook.
total 84
drwxrwxr-x 7 4096 Jun 9 21:29 bitbake
drwxrwxr-x 9 4096 Jun 9 21:29 build
drwxrwxr-x 8 4096 Jun 25 22:40 carhud_os_build
drwxrwxr-x 14 4096 Jun 9 21:29 documentation
-rw-rw-r-- 1 545 May 22 18:34 LICENSE
drwxrwxr-x 22 4096 Jun 9 21:29 meta
drwxrwxr-x 7 4096 Jun 23 21:09 meta-carhud
drwxrwxr-x 5 4096 Jun 9 21:29 meta-hob
drwxr-xr-x 17 4096 Jun 9 21:29 meta-openembedded
drwxr-xr-x 14 4096 Jun 25 20:33 meta-raspberrypi
drwxrwxr-x 7 4096 Jun 9 21:29 meta-skeleton
drwxrwxr-x 7 4096 Jun 9 21:29 meta-yocto
drwxrwxr-x 9 4096 Jun 9 21:29 meta-yocto-bsp
-rwxrwxr-x 1 1592 May 22 18:34 oe-init-build-env
-rw-rw-r-- 1 2038 May 22 18:34 README
-rw-rw-r-- 1 17436 May 22 18:34 README.hardware
drwxrwxr-x 10 4096 Jun 16 21:06 scripts
You'll see that I have the Raspberry Pi recipes downloaded, which you will now need to do.
$ git clone https://github.com/djwillis/meta-raspberrypi.gitWe also need the Open-Embedded recipes:
$ git clone git://git.openembedded.org/meta-openembeddedThe Pimp My Pi tutorial has you check out a specific revision of Poky and the Raspberry Pi layers, but I didn't do this and went ahead with the latest. I'm living on the edge.
Now we get to start the basis for our CarHUD image. Do the following in the terminal:
$ source oe-init-build-env carhud_os_buildThis command will set up the build environment for us and will put us into a directory called carhud_os_build. You can verify this with the pwd command:
$ source oe-init-build-env carhud_os_buildNow on to the configuration, we need to get into the conf directory.
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-toolchain-sdk
adt-installer
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86'
$ cd confWe're going to edit layer.conf to do the first customization of our build.
$ nano layer.confInside this file, change the number of threads equal to the total number of threads your computer can handle. Replace x with your number
BB_NUMBER_THREADS = "x"
PARALLEL_MAKE = "-j x"You also need to make the Machine a raspberrypi. Find the section of machines and comment the last one in the list and add your own
MACHINE ?= "raspberrypi"I ended up changing the package system to use Debian packages. You can choose to modify this if you want.
PACKAGE_CLASSES ?= "package_deb"At the bottom of the file, we need to add a line to whitelist a license.
LICENSE_FLAGS_WHITELIST = "commercial"Save the file by hitting Ctrl-x, pressing y, and hitting Enter to confirm and then exit.
Now lets edit bblayers.conf:
nano bblayers.confLets add our layers inside the BBLAYERS variable below meta-yocto-bsp and above the closing ", replace <username> with your username:
/home/<username>/Projects/poky/meta-raspberrypi \Above the BBLAYERS variable, add the following two variables:
/home/<username>/Projects/poky/meta-openembedded/meta-oe \
PREFERRED_PROVIDER_jpeg = "jpeg"Save the file by hitting Ctrl-x, pressing y, and hitting Enter to confirm and then exit.
PREFEERED_PROVIDER_jpeg-native = "jpeg-native"
Let's go back up to our carhud_os_directory:
$ cd ..[Insert the music at the beginning of 2001: A Space Odyssey]
Now is the time to build a minimal image for the Raspberry Pi. Once we get this building successfully, it'll be used as our basis for everything else.
$ bitbake rpi-basic-imageWhen this completes, flash the image to an SD Card. The image is located inside your carhud_os_build directory:
/home/<username>/Projects/poky/carhud_os_build/tmp/deploy/images/Flash the .rpi-sdimg using normal methods for flashing your Raspberry Pi's SD Card.
The build is barebones to the max. The SSH Server is running, so you can log into the system that way or over the UART lines. Username for the build is root and there is no password.
I want to thanks Jack Mitchell for his tutorial that we're using as the basis for the CarHUD OS build.
It will be some time before I come back with a post about Yocto. I'm on vacation in a week and I am still working on getting everything into Yocto that I want there for the embedded OS. The next post most likely will be about some ideas for the projector.
No comments:
Post a Comment