| | 235 | |
| | 236 | |
| | 237 | |
| | 238 | [=#toolchain] |
| | 239 | == Toolchain |
| | 240 | |
| | 241 | === Marvell toolchain |
| | 242 | The Newport BSP uses a Marvell toolchain to build the kernel and boot firmware based on gcc v7.3.0. |
| | 243 | |
| | 244 | The specific details can be shown by running 'gcc -v' for example: |
| | 245 | {{{#!bash |
| | 246 | user@host:/usr/src/newport/bsp$ . ./setup-environment # configure PATH and CROSS_COMPILER env vars |
| | 247 | user@host:/usr/src/newport/bsp$ ${CROSS_COMPILE}gcc -v |
| | 248 | Using built-in specs. |
| | 249 | COLLECT_GCC=aarch64-marvell-linux-gnu-gcc |
| | 250 | COLLECT_LTO_WRAPPER=/usr/src/newport/bsp/marvell-tools-238.0/bin/../libexec/gcc/aarch64-marvell-linux-gnu/7.3.0/lto-wrapper |
| | 251 | Target: aarch64-marvell-linux-gnu |
| | 252 | Configured with: /home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../src/configure --disable-fixed-point --without-ppl --without-python --disable-werror --enable-plugins --with-lto-plugin-source=/home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../gits/gcc/lto-plugin --with-system-zlib --enable-initfini-array --with-sysroot --with-local-prefix=/home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../marvell-tools/aarch64-marvell-linux-gnu/sys-root --disable-sim --enable-symvers=gnu --enable-__cxa_atexit --enable-symvers=gnu --enable-__cxa_atexit --disable-sim --with-multilib-list=lp64,ilp32 --enable-gnu-indirect-function --target=aarch64-marvell-linux-gnu --enable-languages=c,c++,fortran --prefix=/home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../marvell-tools --with-pkgversion='Marvell Inc. Version: Marvell GCC7 build 238.0' --with-bugurl=http://www.marvell.com/support/ --with-libexpat-prefix=/home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../libs |
| | 253 | Thread model: posix |
| | 254 | gcc version 7.3.0 (Marvell Inc. Version: Marvell GCC7 build 238.0) |
| | 255 | }}} |
| | 256 | |
| | 257 | The buildroot based toolchain is used by virtue of sourcing the [https://github.com/Gateworks/bsp-newport/blob/master/setup-environment setup-environment] file which adds to your PATH and sets the CROSS_COMPILE variable. |
| | 258 | |
| | 259 | === Cross compile examples |
| | 260 | |
| | 261 | Examples of cross-compiling using the buildroot toolchain |
| | 262 | * ANSI-C hello world: |
| | 263 | {{{#!bash |
| | 264 | cat << EOF > helloworld.c |
| | 265 | #include <stdio.h> |
| | 266 | #include <stdlib.h> |
| | 267 | |
| | 268 | int main(int argc, char **argv) |
| | 269 | { |
| | 270 | printf("hello world!\n"); |
| | 271 | |
| | 272 | return 0; |
| | 273 | } |
| | 274 | EOF |
| | 275 | . ./setup-environment # setup environment for buildroot toolchain |
| | 276 | ${CROSS_COMPILE}gcc helloworld.c -o helloworld |
| | 277 | }}} |
| | 278 | * C++ hello world: |
| | 279 | {{{#!bash |
| | 280 | cat << EOF > helloworld.cpp |
| | 281 | #include <iostream> |
| | 282 | |
| | 283 | using namespace std; |
| | 284 | |
| | 285 | int main() { |
| | 286 | cout << "Hello World!"; |
| | 287 | return 0; |
| | 288 | } |
| | 289 | EOF |
| | 290 | . ./setup-environment # setup environment for buildroot toolchain |
| | 291 | ${CROSS_COMPILE}gcc helloworld.cpp -lstdc++ -o helloworld |
| | 292 | }}} |
| | 293 | * kernel module: |
| | 294 | {{{#!bash |
| | 295 | . ./setup-environment # setup environment for buildroot toolchain |
| | 296 | make kernel_image # first build the kernel |
| | 297 | make -C linux M=$PWD/my-module modules |
| | 298 | }}} |
| | 299 | - Note that some out-of-tree kernel modules do not follow the suggested Makefile standards and may need to be modified to use the CROSS_COMPILE prefix and/or specify the kernel directory (as opposed to the above example where you do a make in the linux dir and set M to the path of your module) |