Custom BSP

The following section explains what is the purpose of the custom BSP and how to use it.

Description

GAP SDK’s custom BSP is a mechanism that allows you to define and integrate custom boards and drivers based on GAP SDK resources. The custom BSP currently supports the following features :

  • Create kconfig options to define your board

  • Link your board to an existing GAP chip and already supported drivers from the SDK

  • Add new drivers

  • Describe how your board is implemented with devicetree.

  • Create board’s dedicated BSP files to handle specific implementation.

To simplify this process, GAP SDK offers a way to define the whole content of your custom BSP into a directory which is independant from the SDK. This directory is expected to be rigorously organized.

Custom BSP directory organization

A custom BSP directory is expected to contain specific subfolders and files. Here is a tree view of it :

custom_bsp_folder
--> bsp
    --> boards
        # Board's related BSP files (.c/.h)
    --> drivers
        # Drivers implementation (.c/.h)
--> devicetree
    # Devicetree source files
--> kconfig
    --> board.kconfig   # Board definition
    --> drivers.kconfig # Drivers definition
--> CMakeLists.txt # A custom BSP requires a CMakeLists file to build its sources.

The folder and files name exposed here need to remain unchanged to get properly linked to the SDK. To facilitate the creation of a custom BSP, the SDK provides a template generator here :

${GAP_SDK_HOME}/utils/custom_bsp/custom_bsp_generate.py

This script allows you to create the basics of the custom BSP, here are its arguments :

  1. --path: Custom BSP desired location

  2. --name: Custom BSP folder name

  3. --boards: A list a board name

  4. --drivers: A list of driver name

  5. --override: An empty option that allow to override an existing custom BSP. If this option is not set and if the folder already exists, the creation will abort.

Here is an example :

python custom_bsp_generate.py --path . --name my_first_bsp --boards BOARD_DEV BOARD_CUSTOMER --drivers driver_a driver_b driver_c
my_first_custom_bsp
    bsp
        bsp_board_customer.h
        bsp_board_customer.c
        bsp_board_dev.h
        bsp_board.c
    drivers
        device_a.c
        device_a.h
        device_b.c
        device_b.h
        device_c.c
        device_c.h
    devicetree
        board_customer.dts
        board_dev.dts
    kconfig
        board.kconfig
        drivers.kconfig
    CMakeLists.txt

Adding a board to the custom BSP

First, read the following tutorial How to integrate a new GWT board into the GAP SDK to understand how GAP SDK implements devicetree feature.

The following step describes how to add your own board in the custom bsp :

  1. Create your board option in board.kconfig file. Select which chip and drivers it embbeds.

  2. If needed, implement required drivers unknwown from GAP SDK in bsp/drivers folder.

  3. Create your board’s devicetree file.

  4. Write your board’s BSP implementation in bsp/board folder.

  5. Write the custom BSP’s CMakeList.txt file

The CMakeList.txt file need to create a “custom_bsp” library. This library aims to provide the location of header directories and required C files to compile depending on selected kconfig options.

Check GWT examples for more details : custom_bsp_example

Linking a custom BSP to the SDK

Set the GAP_CUSTOM_BSP cmake variable in your applciation CMakeLists.txt file to the path of your custom BSP to establish the link between the two.

set(GAP_CUSTOM_BSP /path/to/your/custom_bsp)

SDK CMake process include a general check about your custom BSP folder organization. If it respects the conditions explained here, the link will be successful.

The linking process consists in merging the board.kconfig and drivers.kconfig file’s options definition newt to GAP SDK’s board.kconfig and drivers.kconfig ones to appear in the menuconfig interface and to be selectable as valid boards and drivers from an application.

Example

Please, ask an access to GWT’s custom_bsp_helloworld.git project to get an example of a custom BSP implementation.