1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id="workflow">
<title>Using NFV Access SDKs</title>
<para>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.</para>
<itemizedlist>
<listitem>
<para><literal>inteld1521/sdk/enea-glibc-x86_64-enea-image-virtualization-host-sdk-corei7-64-toolchain-7.0.sh</literal>
- for host applications.</para>
</listitem>
<listitem>
<para><literal>qemux86-64/sdk/enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.sh</literal>
- for guest applications.</para>
</listitem>
</itemizedlist>
<section id="install-crosscomp">
<title>Installing the Cross-Compilation Toolchain</title>
<para>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:</para>
<orderedlist>
<listitem>
<para><programlisting>$ ./enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.sh</programlisting>When
prompted, select to install the toolchain in the desired directory,
referred to as <literal><sdkdir></literal>. </para>
<para>A default path where the toolchain will be installed will be
shown in the prompt. The installer unpacks the environment setup
script in <literal><sdkdir></literal> and the toolchain under
<literal><sdkdir>/sysroots</literal>.</para>
<note>
<para>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 <literal>$PATH</literal> variable of
the first one.</para>
</note>
</listitem>
<listitem>
<para>Setup the toolchain environment for your target by sourcing the
environment-setup script. Example: <programlisting>$ source <sdkdir>/environment-setup-core2-64-enea-linux</programlisting></para>
</listitem>
</orderedlist>
</section>
<section id="crosscomp-apps">
<title>Cross-Compiling Applications from Command Line</title>
<para>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.</para>
<orderedlist>
<listitem>
<para>Create a Makefile for your application. Example: a simple
Makefile and application:</para>
<programlisting>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;
}</programlisting>
</listitem>
<listitem>
<para>Run <command>make</command> to cross-compile your application
according to the environment set up:</para>
<programlisting>$ make</programlisting>
</listitem>
<listitem>
<para>Deploy the helloworld program to your target and run it:</para>
<programlisting># ./helloworld
hello world</programlisting>
</listitem>
</orderedlist>
</section>
<section id="crosscomp-kern-mod">
<title>Cross-Compiling Kernel Modules</title>
<para>Before cross-compiling kernle modules, you need to make sure the
installed toolchain includes the kernel source tree, which should be
available at:
<literal><sdkdir>/sysroots/<targetarch>-enea-linux/usr/src/kernel</literal>.</para>
<para>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.</para>
<orderedlist>
<listitem>
<para>Create a Makefile for the kernel module. Example: a simple
Makefile and kernel module:</para>
<programlisting>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");</programlisting>
</listitem>
<listitem>
<para>Run <command>make</command> to cross-compile your kernel module
according to the environment set up:</para>
<programlisting>$ make</programlisting>
</listitem>
<listitem>
<para>Deploy the kernel module <literal>hello.ko</literal> to your
target and install/remove it:</para>
<programlisting># insmod hello.ko
# rmmod hello.ko
# dmesg
[...] Loading hello module...
[...] Hello, world
[...] Goodbye, world</programlisting>
</listitem>
</orderedlist>
</section>
<section id="deploy-artifacts">
<title>Deploying your artifacts</title>
<orderedlist>
<listitem>
<para>Deploying on host</para>
<para>You can use <literal>ssh</literal> to deploy your artifacts on
the host target. For this you will need a network connection to the
target and to use <literal>scp</literal> to copy to the desired
location.</para>
</listitem>
<listitem>
<para>Deploying on guest</para>
<para>You can deploy your artifacts onto the guest VM running on the
target in two steps:</para>
<itemizedlist>
<listitem>
<para>Deploy the artifacts onto the target by using the method
described above or any other method.</para>
</listitem>
<listitem>
<para>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.</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</section>
</chapter>
|