Creating a Custom Linux Kernel for the Edison

[Edit – 12/20/15] – This guide is now out of date. A new walkthrough showing how to build a custom Linux image with the Yocto Project and Edison source code (release 2.1) can be found here.

Intel Edison image courtesy of SparkFun Electronics
Intel Edison image courtesy of SparkFun Electronics

If you want to add custom options to the Edison Linux kernel, you will need to compile it from source and enable the options you want. This tutorial is based on Intel’s Edison BSP User GuideVijayNooki‘s post in the Intel Forum, and hammock‘s post in the Intel Forum.

You will need to perform these steps on a Linux host machine with apt-get installed (e.g. Ubuntu).

[Edit – 05/07/15] Note that this will take a lot of hard drive space. Yocto recommends having at least 50 GB free. Thanks for pointing this out, wojak!

Download Image and Install Tools

First, download the latest Edison Yocto source code from here. Navigate to “Intel Edison OS Image and source files” and the file will be labeled something like “edison-src-rel1-maint-rel1-ww42-14.tgz.”

Install some tools:

[Edit – 02/05/15] If this is the first time you have installed git, you will want to configure it (where “you@example.com” and “Your Name” are your email and name. Ideally, these would be the email and name you used for something like GitHub):

[Edit – 02/05/15] You will also need libtool, if your version of Linux does not have it already installed (thanks, Scott Emery for these 2 tips!):

Perform Initial Build

Naviage to your Downloads directory (or wherever you downloaded the Edison source zip file):

Unzip and navigate to the Edison source directory:

Run the setup script:

Load the shell script in the poky/ directory to configure our build environment:

You will automatically be placed in the edison/source directory.  From there, run bitbake to create an initial Edison image:

This will take some time (potentially hours), as it needs to compile the whole kernel. Subsequent builds will go much faster.

Configure and Create New Kernel

Once the initial build is complete, open up menuconfig:

From here, you can select the options that you want your new kernel to have. Save and exit menuconfig. Copy the config file to the Edison build directory:

You can open up the new defconfig file if you want to verify your kernel features. After that, run bitbake again to create the new image:

Finally, run the post-build script to generate the toFlash/ directory:

Navigate to the toFlash/directory:

Flash Your Edison

If you want to flash your Edison with a new image, you can plug it into the USB port(s) and run:

This will flash your Edison with your new image! If you want to keep your user data, run the command with the keep-data option:

Or Modify Your Edison’s Kernel

However, if you want to try and loading in new kernel modules in your existing Edison image, you will need to mount the newly created Edison image on your host machine, extract the modules, and send them to your Edison. This might be risky. I make no promises.

The cool thing about this method is that you can add modules to other versions of Linux for the Edison, like Debian and its unofficial Edison image, Ubilinux.

Plug in your Edison, configure it on your network, and find it’s IP address. You will need it to copy files using scp.

Mount the image file:

Copy the 4 files found within to your Edison’s /boot directory (where XXX.XXX.XXX.XXX is your Edison’s IP address, e.g. 192.168.1.5):

Unmount the Edison image:

SSH into your Edison:

Remove the old Edison kernel modules and exit SSH:

Copy the new modules over to the Edison:

SSH into your Edison to reboot it:

This will kick you out of SSH. Wait a few minutes and then SSH back in:

Once logged in to your Edison, you can use modprobe to enable your new module:

And that’s it! You can check that the module got loaded with:

You might notice that you need to run modprobe every time you boot. To perform this step automatically, we can create a configure script that gets run at boot. Make sure you are still logged into your Edison and make a file in /etc/modprobe.d/

In that file, on a single line at the top, enter the command:

Save and exit (‘Ctrl-x’ and ‘y’ in nano). Reboot, and your module should be automatically loaded!

30 Responses

  1. Excellent step-by-step instructions on how to build your own Edison image. I started with a fresh Xubuntu install and ran into two errors which you might consider adding to your list of steps. Firstly, while performing the do_patch step of the linux-yocto/3.10.17+gitAUTOINC+6ad20f049a_c03195ed6e-r0 target it requires that your email and name be configured in git. So, after intalling git, users should run:

    git config –global user.email “you@example.com”
    git config –global user.name “Your Name”

    And secondly, the zeromq target requires the libtool package, so you might want to add libtool to the list of packages to install.

  2. Your CSS or whatnot breaks code examples, all ‘minus’ symbols are converted to dashes, and therefore if you are using an UTF-8 terminal, you get errors from copy & paste.
    e.g.


    $ bitbake linux-yocto –c menuconfig
    WARNING: Host distribution "Debian-7.8" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
    Loading cache: 100% |##############################################################################################################################################################################| ETA: 00:00:00
    Loaded 1288 entries from dependency cache.
    ERROR: Nothing PROVIDES '–c'

    or:

    $ git config –global user.email “you@example.com”
    error: key does not contain a section: –global

    1. Thanks for catching these. I didn’t have any issues copying-and-pasting from the code snippets, so there might be something wrong with my code plugin. I’ll take a look at it. The -global option needs to be –global, so I fixed that one.

  3. There is a missing ‘-‘ sign in one of the paths, the correct command is
    cp edison-src/build/tmp/work/edison-poky-linux/linux-yocto/3.10.17+gitAUTO*/linux-edison-standard-build/.config edison-src/device-software/meta-edison/recipes-kernel/linux/files/defconfig

  4. Thanks for this! It is very helpful. I was wondering, has anybody been successful at compiling and loading a 64bit kernel?

  5. Hi,
    I want to try and patch the edison kernel with realtime preemtion, but I’m not to sure at what point I should apply the patch. My assumption would be to apply the patch right after unpacking the edison source. Or is there a special way patches are handled with the edison kernel?
    Thanks in advance.

    1. Sorry I didn’t see this until now! Gmail started marking my WordPress notifications as spam for some reason.

      It has been a very long time since I’ve played with a real time kernel, so I honestly don’t know how a real time kernel would be made for the Edison. My guess would that you would need to create a special kernel from Yocto, but I could be way off. I recommend checking here and here for a start.

  6. I am stuck at this step “source poky/oe-init-build-env”. There is no poky directory in the source. There is only “meta-edison-intel” folder. How shall I solve this?

    1. It very well could be. It has been many months since I have played with Yocto, and they could have changed the build process. Does running the command source poky/oe-init-build-env fail?

      1. I took the older kernel src and it went fine till I reached the config file. I do not know where the config file is saved and from do I copy it. Also it would be great if you can do a tutorial for the newer yocto 2.1

  7. YOur tutorial does not work for YOcto 2.1 software release.First of all I would like to thank you for writing this tutorial but could you please guide us for the same with YOcto 2.1 software release.

    1. I am swamped with other projects for the time being, so I do not think I will be able to load a new Yocto build (at least in the near future). If you are running into issues with the latest Yocto, I recommend posting your questions to Intel’s Edison forums. You will get a much faster response there.

  8. From which directory should I run this “bitbake edison-image” the seconds time in the step “configure and create new kernel”

    1. I don’t believe you change directories once you are automatically placed in a new directory from running source poky/oe-init-build-env (I don’t remember which directory that is).

  9. I changed the spidev.c file and gave wrong syntax purposefully but still bitbake runs without any error. MY question is how do we compile the kernel sources? Does bitbake does that? If bitbake happened once then how do we recompile the kernel sources again?

  10. I am trying to get an SPI device work with the edison.It uses an ioctl call like this
    ioctl(int fd,command,arg). I want to modify this ioctl function to toggle a gpio pin (which I want to use as a custom defined chip/slave select pin).SO could you tell me where will I find this ioctl call in yocto?

  11. I am getting this error when I do postbuild.sh
    cp: cannot stat ‘/home/ranjan/Downloads/edisonsrc2/build/tmp/deploy/images/edison/vmlinux’: No such file or directory

  12. I am trying to change the printk and pr_info statements so that I can see a corresponding change in the dmesg output but I cant change any of the items that are getting printed from the kernel.

    1. Hi Sriranjan/Shawn

      Sriranjan, I think I am having the same issues as you when I am trying to recompile Yocto.

      I had to modify the steps above as follows
      tar xvf edison-src.tgz
      cd edison-src/meta-intel-edison
      sh ./setup.sh
      I am confused after this.
      Shawn says to Load the shell script in the poky/ directory to configure the build environment.
      My poky directory is located at /home/root/edison-src/out/linux32/poky
      When I try to run the source (source poky/oe-init-build-env)
      I get the following error
      Error: The build directory (BUILDDIR) must be set!
      Have you the same issues, Did you have any success?

      Rosemarie

Leave a Reply