Using NFV Access SDKs Enea NFV Access comes with two different toolchains, one for developing applications for the host and one for applications running in the guest VM. Each is wrapped together with an environment-setup script into a shell archive and is available under the Download section on portal.enea.com. They have self explanatory names. inteld1521/sdk/enea-glibc-x86_64-enea-image-virtualization-host-sdk-corei7-64-toolchain-7.0.sh - for host applications. qemux86-64/sdk/enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.sh - for guest applications.
Installing the Cross-Compilation Toolchain Before cross-compiling applications for your target, you need to install the corresponding toolchain on your workstation. To do that, simply run the installer and follow the steps included with it: $ ./enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.shWhen prompted, select to install the toolchain in the desired directory, referred to as <sdkdir>. A default path where the toolchain will be installed will be shown in the prompt. The installer unpacks the environment setup script in <sdkdir> and the toolchain under <sdkdir>/sysroots. Choose a unique directory for each toolchain. Installing a second toolchain of any type in the same directory as a previously installed one will break the $PATH variable of the first one. Setup the toolchain environment for your target by sourcing the environment-setup script. Example: $ source <sdkdir>/environment-setup-core2-64-enea-linux
Cross-Compiling Applications from Command Line Once the environment-setup script is sourced, you can make your applications as per usual and get them compiled for your target. Below you see how to cross-compile from command line. Create a Makefile for your application. Example: a simple Makefile and application: helloworld:helloworld.o $(CC) -o helloworld helloworld.o clean: rm -f *.o helloworld #include <stdio.h> int main(void) { printf("Hello World\n"); return 0; } Run make to cross-compile your application according to the environment set up: $ make Deploy the helloworld program to your target and run it: # ./helloworld hello world
Cross-Compiling Kernel Modules Before cross-compiling kernle modules, you need to make sure the installed toolchain includes the kernel source tree, which should be available at: <sdkdir>/sysroots/<targetarch>-enea-linux/usr/src/kernel. Once the environment-setup script is sourced, you can make your kernel modules as usual and get them compiled for your target. Below you see how to cross-compile a kernel module. Create a Makefile for the kernel module. Example: a simple Makefile and kernel module: obj-m := hello.o PWD := $(shell pwd) KERNEL_SRC := <full path to kernel source tree> all: scripts $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" modules scripts: $(MAKE) -C $(KERNEL_SRC) scripts clean: $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" clean #include <linux/module.h> /* Needed by all modules */ #include <linux/kernel.h> /* Needed for KERN_INFO */ #include <linux/init.h> /* Needed for the macros */ static int __init hello_start(void) { printk(KERN_INFO "Loading hello module...\n"); printk(KERN_INFO "Hello, world\n"); return 0; } static void __exit hello_end(void) { printk(KERN_INFO "Goodbye, world\n"); } module_init(hello_start); module_exit(hello_end); MODULE_LICENSE("GPL"); Run make to cross-compile your kernel module according to the environment set up: $ make Deploy the kernel module hello.ko to your target and install/remove it: # insmod hello.ko # rmmod hello.ko # dmesg [...] Loading hello module... [...] Hello, world [...] Goodbye, world
Deploying your artifacts Deploying on host You can use ssh to deploy your artifacts on the host target. For this you will need a network connection to the target and to use scp to copy to the desired location. Deploying on guest You can deploy your artifacts onto the guest VM running on the target in two steps: Deploy the artifacts onto the target by using the method described above or any other method. On the target, copy the artifacts to the guest rootfs. For this, you will need to shut down the guest VM, mount the file system on the target, copy your files onto it, unmount it and then restart the guest VM as usual.