November 12th, 2008
Creating Custom Images for the Gumstix
Lets say you need to setup 5, 10, or maybe 1000s of gumstix with the same root fs. None of the stock images have what you need and many have many items you don’t need. You could of course, start with one of the minimal images (say gumstix-minimal-image) and then, once it is installed, use ipkg to install all the packages you need and in a final step pull the image back out of flash (I’m not sure how you would do that, or if the gumstix would even allow it. You could do it using one of the boot from SD/MMC/CF images, and then take the tree and turn it into a JFFS2 images once it was setup). Of course, when you need to update the image, you have to repeat the process of starting from a stock binary, installing everything (hope you kept good notes and that nothing changed) and pulling the image.
A better way to handle this is with your very own bitbake recipe file for your custom image. This is pretty simple to set up and works very well whether you use on board flash or from SD/MMC/CF. You can also tweak the kernel as well as configuration in the root directory as needed.
This setup assume you have setup your build environment according to this documentation. Once you can successfully built one of the stock images you are ready to start your own.
The Procedure
First, create a user.collection directory with sub directories
cd ~/gumstix/gumstix-oe/ mkdir -p user.collection/packages/images
Next copy the basic image from the com.gumstix.collection tree to your tree with a new name:
cd ~/gumstix/gumstix-oe/user.collection/packages/images cp ~/gumstix/gumstix-oe/com.gumstix.collection/packages/images/gumstix-basic-image.bb ./gumstix-custom-image.bb
Now, we must edit this file to a) make sure it references the minimal image properly and b) add all the packages we don’t want to have to install by hand. Lines in bold were edited.
# my custom gumstix image
require ${GUMSTIXBRANCH}/packages/images/gumstix-minimal-image.bb
#Note the change in the line above to reference the gumstix tree.
#This way if the basic image changes, you will automatically get
#those changes.
#Add all the package names here you want included. The trailing
#slash, with NO SPACES after it is important. That is the line
#continuation character that tells the script to append the next
#line also.
IMAGE_INSTALL += ” \
cron \
ntp \
ntpdate \
boa \
motd \
www-content \
mtd-utils \
openvpn \
sshfs-fuse \
perl \
perl-module-exporter-heavy \
perl-module-fcntl \
perl-module-time-hires \
perl-module-cgi \
perl-module-cgi-carp \
perl-module-overload \
perl-module-file-spec-unix \
perl-module-carp-heavy \
perl-module-file-basename \
perl-module-io-file \
perl-module-io \
perl-module-posix \
perl-module-scalar-util \
perl-module-list-util \
mplayer \
alsa-utils \
alsa-lib \
“
At this point, you should be able to change directory to your top level gumstix directory and build the image. I choose to completely delete the previous build tmp dir since I’ve had mixed results running bitbake again after changes. I’m sure there is a better way, but I have a huge 8 core work station, so a full build only takes less than an hour.
cd ~/gumstix/gumstix-oe/ rm -rf tmp cd ~/gumstix/ bitbake gumstix-custom-image
Go watch the Colbert Report or Daily Show for the last week or two using your spare cycles. When it finishes, use the normal procedure to install the images.
Finding Packages
One way to find packages is to use ipkg on a working gumstix.
ipkg update ipkg list | grep -i whatever
If you don’t want to use the gumstix (because, lets say you have trashed the root image and can’t get into it, just because it is slow and a PIA to have wired up an on, or you don’t have a net board so you can’t actually use ipk update effectivly) you can use a similar approach on your workstation.
cd ~/gumstix/gumstix-oe/ find | grep -e \.bb$ | grep -i whatever
or
cd ~/gumstix/gumstix-oe/ find ./ -iname *whatever*.bb -print
The second one, using find, is probably quote-un-quote better, but I prefer the more crude grep expression. It somehow makes more since. Either one is probably fine. Look through the bb files that are returned. Use the file name, minus any version numbers or extensions in the image bb file. For example
./org.openembedded.snapshot/packages/openssh/openssh_4.0p1.bb
becomes
openssh
Pitfalls
The most common problem I run into is misnamed packages in the image bb file. Use the method above to ensure that you do not have any misnamed packages. When in doubt, remove all the packages and try building. If it works, add one or two back in, repeat.
Other things to watch out for are mis-formatting. As I said earlier, if packages are placed on separate lines, then the last (and I mean very last) character on the line must be a “\” otherwise the parser will probably freak out and think you are missing a closing quote. Oh, and make sure the quote is there too.
If you attempt to rebuild using bitbake without deleting the tmp directory, and things get weird, try again after deleting it. It sucks, and I’m sure there is a better way, but the best way to be sure is to nuke the site from orbit (rm -rf).