diff options
Diffstat (limited to 'doc/book-enea-nfv-access-platform-guide/doc/using_nfv_access_platform_sdks.xml')
-rw-r--r-- | doc/book-enea-nfv-access-platform-guide/doc/using_nfv_access_platform_sdks.xml | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/doc/book-enea-nfv-access-platform-guide/doc/using_nfv_access_platform_sdks.xml b/doc/book-enea-nfv-access-platform-guide/doc/using_nfv_access_platform_sdks.xml new file mode 100644 index 0000000..9f0f3f5 --- /dev/null +++ b/doc/book-enea-nfv-access-platform-guide/doc/using_nfv_access_platform_sdks.xml | |||
@@ -0,0 +1,203 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
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 Platform SDKs</title> | ||
6 | |||
7 | <para>Enea NFV Access Platform 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><sdkdir></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><sdkdir></literal> and the toolchain under | ||
41 | <literal><sdkdir>/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 <sdkdir>/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 | ||
72 | clean: | ||
73 | rm -f *.o helloworld | ||
74 | #include <stdio.h> | ||
75 | int 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 | ||
92 | hello 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><sdkdir>/sysroots/<targetarch>-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 | ||
115 | PWD := $(shell pwd) | ||
116 | |||
117 | KERNEL_SRC := <full path to kernel source tree> | ||
118 | |||
119 | all: scripts | ||
120 | $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" modules | ||
121 | scripts: | ||
122 | $(MAKE) -C $(KERNEL_SRC) scripts | ||
123 | clean: | ||
124 | $(MAKE) -C $(KERNEL_SRC) M=$(PWD) LDFLAGS="" clean | ||
125 | #include <linux/module.h> /* Needed by all modules */ | ||
126 | #include <linux/kernel.h> /* Needed for KERN_INFO */ | ||
127 | #include <linux/init.h> /* Needed for the macros */ | ||
128 | |||
129 | static 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 | |||
136 | static void __exit hello_end(void) | ||
137 | { | ||
138 | printk(KERN_INFO "Goodbye, world\n"); | ||
139 | } | ||
140 | |||
141 | module_init(hello_start); | ||
142 | module_exit(hello_end); | ||
143 | |||
144 | MODULE_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 | ||