This page will document the GCC based toolchain to allow  developers to build code to run on NavOS based devices.

The toolchain is being actively developed along with NavOS

Introduction

Insert introduction and summary here. This section is not full width due to the contents on the right. There is no issue with this section being longer then the contents however it makes more sense to make it a similar size as the content and then shift to the full width section below

Contents



Build Environment

Requirements

Ubuntu 20.04 based Linux distribution (WSL 20.04 LTS has been tested as well as a standalone x86_64 20.04 LTS server)

WSL Only

Edit ~/.profile and add the following at the end to fix file permissions, then close and re-open the shell

if [ "$(umask)" = "0000" ]; then
    umask 0022
fi

Updating and adding required packages for x86_64 build

sudo apt-get -y update && sudo apt-get -y upgrade
sudo apt-get -y install build-essential pkg-config u-boot-tools bison flex autoconf libtool libtool-bin texinfo sed gcc g++ sed make binutils bash patch gzip bzip2 perl tar cpio python unzip rsync file bc libncurses5-dev g++- cmake gdb

Adding Navtech ARM Hard Float Compiler

Copy the arm-navtech-linux-gnueabihf_sdk-buildroot_imx6q-tx6q-1033.tar.gz to your users home folder

mkdir ~/toolchains
tar xzf arm-navtech-linux-gnueabihf_sdk-buildroot_imx6q-tx6q-1033.tar.gz -C ~/toolchains/
cd ~/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot/
./relocate-sdk.sh

Add Navtech Compiler to the path if not using CMake

Edit ~/.profile and add the following at the end to update the path, then close and re-open the shell

export PATH=$PATH:~/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot//bin

Recommendations

Navtech uses the CMake (documentaion here) build tool to simplify development, CMake easily allows swapping between toolchains and has built-in support for using cross compilers. It also has support for unit testing.

Navtech uses VSCode with remoting tools to allow any host operating system that can run VSCode to build and cross compile projects that will run on NavOS devices

VSCode Extensions

Remote - SSH (Microsoft) - If using Server/VM based Ubuntu
Remote - WSL (Microsoft) - If using WSL based Ubuntu
C/C++ (Microsoft)
CMake Tools - (vector-of-bool)

VSCode CMake Basic Setup

cmake: Scan for Kits
cmake: Edit user-local CMake kits

Add this to the file

{
    "name": "GCC for arm-navtech-linux-gnueabihf 9.3.0",
    "toolchainFile": "/home/<your username>/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot//share/buildroot/toolchainfile.cmake",
    "compilers": {
      "C": "/home/<your username>/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot//bin/arm-buildroot-linux-gnueabihf-gcc",
      "CXX": "/home/<your username>/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot//bin/arm-buildroot-linux-gnueabihf-g++"
    }
}

cmake: Select a Kit - Choose GCC for x86_64-linux-gnu 9.3.0 or GCC for arm-buildroot-linux-gnueabihf 9.3.0

CMake Test to prove both x86_64 and ARM Hard Float Compiler work

mkdir ~/test
cd ~/test

Create a file called CMakeLists.txt

cmake_minimum_required(VERSION 3.10)

project(navtech-test LANGUAGES CXX)
enable_testing()
include(CTest)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

add_executable(navtech-test navtech-test.cpp)

Create a file navtech-test.cpp with the following contents

#include <iostream>

int main()
{
    std::cout << "Hello World!" << std::endl;
}

Run CMake to create two build folders one for each compiler

# Create x86_86 debug build for local testing
mkdir -p output/x64_86/debug
pushd output/x64_86/debug
cmake -DCMAKE_BUILD_TYPE=debug ../../../
make
./navtech-test
popd

# Create armhf debug build for NavOs
mkdir -p output/armhf/debug
pushd output/armhf/debug
cmake -DCMAKE_BUILD_TYPE=relwithdebuginfo -DCMAKE_TOOLCHAIN_FILE=~/toolchains/arm-navtech-linux-gnueabihf_sdk-buildroot//share/buildroot/toolchainfile.cmake ../../../
make
file ./navtech-test
popd
# Expect output similar to ./navtech-test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)

Related Information