Changes between Version 43 and Version 44 of newport/bsp


Ignore:
Timestamp:
04/13/2022 09:50:28 PM (8 months ago)
Author:
Tim Harvey
Comment:

added cross-compile examples

Legend:

Unmodified
Added
Removed
Modified
  • newport/bsp

    v43 v44  
    233233https://github.com/Gateworks/openwrt/blob/20.06/target/linux/octeontx/image/Makefile
    234234
     235
     236
     237
     238[=#toolchain]
     239== Toolchain
     240
     241=== Marvell toolchain
     242The Newport BSP uses a Marvell toolchain to build the kernel and boot firmware based on gcc v7.3.0.
     243
     244The specific details can be shown by running 'gcc -v' for example:
     245{{{#!bash
     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.
     249COLLECT_GCC=aarch64-marvell-linux-gnu-gcc
     250COLLECT_LTO_WRAPPER=/usr/src/newport/bsp/marvell-tools-238.0/bin/../libexec/gcc/aarch64-marvell-linux-gnu/7.3.0/lto-wrapper
     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=http://www.marvell.com/support/ --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)
     255}}}
     256
     257The 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
     261Examples of cross-compiling using the buildroot toolchain
     262 * ANSI-C hello world:
     263{{{#!bash
     264cat << EOF > helloworld.c
     265#include <stdio.h>
     266#include <stdlib.h>
     267
     268int main(int argc, char **argv)
     269{
     270        printf("hello world!\n");
     271
     272        return 0;
     273}
     274EOF
     275. ./setup-environment # setup environment for buildroot toolchain
     276${CROSS_COMPILE}gcc helloworld.c -o helloworld
     277}}}
     278 * C++ hello world:
     279{{{#!bash
     280cat << EOF > helloworld.cpp
     281#include <iostream>
     282
     283using namespace std;
     284
     285int main() {
     286        cout << "Hello World!";
     287        return 0;
     288}
     289EOF
     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
     296make kernel_image # first build the kernel
     297make -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)