summaryrefslogtreecommitdiffstats
path: root/doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml')
-rw-r--r--doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml203
1 files changed, 203 insertions, 0 deletions
diff --git a/doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml b/doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml
new file mode 100644
index 0000000..18602a1
--- /dev/null
+++ b/doc/book-enea-nfv-access-guide/doc/using_nfv_access_sdks.xml
@@ -0,0 +1,203 @@
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4<chapter id="workflow">
5 <title>Using NFV Access SDKs</title>
6
7 <para>Enea NFV Access comes with two different toolchains, one for
8 developing applications for the host and one for applications running in the
9 guest VM. Each is wrapped together with an environment-setup script into a
10 shell archive and is available under the Download section on
11 portal.enea.com. They have self explanatory names.</para>
12
13 <itemizedlist>
14 <listitem>
15 <para><literal>inteld1521/sdk/enea-glibc-x86_64-enea-image-virtualization-host-sdk-corei7-64-toolchain-7.0.sh</literal>
16 - for host applications.</para>
17 </listitem>
18
19 <listitem>
20 <para><literal>qemux86-64/sdk/enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.sh</literal>
21 - for guest applications.</para>
22 </listitem>
23 </itemizedlist>
24
25 <section id="install-crosscomp">
26 <title>Installing the Cross-Compilation Toolchain</title>
27
28 <para>Before cross-compiling applications for your target, you need to
29 install the corresponding toolchain on your workstation. To do that,
30 simply run the installer and follow the steps included with it:</para>
31
32 <orderedlist>
33 <listitem>
34 <para><programlisting>$ ./enea-glibc-x86_64-enea-image-virtualization-guest-sdk-core2-64-toolchain-7.0.sh</programlisting>When
35 prompted, select to install the toolchain in the desired directory,
36 referred to as <literal>&lt;sdkdir&gt;</literal>. </para>
37
38 <para>A default path where the toolchain will be installed will be
39 shown in the prompt. The installer unpacks the environment setup
40 script in <literal>&lt;sdkdir&gt;</literal> and the toolchain under
41 <literal>&lt;sdkdir&gt;/sysroots</literal>.</para>
42
43 <note>
44 <para>Choose a unique directory for each toolchain. Installing a
45 second toolchain of any type in the same directory as a previously
46 installed one will break the <literal>$PATH</literal> variable of
47 the first one.</para>
48 </note>
49 </listitem>
50
51 <listitem>
52 <para>Setup the toolchain environment for your target by sourcing the
53 environment-setup script. Example: <programlisting>$ source &lt;sdkdir&gt;/environment-setup-core2-64-enea-linux</programlisting></para>
54 </listitem>
55 </orderedlist>
56 </section>
57
58 <section id="crosscomp-apps">
59 <title>Cross-Compiling Applications from Command Line</title>
60
61 <para>Once the environment-setup script is sourced, you can make your
62 applications as per usual and get them compiled for your target. Below you
63 see how to cross-compile from command line.</para>
64
65 <orderedlist>
66 <listitem>
67 <para>Create a Makefile for your application. Example: a simple
68 Makefile and application:</para>
69
70 <programlisting>helloworld:helloworld.o
71 $(CC) -o helloworld helloworld.o
72clean:
73 rm -f *.o helloworld
74#include &lt;stdio.h&gt;
75int main(void) {
76 printf("Hello World\n");
77 return 0;
78}</programlisting>
79 </listitem>
80
81 <listitem>
82 <para>Run <command>make</command> to cross-compile your application
83 according to the environment set up:</para>
84
85 <programlisting>$ make</programlisting>
86 </listitem>
87
88 <listitem>
89 <para>Deploy the helloworld program to your target and run it:</para>
90
91 <programlisting># ./helloworld
92hello world</programlisting>
93 </listitem>
94 </orderedlist>
95 </section>
96
97 <section id="crosscomp-kern-mod">
98 <title>Cross-Compiling Kernel Modules</title>
99
100 <para>Before cross-compiling kernle modules, you need to make sure the
101 installed toolchain includes the kernel source tree, which should be
102 available at:
103 <literal>&lt;sdkdir&gt;/sysroots/&lt;targetarch&gt;-enea-linux/usr/src/kernel</literal>.</para>
104
105 <para>Once the environment-setup script is sourced, you can make your
106 kernel modules as usual and get them compiled for your target. Below you
107 see how to cross-compile a kernel module.</para>
108
109 <orderedlist>
110 <listitem>
111 <para>Create a Makefile for the kernel module. Example: a simple
112 Makefile and kernel module:</para>
113
114 <programlisting>obj-m := hello.o
115PWD := $(shell pwd)
116
117KERNEL_SRC := &lt;full path to kernel source tree&gt;
118
119all: scripts
120 $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" modules
121scripts:
122 $(MAKE) -C $(KERNEL_SRC) scripts
123clean:
124 $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" clean
125#include &lt;linux/module.h&gt; /* Needed by all modules */
126#include &lt;linux/kernel.h&gt; /* Needed for KERN_INFO */
127#include &lt;linux/init.h&gt; /* Needed for the macros */
128
129static int __init hello_start(void)
130{
131 printk(KERN_INFO "Loading hello module...\n");
132 printk(KERN_INFO "Hello, world\n");
133 return 0;
134}
135
136static void __exit hello_end(void)
137{
138 printk(KERN_INFO "Goodbye, world\n");
139}
140
141module_init(hello_start);
142module_exit(hello_end);
143
144MODULE_LICENSE("GPL");</programlisting>
145 </listitem>
146
147 <listitem>
148 <para>Run <command>make</command> to cross-compile your kernel module
149 according to the environment set up:</para>
150
151 <programlisting>$ make</programlisting>
152 </listitem>
153
154 <listitem>
155 <para>Deploy the kernel module <literal>hello.ko</literal> to your
156 target and install/remove it:</para>
157
158 <programlisting># insmod hello.ko
159# rmmod hello.ko
160# dmesg
161[...] Loading hello module...
162[...] Hello, world
163[...] Goodbye, world</programlisting>
164 </listitem>
165 </orderedlist>
166 </section>
167
168 <section id="deploy-artifacts">
169 <title>Deploying your artifacts</title>
170
171 <orderedlist>
172 <listitem>
173 <para>Deploying on host</para>
174
175 <para>You can use <literal>ssh</literal> to deploy your artifacts on
176 the host target. For this you will need a network connection to the
177 target and to use <literal>scp</literal> to copy to the desired
178 location.</para>
179 </listitem>
180
181 <listitem>
182 <para>Deploying on guest</para>
183
184 <para>You can deploy your artifacts onto the guest VM running on the
185 target in two steps:</para>
186
187 <itemizedlist>
188 <listitem>
189 <para>Deploy the artifacts onto the target by using the method
190 described above or any other method.</para>
191 </listitem>
192
193 <listitem>
194 <para>On the target, copy the artifacts to the guest rootfs. For
195 this, you will need to shut down the guest VM, mount the file
196 system on the target, copy your files onto it, unmount it and then
197 restart the guest VM as usual.</para>
198 </listitem>
199 </itemizedlist>
200 </listitem>
201 </orderedlist>
202 </section>
203</chapter> \ No newline at end of file