INTEL EDISON - ADDING KERNEL MODULES TO YOCTO - EXAMPLE BATMAN

INTEL EDISON - ADDING KERNEL MODULES TO YOCTO - EXAMPLE BATMAN

Promotion | 07 Aug 2015

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 - may be resolved by now], Fedora* 20, ...)
  • min 50 GB free disk space (at least if you want to compile the whole Yocto image)

Yocto setup

  • download "Yocto complete image" from http://www.intel.com/support/edison/sb/CS-035180.htm
  • tar xvf edison-src*.tgz 
  • cd edison-src
  • device-software/setup.sh
  • source poky/oe-init-build-env

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:
1 < # CONFIG_BATMAN_ADV is not set

2 ---

3 > CONFIG_BATMAN_ADV=m

4 > CONFIG_BATMAN_ADV_BLA=y

5 > CONFIG_BATMAN_ADV_DAT=y

6 > CONFIG_BATMAN_ADV_NC=y

7 > # 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:

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

02
 

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

04
 

05 DESCRIPTION = "Control application for B.A.T.M.A.N. routing protocol kernel module for multi-hop ad-hoc mesh networks."

06 HOMEPAGE = "http://www.open-mesh.net/"

07 SECTION = "console/network"

08 PRIORITY = "optional"

09
 

10 LICENSE = "GPLv2+"

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

12
 

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

14 DEPENDS = "libnl"

15
 

16
 

17 SRC_URI = "http://downloads.open-mesh.net/batman/stable/sources/batctl/batctl-${PV}.tar.gz\

18 file://patch.patch"

19 SRC_URI[md5sum] = "f3a14565699313258ee6ba3de783eb0a"

20 SRC_URI[sha256sum] = "77509ed70232ebc0b73e2fa9471ae13b12d6547d167dda0a82f7a7fad7252c36"

21
 

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

23
 

24 do_compile() {

25  oe_runmake

26 }

27
 

28 do_install() {

29 install -d ${D}${bindir}

30 install -m 0755 batctl ${D}${bindir}

31 }

32 EOF

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

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

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

03
 

04 --- a/Makefile  2015-02-27 09:10:45.768409932 +0100

05 +++ b/Makefile  2015-02-27 09:11:32.710554513 +0100

06 @@ -29,7 +29,7 @@

07 MANPAGE = man/batctl.8

08
 

09  # batctl flags and options

10 -CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP

11 +CFLAGS += -Wall -W -std=gnu99 -fno-strict-aliasing -MD -MP –I${STAGING_INC}/libnl3

12 CPPFLAGS += -D_GNU_SOURCE

13 LDLIBS += -lm

14 EOF
After that one can bitbake batctl with: 
1 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

1 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/ 

01 root@edison:~/ # modinfo batman-adv

02 filename:       /lib/modules/3.10.17-poky-edison+/kernel/net/batman-adv/batman-adv.ko

03 version:        2013.2.0

04 description:    B.A.T.M.A.N. advanced

05 author:         Marek Lindner <lindner_marek@yahoo.de>, Simon Wunderlich <siwu@hrz.tu-chemnitz.de>

06 license:        GPL

07 srcversion:     66711903985B5CAAE0DAF30

08 depends:      

09 intree:         Y

10 vermagic:       3.10.17-poky-edison+ SMP preempt mod_unload ATOM

Using a USB eth dongle:

01 root@edison:~/ # batctl if add enp0s17u1

02 root@edison:~/ # batctl if

03 enp0s17u1: active

04 root@edison:~/ # batctl s

05 tx: 6

06 tx_bytes: 468

07 tx_dropped: 0

08  rx: 1

09 rx_bytes: 42

10 forward: 0
    

11  forward_bytes: 0

12   mgmt_tx: 60

13 mgmt_tx_bytes: 2428

14  mgmt_rx: 0

15  mgmt_rx_bytes: 0

16  tt_request_tx: 0

17 tt_request_rx: 0

18  tt_response_tx: 0

19  tt_response_rx: 0

20  tt_roam_adv_tx: 0

21  tt_roam_adv_rx: 0

22 dat_get_tx: 0

23 dat_get_rx: 0

24 dat_put_tx: 0

25  dat_put_rx: 0

26 dat_cached_reply_tx: 0

27  nc_code: 0

28 nc_code_bytes: 0

29 nc_recode: 0

30 nc_recode_bytes: 0

31 nc_buffer: 0

32 nc_decode: 0

33 nc_decode_bytes: 0

34  nc_decode_failed: 0

35  nc_sniffed: 0

1 # ifconfig bat0

2 bat0      Link encap:Ethernet  HWaddr 52:78:97:51:ba:9d 

3 inet6 addr: fe80::5078:97ff:fe51:ba9d/64 Scope:Link
         

4  UP BROADCAST RUNNING MULTICAST DYNAMIC  MTU:1500  Metric:1
        

5  RX packets:1 errors:0 dropped:0 overruns:0 frame:0
        

6   TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
       

7  collisions:0 txqueuelen:0
        

8  RX bytes:42 (42.0 B)  TX bytes:468 (468.0 B)
        

For more such intel IoT resources and tools from Intel, please visit the Intel® Developer Zone

Source: https://software.intel.com/en-us/blogs/2015/02/27/intel-edison-adding-kernel-modules-to-yocto-example-batman/

logo
Promotion

Digit caters to the largest community of tech buyers, users and enthusiasts in India. The all new Digit in continues the legacy of Thinkdigit.com as one of the largest portals in India committed to technology users and buyers. Digit is also one of the most trusted names when it comes to technology reviews and buying advice and is home to the Digit Test Lab, India's most proficient center for testing and reviewing technology products.

We are about leadership-the 9.9 kind! Building a leading media company out of India.And,grooming new leaders for this promising industry.