6 Replies Latest reply on Nov 26, 2014 12:58 PM by AlexT_Intel

    Building an linux image and modify the kernel -  Answered


      The last days, I got several requests about how to build an image and how to customize the kernel. Instead of writing the same text again and again, I want to make a dedicated public post.




      Intel provides two basic images for the Intel Galileo, the so-called SPI image and the Full image (or SD Card image). Both can be downloaded and work out-of-the-box. But to really get the best out of your Galileo – and to get additional hardware supported – you should know how to build an image and customize the kernel.



      You need a “Host Computer” or “Build Computer”. This can be your desktop computer or laptop. It must run on Linux, have at least 70GB free disk space and 2 GB RAM.

      But I'm on Windows/MacOS!


      No Problem! You can use a Virtual Machine (VM). A VM allows you to run another operating system on your computer like a regular program. Some of them are free to use, some of them are not. A free one will fit our needs.


      After installing a VM program, you have to create a virtual machine and install a Linux “in it”. The program will ask you about what kind of VM image you want to create. Make sure, this VM image can use at least 90 GB disk space and provides 2 GB RAM.

      Note: The term VM image here does not refer to an image for the Galileo. Both have nothing in common.


      One problem with an VM is: The Linux in the VM has often no connection to your Windows/MacOS and Hardware. Sometimes you can “share” and access devices like a smart card readers on the Linux, sometimes this will fail. But you need a way to transfer the generated Galileo image to a smart card (and the generated files can be big). What usually works is to setup a “shared folder”. This is a folder or directory writable and readable from the Linux in the VM and on Windows/MacOs at the same time.


      (Re-)Build a Linux image


      I wan't cover this in detail. There are two documents you should read:

      The official Intel Quark BSP Build Guild (Intel® Quark BSP Build Guide) and a blog post from Sergey Kiselev (Intel Galileo - Building Linux Image - Malinov Family Web Presence). The second one is much easier to follow, and it also contains the explanation for the “famous” LSB image or also called “image-sdk” image. But you should really look at both, starting with Intel's one.


      I only want to add some hints:

      • After you download and extract the Build Support Package, you get a really long directory name like “Board_Support_Package_Sources_for_Intel_Quark_v0.7.5”. Rename this directory before doing anything else, for example to “bsp0.7.5”. Or you might get in trouble later.
      • Sergeys Blog entry contains a bug: Calling setup.sh without any parameter is wrong. It must be:
        setup.sh -e layer
      • Setup.sh might throws errors about missing programs like “git” or “diffstat”. Just install them using the package manager of your Linux, for example (on Ubuntu):
        sudo apt-get install git
      • After setup, build the SPI image first using “bitbake image-spi”. If it runs without any problems, your setup is correct. 
      • Building image-full (the Full SD card image) or image-sdk (the LSB image) for the first time needs hours, if not a whole day! (That is the reason, why you should test the setup with image-spi).
      • Later builds will require much less time - as long as you don't delete any caches.
      • Some basic customizations to the image and the build process can be done in <BSP dir>/meta-clanton_v0.7.5/conf/local.conf. Explanations about the entries can be found in <BSP dir>/meta-clanton_v0.7.5/poky/meta-yocto/conf/local.conf.sample


      Customize the kernel


      If you are able to build your own image, you are ready to customize the kernel. You need to customize the kernel, if you want to use specific hardware that is not supported by the kernel in your current images. Typical use case: You have an older or non-Intel Wlan card.


      Warning: Don't customize the kernel “for fun”. You can break things easily.


      Go to the directory <BSP dir>/meta-clanton_v0.7.5. Always call:

      source poky/oe-init-build-env yocto_build

      before doing anything else.


      You should be in the yocto_build directory now, so run:

      bitbake virtual/kernelconfig -c menuconfig


      A text based GUI will show up. Here you can modify the kernel – enable or disable kernel modules.


      Rule of thumb: Never disable kernel modules you didn't enable before, or you might crash your kernel.


      After you modified the kernel, don't forget to save the config at the end. Now you are ready to create a new kernel, just create the image as usual:

      bitbake <your-image-to-create>


      Which kernel module do I need for my Wlan card?


      There are plenty of kernel modules. Which you need depends on hardware to add. In case of a Wlan card, the used networking chip matters often. Check the technical specs of the card. If it says, it uses a Broadcom chip, you need to enable one of the Broadcom kernel modules. If you are unsure, use Google&Co. Then, you use the search feature of the kernelconfig GUI to locate the module.

        • 1. Re: Building an linux image and modify the kernel -  Answered

          Nice writeup Alexander. A couple of comments if you don't mind :-)

          <...> can be done in <BSP dir>/meta-clanton_v0.7.5/conf/local.conf.

          Looks like there's yocto_build directory missing in that path, that's the default build dir created by setup.sh



          bitbake virtual/kernelconfig -c menuconfig

          may not work on some of the Linux distros, e.g. openSUSE. As far as I understood researching on the issue, that's caused by a sort of a bug/deficiency in the Yocto (Openembedded really) code which uses wrong ncurses library (from the host rather then the cross-compiled sysroot and when they differ too much, the problem manifests itself). It was fixed in later OpenEmbedded (and subsequently Yocto) versions, but not the one on which all the BSPs are based so far.


          It looks like that - you type the above command, it starts processing recipes, but then when you expect a window to be open with the menuconfig GUI, the window opens and immediately closes.


          To work around that use the following sequence of commands:

          bitbake virtual/kernelconfig -c devshell

          # the devshell window will open with all environment set for kernel compilation and there you can run menuconfig alternative, nconfig

          > make nconfig

          1 of 1 people found this helpful
          • 2. Re: Building an linux image and modify the kernel -  Answered

            Hi Alexander,

                 Probably this is a very late reply... When I follow Sergey's instruction I noticed that bug of setup.sh and I found your post here. But follow

            ./setup.sh -e layer

                 does not working either. The error information as follows:

            setup.sh: line 73: setup/gitsetup.py: Permission denied

                 I have Python 2.7.6 on my Ubuntu and other dependencies are installed. (I checked the reference of Intel BSP Build Guide)

                 I was thinking if the permission has some problem. When I tend to add "executable" to both setup.sh and gitsetup.py via

            sudo chmod -v+x setup.sh

                 it said changed successfully. But when I use "ls -l" to check the permission I still have no "executable".


                 Could you provide some suggestion or solution on this issue?




            • 3. Re: Building an linux image and modify the kernel -  Answered

              The issue is not that the script isn't executed but rather that within the script another script can't be executed.

              • 4. Re: Building an linux image and modify the kernel -  Answered

                How does the output of "ls -alF setup/" look like and under which user do you run the setup.sh? Indeed it looks like there's somethgin wrong with your permissions.

                • 5. Re: Building an linux image and modify the kernel -  Answered

                  Don't know what reason I could run that script now. But here is the output of your command:


                  total 14

                  drwxrwxrwx 1 root root    0 Feb 28  2014 ./

                  drwxrwxrwx 1 root root 4096 Nov 23 19:25 ../

                  -rwxrwxrwx 1 root root 4731 Feb 28  2014 gitsetup.py*

                  -rwxrwxrwx 1 root root   91 Feb 28  2014 meta-intel.cfg*

                  -rwxrwxrwx 1 root root  117 Feb 28  2014 meta-oe.cfg*

                  -rwxrwxrwx 1 root root   79 Feb 28  2014 poky.cfg*

                  • 6. Re: Building an linux image and modify the kernel -  Answered

                    Interesting indeed why it's changed

                    The permission look ok in the sense that you should be able to run the script, though a bit unusual, 777 is rarely used. It looks like someone or something is messing up those for you.


                    I, for one, have the following for the same files:


                    usr@lnx:setup> l

                    total 28

                    drwxr-sr-x  2 usr users 4096 May 22  2014 ./

                    drwxr-sr-x 11 usr users 4096 Oct 21 20:04 ../

                    -rwxr-xr-x  1 usr users 4731 May 22  2014 gitsetup.py*

                    -rw-r--r--  1 usr users   91 May 22  2014 meta-intel.cfg

                    -rw-r--r--  1 usr users  117 May 22  2014 meta-oe.cfg

                    -rw-r--r--  1 usr users   79 May 22  2014 poky.cfg