Changes between Version 6 and Version 7 of venice/bsp

09/10/2021 10:35:54 PM (10 months ago)
Tim Harvey

add toolchain details and cross-compile examples


  • venice/bsp

    v6 v7  
    116116make ubuntu-image
     121== Toolchain
     123=== Buildroot based toolchain
     124The Venice BSP uses buildroot to build the toolchain used to build the kernel and bootloader firmware.
     126The buidlroot config is [ venice/buildroot-imx8mm_venice_defconfig] which is copied to buildroot/configs/imx8mm_venice_defconfig.
     128The bsp [ Makefile] has a 'toolchain' target which is built as a pre-requisite for building the bootloader and kernel.
     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)
     137The specific details can be shown by running 'gcc -v' for example:
     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.
     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= --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)
     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:
     153cd buildroot
     154make menuconfig # select options desired under Toolchain
     155make clean
     158 * make sure you clean and rebuild when changing toolchain options
     160The buildroot based toolchain is used by virtue of sourcing the [ setup-environment] file which adds to your PATH and sets the CROSS_COMPILE variable.
     162=== External toolchain
     163The Venice BSP uses buildroot to build the toolchain used to build the kernel and bootloader firmware.
     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.
     168=== Cross compile examples
     170Examples of cross-compiling:
     171 * ANSI-C hello world:
     173cat << EOF > helloworld.c
     174#include <stdio.h>
     175#include <stdlib.h>
     177int main(int argc, char **argv)
     179        printf("hello world!\n");
     181        return 0;
     184. ./setup-environment # setup environment for buildroot toolchain
     185${CROSS_COMPILE}gcc helloworld.c -o helloworld
     187 * C++ hello world:
     189cat << EOF > helloworld.cpp
     190#include <iostream>
     192using namespace std;
     194int main() {
     195        cout << "Hello World!";
     196        return 0;
     199. ./setup-environment # setup environment for buildroot toolchain
     200${CROSS_COMPILE}gcc helloworld.cpp -lstdc++ -o helloworld
     202 * kernel module:
     204. ./setup-environment # setup environment for buildroot toolchain
     205make kernel_image # first build the kernel
     206make -C linux M=$PWD/my-module modules
     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)
    118211= SSH using Ubuntu