Saturday, March 13, 2010

More about OpenEmbedded

I have been using OpenEmbedded to develop the beagleboard. Here is a very good "tutorial" teaching people how to make your own image.

The tutorial ask you create another image in receipts/images. That's the location bitbake can find receipts from.

helloworld-console-image.bb
require console-image.bb
ANGSTROM_EXTRA_INSTALL += " helloworld "
export IMAGE_BASENAME = "helloworld-console-image"
----------------------

This bb file include the console-image first, and add the helloworld.bb. The exported image is called "helloworld-console-image". So, when you do bitbake, you will need the
"helloworld-console-image", that's the bb file in the image folder. The helloworld.bb file can be found in the receipt directory.

The helloworld.bb is the receipt to make the helloworld user app. The install part of the helloworld.bb is like the following:


helloworld.bb
do_install () {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}/
# /bin/init is on purpose, it is tried
# after /sbin/init and /etc/init

# so if a sysvinit is installed, it will be
# used instead of helloworld

install -d ${D}${base_bindir}
ln -sf ${bindir}/helloworld ${D}${base_bindir}/init
}
----------------------

The install -d command will check the directory. If the directory does not exists, it creates one. ${D} is your destination, in this case, the bitbake will put it in tmp first. ${bindir} is where you want to put your user app. It's /usr/bin by default. "-m" changes the user app' attribute to rwxr-x-r-x in this case. "base_bindir" is /bin.

The last line create a link from the /usr/bin/helloworld to /bin/init. Some distribution of linux use /bin/init as initial program. You may change this to your own distribution.

A good article talking about init can be found here and here.
A discussion about start a program can be found here.



No comments:

Post a Comment