Click here to Skip to main content
15,881,715 members
Articles / Internet of Things
Article

Intel® Edison - adding kernel modules to Yocto - example "Batman"

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
8 Oct 2015CPOL2 min read 8.2K  
Intel® Edison - adding kernel modules to Yocto - example "Batman"

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Recently I was asked how to add batman-adv to Yocto. I put together my answer email and it turned out slightly lengthy - looked like it should go into a blog ;-)

Option 1 - kindly ask others to do the work

Check availability in existing repos like http://repo.opkg.net/edison/. In our concrete example we can find the prerequesite libnl in http://repo.opkg.net/edison/repo/core2-32/ but no b.a.t.m.a.n* [by now it has been added to the repo - still keeping this blog]. Hence we could kindly ask e.g. AlexT on https://communities.intel.com/thread/55692?start=0&tstart=0 whether he could add the packages "kernel-module-batman-adv" as well as "batctl" to http://repo.opkg.net/edison/. If you are lucky he might do but it's voluntary work on his side.

The packages can be installed via "opkg install <package name>"

Option 2 - compile on target

Slightly more difficult - and requires sufficient free space on Intel(R) Edison rootfs. Install kernel sources on the target and compile modules on the target

Option 3 - build in Yocto build environment

requirements

  • Linux x64 host system (e.g. Ubuntu* 12.04 [have heard about issues running Yocto* on 14.04 - maybe resolved by now], Fedora* 20, ...)
  • min 50 GB free disk space (at least if you want to compile the whole Yocto image)

Yocto setup

build kernel-modules-batman-adv

  • bitbake -c menuconfig virtual/kernel; this will open a new window running Linux kernel config for Edison
  • configure batman: within the menuconfig session configure the b.a.t.m.a.n* options you want to see within the Networking Support > Networking Options > BATMAN category
  • cp build/tmp/work/edison-poky-linux/linux-yocto/<your current kernel>/linux-edison-standard-build/.config device-software/meta-edison/recipes-kernel/linux/files/defconfig
  • bitbake -c compile_kernelmodules virtual/kernel
  • in case you require the complete modules tarball: bitbake -c deploy virtual/kernel – you'd find the tarball under build/tmp/deploy/images/edison geschrieben
  • otherwise: opkg install build/tmp/deploy/ipk/edison/kernel-module-batman-adv_<version>.ipk on your target

The configs I changed:

< # CONFIG_BATMAN_ADV is not set
---
> CONFIG_BATMAN_ADV=m
> CONFIG_BATMAN_ADV_BLA=y
> CONFIG_BATMAN_ADV_DAT=y
> CONFIG_BATMAN_ADV_NC=y
> # CONFIG_BATMAN_ADV_DEBUG is not set

batctl

In order to make use of batman you should also install batctl. On the web you can find bitbake recipes. I used and adopted https://github.com/openembedded/openembedded/blob/master/recipes/batctl/batctl.inc as per below:

mkdir -p device-software/meta-edison-distro/recipes-support/batman/

cat > device-software/meta-edison-distro/recipes-support/batman/batctl_2014.4.0.bb <<EOF

DESCRIPTION = "Control application for B.A.T.M.A.N. routing protocol kernel module for multi-hop ad-hoc mesh networks."
HOMEPAGE = "http://www.open-mesh.net/"
SECTION = "console/network"
PRIORITY = "optional"

LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://../license-destdir/${PN}/generic_GPLv2;md5=801f80980d171dd6425610833a22dbe6"

RDEPENDS_${PN} = "kernel-module-batman-adv"
DEPENDS = "libnl"


SRC_URI = "http://downloads.open-mesh.net/batman/stable/sources/batctl/batctl-${PV}.tar.gz\
     file://patch.patch"
SRC_URI[md5sum] = "f3a14565699313258ee6ba3de783eb0a"
SRC_URI[sha256sum] = "77509ed70232ebc0b73e2fa9471ae13b12d6547d167dda0a82f7a7fad7252c36"

EXTRA_OEMAKE = 'STAGING_INC="${STAGING_INC}"'

do_compile() {
  oe_runmake
}

do_install() {
  install -d ${D}${bindir}
  install -m 0755 batctl ${D}${bindir}
}
EOF

As libnl has changed its include installation path I had to patch the Makefile of batctl. The patch as per below:

mkdir -p device-software/meta-edison-distro/recipes-support/batman/files
cat > device-software/meta-edison-distro/recipes-support/batman/files/patch.patch <<EOF

--- a/Makefile  2015-02-27 09:10:45.768409932 +0100
+++ b/Makefile  2015-02-27 09:11:32.710554513 +0100
@@ -29,7 +29,7 @@
MANPAGE = man/batctl.8

 # batctl flags and options
-CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP
+CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP –I${STAGING_INC}/libnl3
CPPFLAGS += -D_GNU_SOURCE
LDLIBS += -lm
EOF

After that one can bitbake batctl with:

bitbake batctl

After completion you'll find the package in build/tmp/deploy/ipk/core2-32/batctl_2014.4.0-r0_core2-32.ipk. It can be directly installed via "opkg install" on Intel(R) Edison running Yocto* Linux

Test on Intel(R) Edison after installation

root@edison:~/ # modprobe batman-adv

If you want to have the module auto-loaded you'd probably want to enter it in /etc/modules-load.d/

root@edison:~/ # modinfo batman-adv
filename:       /lib/modules/3.10.17-poky-edison+/kernel/net/batman-adv/batman-adv.ko
version:        2013.2.0
description:    B.A.T.M.A.N. advanced
author:         Marek Lindner <lindner_marek@yahoo.de>, Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
license:        GPL
srcversion:     66711903985B5CAAE0DAF30
depends:       
intree:         Y
vermagic:       3.10.17-poky-edison+ SMP preempt mod_unload ATOM

Using a USB eth dongle:

root@edison:~/ # batctl if add enp0s17u1
root@edison:~/ # batctl if
enp0s17u1: active
root@edison:~/ # batctl s
     tx: 6
     tx_bytes: 468
     tx_dropped: 0
     rx: 1
     rx_bytes: 42
     forward: 0
     forward_bytes: 0
     mgmt_tx: 60
     mgmt_tx_bytes: 2428
     mgmt_rx: 0
     mgmt_rx_bytes: 0
     tt_request_tx: 0
     tt_request_rx: 0
     tt_response_tx: 0
     tt_response_rx: 0
     tt_roam_adv_tx: 0
     tt_roam_adv_rx: 0
     dat_get_tx: 0
     dat_get_rx: 0
     dat_put_tx: 0
     dat_put_rx: 0
     dat_cached_reply_tx: 0
     nc_code: 0
     nc_code_bytes: 0
     nc_recode: 0
     nc_recode_bytes: 0
     nc_buffer: 0
     nc_decode: 0
     nc_decode_bytes: 0
     nc_decode_failed: 0
     nc_sniffed: 0
# ifconfig bat0
bat0      Link encap:Ethernet  HWaddr 52:78:97:51:ba:9d  
          inet6 addr: fe80::5078:97ff:fe51:ba9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST DYNAMIC  MTU:1500  Metric:1
          RX packets:1 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:42 (42.0 B)  TX bytes:468 (468.0 B)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
This is a Organisation

42 members

Comments and Discussions

 
-- There are no messages in this forum --