Changes between Version 6 and Version 7 of venice/bsp


Ignore:
Timestamp:
09/10/2021 10:35:54 PM (15 months ago)
Author:
Tim Harvey
Comment:

add toolchain details and cross-compile examples

Legend:

Unmodified
Added
Removed
Modified
  • venice/bsp

    v6 v7  
    116116make ubuntu-image
    117117}}}
     118
     119
     120[=#toolchain]
     121== Toolchain
     122
     123=== Buildroot based toolchain
     124The Venice BSP uses buildroot to build the toolchain used to build the kernel and bootloader firmware.
     125
     126The buidlroot config is [https://github.com/Gateworks/bsp-venice/blob/master/buildroot-imx8mm_venice_defconfig venice/buildroot-imx8mm_venice_defconfig] which is copied to buildroot/configs/imx8mm_venice_defconfig.
     127
     128The bsp [https://github.com/Gateworks/bsp-venice/blob/master/Makefile Makefile] has a 'toolchain' target which is built as a pre-requisite for building the bootloader and kernel.
     129
     130The buildroot version is 2020.05.3 and builds a toolchain with the following details (which are all defaults for buildroot):
     131 - Linux 5.6.x kernel headers
     132 - uClibc libc
     133 - binutils 2.32
     134 - gcc 8.x
     135 - C++ support (default is to disable this; we enable it)
     136
     137The specific details can be shown by running 'gcc -v' for example:
     138{{{#!bash
     139user@host:/usr/src/venice/bsp$ . ./setup-environment # configure PATH and CROSS_COMPILER env vars
     140user@host:/usr/src/venice/bsp$ ${CROSS_COMPILE}gcc -v
     141Using built-in specs.
     142COLLECT_GCC=/usr/src/venice/bsp/buildroot/output/host/bin/aarch64-linux-gcc.br_real
     143COLLECT_LTO_WRAPPER=/usr/src/venice/bsp/buildroot/output/host/libexec/gcc/aarch64-buildroot-linux-uclibc/8.4.0/lto-wrapper
     144Target: aarch64-buildroot-linux-uclibc
     145Configured with: ./configure --prefix=/usr/src/venice/bsp/buildroot/output/host --sysconfdir=/usr/src/venice/bsp/buildroot/output/host/etc --enable-static --target=aarch64-buildroot-linux-uclibc --with-sysroot=/usr/src/venice/bsp/buildroot/output/host/aarch64-buildroot-linux-uclibc/sysroot --enable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --disable-decimal-float --with-gmp=/usr/src/venice/bsp/buildroot/output/host --with-mpc=/usr/src/venice/bsp/buildroot/output/host --with-mpfr=/usr/src/venice/bsp/buildroot/output/host --with-pkgversion='Buildroot 2020.05.3' --with-bugurl=http://bugs.buildroot.net/ --disable-libquadmath --disable-libsanitizer --enable-tls --enable-threads --without-isl --without-cloog --with-abi=lp64 --with-cpu=cortex-a53 --enable-languages=c,c++ --with-build-time-tools=/usr/src/venice/bsp/buildroot/output/host/aarch64-buildroot-linux-uclibc/bin --enable-shared --disable-libgomp
     146Thread model: posix
     147gcc version 8.4.0 (Buildroot 2020.05.3)
     148}}}
     149
     150
     151Note there are other options you may want to change for your needs such as using a different libc, different compiler version, or enable WCHAR support or additional threading support. To do so you can:
     152{{{#!bash
     153cd buildroot
     154make menuconfig # select options desired under Toolchain
     155make clean
     156make
     157}}}
     158 * make sure you clean and rebuild when changing toolchain options
     159
     160The buildroot based toolchain is used by virtue of sourcing the [https://github.com/Gateworks/bsp-venice/blob/master/setup-environment setup-environment] file which adds to your PATH and sets the CROSS_COMPILE variable.
     161
     162=== External toolchain
     163The Venice BSP uses buildroot to build the toolchain used to build the kernel and bootloader firmware.
     164
     165While the BSP makefile will always build the buildroot toolchain (unless you comment that out in the Makefile) you can easily use a toolchain of your liking by modifying the environment like 'setup-environment' does. Simply make sure to set CROSS_COMPILE to the prefix of your toolchains 'gcc' compiler and other tools, and make sure your external toolchain shows up first in your PATH.
     166
     167
     168=== Cross compile examples
     169
     170Examples of cross-compiling:
     171 * ANSI-C hello world:
     172{{{#!bash
     173cat << EOF > helloworld.c
     174#include <stdio.h>
     175#include <stdlib.h>
     176
     177int main(int argc, char **argv)
     178{
     179        printf("hello world!\n");
     180
     181        return 0;
     182}
     183EOF
     184. ./setup-environment # setup environment for buildroot toolchain
     185${CROSS_COMPILE}gcc helloworld.c -o helloworld
     186}}}
     187 * C++ hello world:
     188{{{#!bash
     189cat << EOF > helloworld.cpp
     190#include <iostream>
     191
     192using namespace std;
     193
     194int main() {
     195        cout << "Hello World!";
     196        return 0;
     197}
     198EOF
     199. ./setup-environment # setup environment for buildroot toolchain
     200${CROSS_COMPILE}gcc helloworld.cpp -lstdc++ -o helloworld
     201}}}
     202 * kernel module:
     203{{{#!bash
     204. ./setup-environment # setup environment for buildroot toolchain
     205make kernel_image # first build the kernel
     206make -C linux M=$PWD/my-module modules
     207}}}
     208  - 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)
     209
     210
    118211= SSH using Ubuntu
    119212