📜 ⬆️ ⬇️

Operation BATMAN: Adding Core Modules to Yocto on Intel Edison

I was recently asked how to add support for batman-adv in Yocto. As a result, correspondence ensued, which became the basis for this post. So how do you do this? Let's figure it out together.



Method one: do not reinvent the wheel


Before you do something yourself, it will not hurt to check whether someone else has already done the same thing. It is worth going through existing repositories, for example, to look here . I managed to find the necessary libnl here , but not BATMAN (now, though, it is already there, but I still want to continue the story). In such a situation, it is possible to make a polite request to the repository owner , for example, in our case, to the user with the nickname AlexT . The essence of the request is to add the kernel-module-batman-adv and batctl packages to the opkg repository . If luck is on your side, AlexT will do it, but you need to consider that it deals with this repository on a voluntary basis in your free time. Packages can be installed with a command like "opkg install".

Method two: compile on target device


This approach is a bit more complicated, it requires enough space in the Intel Edison rootfs. When applying it, you need to download and compile the necessary kernel-level code on the target device.
')

Method Three: Build in Yocto Environment


In order to use this method, you will need:


Yocto setting


Download “Yocto complete image” from here . After downloading, execute the following commands:


Build kernel-modules-batman-adv


Here the path to success lies through the following steps:


I changed the following configuration options:

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

Install batctl


In order to use BATMAN, you need to install and batctl. Suitable recipes for the BitBake build system can be found on the Internet. For example, I used this one , making some changes to it. Here is what I did:

 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 BATMAN 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 

Since libnl changed the installation path included in it, I need to patch the Makefile batctl. This is done like this:

 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 -MPI${STAGING_INC}/libnl3 CPPFLAGS += -D_GNU_SOURCE LDLIBS += -lm EOF 

After all these manipulations, to build batctl using bitbake, we need this command:

 bitbake batctl 

After the build is completed, the finished package can be found at build / tmp / deploy / ipk / core2-32 / batctl_2014.4.0-r0_core2-32.ipk. It can be installed using "opkg install" on Intel Edison with Yocto Linux installed

Testing on Intel Edison after installation


 root@edison:~/ # modprobe batman-adv 

If you want the module to load automatically, you should probably include 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:    BATMAN 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 Ethernet adapter:

 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) 

Results


This approach allows building modules into the Yocto Linux kernel on Intel Edison. Using it, you can include in a kernel that that is necessary for you, and not to depend on repositories. If your goal is BATMAN Advanced, then your Intel Edison is ready to work on the MESH network.

Source: https://habr.com/ru/post/267817/


All Articles