Changes between Version 1 and Version 2 of catalina/bsp


Ignore:
Timestamp:
04/30/2026 05:41:47 PM (29 hours ago)
Author:
Tim Harvey
Comment:

added additional sections

Legend:

Unmodified
Added
Removed
Modified
  • catalina/bsp

    v1 v2  
    9393source ./setup-environment
    9494}}}
     95
     96[=#kernel]
     97==== Modifying the stand-alone Linux Kernel
     98The Gateworks Catalina BSP instructions [#build above] create an environment for building the Linux kernel among other targets.
     99
     100You can modify the default Gateworks kernel config as well as build it manually:
     101 * Modify kernel menuconfig:
     102{{{#!bash
     103make linux-menuconfig
     104}}}
     105 * Make kernel by hand
     106{{{#!bash
     107source ./setup-environment
     108cd linux
     109make menuconfig
     110make savedefconfig
     111diff defconfig ../configs/imx95_catalina_linux-6.18_defconfig # show changes
     112cp defconfig ../configs/imx95_catalina_linux-6.18_defconfig # copy changes (if desired)
     113}}}
     114
     115[=#toolchain]
     116== ARM64 Toolchain
     117The buildroot based ARM64 toolchain is used can be used by sourcing the [https://github.com/Gateworks/bsp-catalina/blob/master/setup-environment setup-environment] file which adds to your PATH and sets the CROSS_COMPILE variables:
     118{{{#!bash
     119source ./setup-environment
     120}}}
     121
     122Note this is not necessary to do if you are using the Makefile as it specifies the necessary ARCH and CROSS_COMPILE vars where needed.
     123
     124=== Buildroot based toolchain
     125The Catalina BSP uses buildroot to build the ARM64 toolchain used to build everything that runs on the A55 cores: ATF, kernel and bootloader firmware.
     126
     127The buidlroot config is [https://github.com/Gateworks/bsp-catalina/blob/main/configs/buildroot_arm64_toolchain_defconfig configs/buildroot_arm64_toolchain_defconfig].
     128
     129The bsp [https://github.com/Gateworks/bsp-catalina/blob/main/Makefile Makefile] has an 'arm64-toolchain' target which is built as a pre-requisite for building code running on the A55 cores.
     130
     131The toolchain is built using buildroot 2026.02 with the following details (which are all defaults for this version of buildroot):
     132 - Linux 6.18 kernel headers
     133 - glib libc
     134 - binutils 2.44
     135 - gcc 13.4
     136 - C++ support (default is to disable this; we enable it)
     137
     138Note 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:
     139{{{#!bash
     140make arm64-toolchain-menuconfig # select changes
     141make clean-toolchain
     142make
     143}}}
     144 * make sure you clean and rebuild when changing toolchain options
     145
     146=== External toolchain
     147The Catalina BSP uses buildroot to build the toolchain used to build the kernel and bootloader firmware.
     148
     149While the BSP makefile will always build the buildroot ARM64 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 and adjusting the PATH and CROSS_COMPILE statements int he Makefile.
     150
     151
     152=== Cross compile examples
     153
     154Examples of cross-compiling on your development host using the ARM64 buildroot toolchain
     155 * ANSI-C hello world:
     156{{{#!bash
     157cat << EOF > helloworld.c
     158#include <stdio.h>
     159#include <stdlib.h>
     160
     161int main(int argc, char **argv)
     162{
     163        printf("hello world!\n");
     164
     165        return 0;
     166}
     167EOF
     168. ./setup-environment # setup environment for buildroot toolchain
     169${CROSS_COMPILE}gcc helloworld.c --static -o helloworld
     170}}}
     171  - Note that if you want to use shared libraries you would either need to copy the toolchains libc (buildroot/output/target/lib/) to the target so that the interpreter and shared libs are present or you can use Ubuntu's cross-toolchain instead (see [wiki:/ubuntu#hello-world.c ubuntu/cross-compile])
     172 * C++ hello world:
     173{{{#!bash
     174cat << EOF > helloworld.cpp
     175#include <iostream>
     176
     177using namespace std;
     178
     179int main() {
     180        cout << "Hello World!";
     181        return 0;
     182}
     183EOF
     184. ./setup-environment # setup environment for buildroot toolchain
     185${CROSS_COMPILE}gcc helloworld.cpp --static -lstdc++ -o helloworld
     186}}}
     187  - Note that if you want to use shared libraries you would either need to copy the toolchains libc (buildroot/output/target/lib/) to the target so that the interpreter and shared libs are present or you can use Ubuntu's cross-toolchain instead (see [wiki:/ubuntu#hello-world.c ubuntu/cross-compile])
     188 * kernel module:
     189{{{#!bash
     190. ./setup-environment # setup environment for buildroot toolchain
     191make kernel_image # first build the kernel
     192make -C linux M=$PWD/my-module modules
     193}}}
     194  - 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)
     195
     196
     197[=#target-compile]
     198== Building applications on the Catalina Target
     199
     200=== Out-of-Tree Kernel Modules on Target
     201Gateworks Catalina BSP now creates images that have built in support for building external or out-of-tree kernel modules on a target board, allowing users to extend the functionality of the kernel with custom or third-party modules. Below are some examples demonstrating how to build and install external modules on a one of our Catalina boards:
     202
     203Before building any external kernel modules, it's essential to ensure your system has necessary dependencies installed. We recommend starting with an update of package lists followed by the installation of essential tools. Run the following commands:
     204{{{#!bash
     205apt update
     206apt install -y build-essential git bc file flex bison
     207}}}
     208
     209Examples:
     210 1. cryptodev-linux (a properly defined Makefile)
     211{{{#!bash
     212git clone http://github.com/cryptodev-linux/cryptodev-linux
     213cd cryptodev-linux
     214make && make modules_install
     215modprobe cryptodev
     216}}}
     2171. something with an improper or problematic Makefile but with a single C file for example uiodma.c
     218{{{#!bash
     219git clone https://github.com/nxp-imx-support/uiodma-driver.git
     220cd uiodma-driver/uiodma
     221# build module
     222make -C /lib/modules/$(uname -r)/build M=$PWD obj-m=uiodma.o modules
     223# install module
     224make -C /lib/modules/$(uname -r)/build M=$PWD obj-m=uiodma.o modules_install
     225}}}
     226 - The kernel build system will still look for a file named Makefile or Kbuild in your directory. If the existing files are so broken that it can't even parse them you will need to rename/remove them
     227 - If you need to pass flags to the compiler define them as 'KCFLAGS' - ie 'KCFLAGS="-Wno-missing-prototypes -Wno-missing-declarations"
     228
     229These examples illustrate the process of building and installing external kernel modules. Users can adapt these instructions for other modules as needed, ensuring that dependencies are met and the module is properly installed and loaded into the kernel.
     230
     231