This page will document the GCC based toolchain to allow developers to build code to run on NavOS based devices.
...
Note |
---|
The toolchain is being actively developed along with NavOS |
Introduction
Contents
...
Table of Contents |
---|
maxLevel | 3 |
---|
indent | 16px |
---|
exclude | Introduction|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)
...
...
On this page:
WSL Only
Edit ~/.profile and add the following at the end to fix file permissions, then close and re-open the shell
Code Block |
---|
|
if [ "$(umask)" = "0000" ]; then
umask 0022
fi |
Updating and adding required packages for x86_64 build
Code Block |
---|
|
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
Code Block |
---|
|
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
Code Block |
---|
|
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
Code Block |
---|
|
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
Code Block |
---|
|
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
Code Block |
---|
|
mkdir ~/test
cd ~/test |
Create a file called CMakeLists.txt
Code Block |
---|
|
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
Code Block |
---|
|
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
} |
Run CMake to create two build folders one for each compiler
Code Block |
---|
|
# 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
Filter by label |
---|
showLabels | false |
---|
max | 10 |
---|
cql | label in ( "radar" , "epu" , "colossus" ) |
---|
|