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:
Yocto setup
build kernel-modules-batman-adv
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/