Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

dbaba/vagrant-edison-build

Repository files navigation

vagrant-edison-build

GitHub release License MIT

This vagrant stuff helps you to

  1. build kernel modules (.ko files) running on the intel's iotdk complete image (poky-edison) so that you can copy them into your edison without replacing entire image
  2. create an image file and mount it on the guest filesystem so that you can place arbitrary files inside the image

Prerequisites

  1. Vagrant 1.8.1+
  2. VirtualBox 5+
  3. 4GiB RAM and 2 CPU cores for a vagrant box ... You can modify it in Vagrantfile
  4. High-speed Internet connection

Tested Edison Image Version

VM memory and CPU allocation

By default, 4GiB memory and 2 cpu cores are allocated. You can modify vb.memory for RAM size and vb.cpus for core size in Vagrantfile.

  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    # vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "4096"
    # Customize the cpu size on the VM:
    vb.cpus = 2
  end

How to build kernel module

Clone the project and launch it with Vagrant.

(host)   $ git clone https://github.com/dbaba/vagrant-edison-build.git
(host)   $ cd vagrant-edison-build

Copy or create your kernel modules to meta-ext-modules.

The module directory structure looks like:

  meta-ext-modules
  `- conf
  `- your-module-1 ... for .bb/.bbappend files
  | `- files ... for Makefile and source code
  `- your-module-2 ... for .bb/.bbappend files
  :  `- files ... for Makefile and source code
  :

Please make sure that your modules include valid .bb and/or .bbappend files. You can look into an example module named my-hello-mod as a reference.

After placing your modules, you can start a vagrant box with the following command.

(host)   $ vagrant up

setup.sh is performed during the provisioning process. After the provisioning finishes, you can ssh to the vagrant box.

(host)   $ vagrant ssh

Now you're ready to build your module.

(vagrant)$ cd ${HOME}/edison/edison-src/out/linux64
(vagrant)$ source poky/oe-init-build-env
(vagrant)$ time bitbake my-hello-mod

The bitbake target name to build your module is equal to the .bb file name without the version and .bb extension, i.e. my-hello-mod comes from my-hello-mod_1.0.0.bb.

The time command prior to bitbake is not mandatory, just show the elapsed time to create the module. The first build will take a long time (approx. 1 hour) because of building the underlying dependencies as well.

Finally, you can get your own .ko file at ./tmp/sysroots/edison/lib/modules/3.10.17-poky-edison+/extra/.

(vagrant)$ ls -la ./tmp/sysroots/edison/lib/modules/3.10.17-poky-edison+/extra/
total 716
drwxr-xr-x 2 vagrant vagrant   4096 Feb  4 06:17 .
drwxr-xr-x 3 vagrant vagrant   4096 Feb  4 06:17 ..
-rw-r--r-- 3 vagrant vagrant  46006 Feb  4 06:17 my_hello_mod.ko

Tips

The module name must NOT contain characters other than [a-z0-9.+-]. Otherwise, you'll get the following error:

*** Error: Package name  contains illegal characters, (other than [a-z0-9.+-])

How to build image

Clone the project and launch it with Vagrant.

(host)   $ git clone https://github.com/dbaba/vagrant-edison-build.git
(host)   $ cd vagrant-edison-build
(host)   $ vagrant up

SSH to the vagrant box.

(host)   $ vagrant ssh

You can list the config values by running the command.

(vagrant)$ ./config_get.sh CONFIG_USB_NET_CDCETHER
~/edison/edison-src/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files ~
[defconfig]
1207:CONFIG_USB_NET_CDCETHER=m

You can configure the kernel config as you like.

(vagrant)$ ./config_set.sh CONFIG_USB_NET_CDCETHER m
~/edison/edison-src/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files ~
==== BEFORE ===
[defconfig]
1207:# CONFIG_USB_NET_CDCETHER is not set
==== AFTER ===
[defconfig]
1207:CONFIG_USB_NET_CDCETHER=m

You can reset the kernel config modifications by the following command.

(vagrant)$ ./config_reset.sh
~/edison/edison-src/meta-intel-edison/meta-intel-edison-bsp/recipes-kernel/linux/files ~
Resetting configuration
[defconfig]
Done

Now time to build. Run the following command.

(vagrant)$ source ./build.sh

This will take a couple of hours or more depending on your network bandwidth and allocated hardware resources.

It took 2 hours and 10 minutes for the first build with 2.8 GHz Intel Core i7 and 16GiB RAM (4GiB RAM and 2 cpus were allocated for VM). The second build after adding 3 modules was finished around 15 minutes though.

The shell script takes you to /mnt/edison where the rootfs is expanded.

The command output looks like as follows.

~/edison/edison-src ~

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    core-image-sato
    meta-toolchain
    adt-installer
    meta-ide-support

You can also run generated qemu images with a command like 'runqemu qemux86'
Start building at Wed Oct 28 14:16:04 UTC 2015

(snip)

Terminated building at Wed Oct 28 17:00:33 UTC 2015
~
Done. You're now able to explore the rootfs from here! => /mnt/edison
Copy files to /vagrant, and you can get them from the host machine without SCP.

Then try to find a kernel module file on the directory, cdc_ether.ko for instance.

(vagrant)$ sudo find -name "cdc_ether.ko"
./lib/modules/3.10.17-poky-edison+/kernel/drivers/net/usb/cdc_ether.ko

See HOWTO: make your driver load automatically at poky boot for installing the kernel files.

Where are bitbaked files?

You can find the rootfs and other files in ${HOME}/edison/edison-src/out/linux64/build/tmp/deploy/images/edison/.

How to use the previous release source code?

Edit setup.sh and modify SOURCE_URL, then vagrant destroy -f; vagrant up.

Where is the bitbake logs?

You can fine the log at ${HOME}/edison/edison-src/out/linux64/build/tmp/log/cooker/edison/yyyyMMddhhmmss.log, where yyyyMMddhhmmss is a timestamp.

Helpful Resources

wget and POODLE issue

The preinstalled version of wget is too old to handle non-SSLv3 connection, e.g. downloading files from download.xdk.intel.com where SSLv3 is disabled for fixing POODLE don't work at all. In fact, I got the following error while building the kernel.

ERROR: Fetcher failure: Fetch command failed with exit code 4, output:
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Unable to establish SSL connection.`

In order to avoid the error, I added a simple wrapper script fetch_cmd using curl, as well as wget, which is able to handle such the connection, and modify FETCHCMD_wget variable in the bitbake.conf. The script uses curl only when wget fails.

Distribution Packaging

tar --exclude=.DS_Store --exclude=vagrant-edison-build.tgz --exclude=.vagrant --exclude=.git -zcf vagrant-edison-build.tgz .

License

Revision History

  • 2.0.0
    • ** NOTICE ** This release only supports Intel® Edison Module Firmware Software Release 2.1
    • Fix an issue where bitbake failed to download xdk-daemon-0.0.35.tar.bz2 with wget command
    • Add an instruction and template stuff for building custom kernel modules
  • 1.0.1
    • renamed
  • 1.0.0
    • Initial Release