Building custom Intel Edison Images

After working with the Intel Edison board for a few weeks I was afraid to build my own images. I had relied on others’ images and have barely gotten by. For our capstone project we needed some specific modules installed so I realized it was time to step up to the challenge and make some custom images myself.

The Intel Edison Board Support Package documentation is a great resource for figuring out how to get started building the default Yocto image as well as how to start customizing those images using Yocto’s ‘Recipes’. This document can be found here: Intel Edison BSD.

After following the initial steps I ran into an error saying that the “do_Patch()” method failed and it stopped the build. I also so some error messages referring to Git and that I didn’t have a registered email address or user name. I fixed this using:

git config --global user.email "email@email.com"
git config --global user.username "name here"

After rebuilding immediately after entering these commands the build continues without issues until it was completed. No cleaning was need in between.

My next goal was to start learning how to add my own modules and libraries into the image. This is done using Yocto Recipes. As stated in the Intel Edison BSD, “In order to add a package to the image, you simply need to add it to the IMAGE_INSTALL variable. For example, if you wanted to add the lib PNG to the image, add the following line to the edison-src/device-software/meta-edison-distro/recipes-core/images/edison-image.bb file: IMAGE_INSTALL += “libpng” ”

To exclude packages you can either remove them from the include list or add them to the exclude list by saying something like: PACKAGE_EXCLUDE = “package1 package2”

If the package you want is not supplied by default you can add third party recipes as well. For my project I need OpenCV so I had to add that to my image. Luckily there is an example of just this towards the end of the Intel Edison BSD linked above. The basic steps for this were:

  • Add the Open Embedded git hub clone to your device-software directory
  • Checkout the ‘daisy ‘ branch
  • Tell bitbake to look for recipes in the new meta-oe/ layer. This is done by appending the location to the build/conf/bblayer.conf file.
  • After that you can now add any recipe that is provided by the new meta-oe layer to your image.
  • You may then add opencv to the image by simply adding to the IMAGE_INSTALL variable. You can do this in the build/conf/local.conf file. In this file you can add:
    IMAGE_INSTALL += "opencv opencv-dev opencv-apps"
    PACKAGECONFIG_pn-opencv="eigen jpeg libav png tiff v41"
  • This code will add opencv to the image but without gtk support.
  • Once this is saved run the following to rebuild the image:
    cd edison-src
    source poky/oe-init-build-env
    bitbake edison-image

At this point the image will contain opencv, but we aren’t done yet. We need to make sure to enable uvcvideo so that we can access the USB Webcam we are going to use as our input. After performing bitbake with opencv you are ready to customize the linux kernel. Type:

~/edison-src/build> bitbake virtual/kernel -c menuconfig

and then find and enable Device Drivers->Multimedia Support->Media USB Adapters. When you have Media USB Adapters highlighted press ‘y’ to enable it. You should then check to make sure the following are set using the search option and noticing their setting.

CONFIG_VIDEOBUF2_CORE=m
CONFIG_VIDEOBUF2_MEMOPS=m
CONFIG_VIDEOBUF2_VMALLOC=m
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=m
CONFIG_USB_VIDEO_CLASS_INPUT_EDEV=y

When configuration is completed, replace defconfig with .config that you just modified. Type:

~/edison-src/build> cp tmp/work/edison-poky-linux/linuxyocto/3.<PRESS TAB>/linux-edison-standardbuild/.config build/tmp/work/edison-poky-linux/linuxyocto/3.<PRESS TAB>/defconfig

We then bake the image again using:

~/edison-src/build> bitbake virtual/kernal -c configure -f -v
~/edison-src/build> bitbake edison-image

At this point we should have a working image, but there is one problem that I had noticed, the rootfs’ partition always seemed to fill up. In this step we will extend it from 512MB to 1312MB. First you need to access the file: edison-src/device-software/meta-edison-distro/recipes-bsp/u-boot/files/edison.env and change the size. The /home directory will shrink automatically as it only uses the remaining space. The second part of this is the roots image size itself, which is set in the: edison-src/device-software/meta-edison-distro/recipes-core/images/edison-image.bb and is also 512MB. Change the size of roots again then re-build the image again by typing ‘bitbake edison-image’.

Once the bitbake is done type:

~/edison-src> device-software/utils/flash/postBuild.sh

Then make sure you have ‘du-util’ which is needed to flash the edison.

~/edison-src> sudo apt-get install dfu-util

Now we need to flash twice to apply the new partition settings. First run:

~/edison-src> /build/toFlash/flashall.sh --recovery

and then complete the flash by excluding ‘–recovery’

~/edison-src> /build/toFlash/flashall.sh

You have successfully created a custom edison image with opencv and uvcvideo.
The next thing that I did was setup the edison by typing:

configure_edison --setup

and follow the instructions presented.

 

 

 

Leave a comment