Changes between Version 43 and Version 44 of newport/bsp

04/13/2022 09:50:28 PM (2 years ago)
Tim Harvey

added cross-compile examples


  • newport/bsp

    v43 v44  
     239== Toolchain
     241=== Marvell toolchain
     242The Newport BSP uses a Marvell toolchain to build the kernel and boot firmware based on gcc v7.3.0.
     244The specific details can be shown by running 'gcc -v' for example:
     246user@host:/usr/src/newport/bsp$ . ./setup-environment # configure PATH and CROSS_COMPILER env vars
     247user@host:/usr/src/newport/bsp$ ${CROSS_COMPILE}gcc -v
     248Using built-in specs.
     251Target: aarch64-marvell-linux-gnu
     252Configured 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= --with-libexpat-prefix=/home/jenkins/workspace/BuildToolchainAARCH64_Marvell7/toolchain/scripts/../libs
     253Thread model: posix
     254gcc version 7.3.0 (Marvell Inc. Version: Marvell GCC7 build 238.0)
     257The buildroot based toolchain is used by virtue of sourcing the [ setup-environment] file which adds to your PATH and sets the CROSS_COMPILE variable.
     259=== Cross compile examples
     261Examples of cross-compiling using the buildroot toolchain
     262 * ANSI-C hello world:
     264cat << EOF > helloworld.c
     265#include <stdio.h>
     266#include <stdlib.h>
     268int main(int argc, char **argv)
     270        printf("hello world!\n");
     272        return 0;
     275. ./setup-environment # setup environment for buildroot toolchain
     276${CROSS_COMPILE}gcc helloworld.c -o helloworld
     278 * C++ hello world:
     280cat << EOF > helloworld.cpp
     281#include <iostream>
     283using namespace std;
     285int main() {
     286        cout << "Hello World!";
     287        return 0;
     290. ./setup-environment # setup environment for buildroot toolchain
     291${CROSS_COMPILE}gcc helloworld.cpp -lstdc++ -o helloworld
     293 * kernel module:
     295. ./setup-environment # setup environment for buildroot toolchain
     296make kernel_image # first build the kernel
     297make -C linux M=$PWD/my-module modules
     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)