Custom BSP

Overview

“Custom BSP” stands for Custom Board Support Package. It is the SDK entry point for adding your custom board definitions and any drivers not yet supported by the SDK.

With a custom BSP, you can:

  • Create a Kconfig option for your board and select it among GWT options.

  • Create a devicetree file to describe the devices implemented on your board.

  • Associate your board with supported boards and drivers.

  • Integrate new hardware drivers with the SDK.

The custom BSP is simply an external folder with specific constraints. Its contents must be organized precisely, as described in the next section.

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-specific implementations. (.c/.h files)
    --> drivers
        # Drivers implementation (.c/.h files)
--> devicetree
    # Board content definition. Devicetree source files
--> kconfig
    --> board.kconfig   # Board options
    --> drivers.kconfig # Drivers options
--> CMakeLists.txt # Compilation and link rules

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 :

# From GAP_SDK top-level directory
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 names

  4. --drivers: A list of driver names

  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 :

# From GAP_SDK top-level directory
python utils/custom_bsp/custom_bsp_generate.py --path . --name my_custom_bsp --boards customer_1 customer_2 --drivers driver_a driver_b driver_c
my_first_custom_bsp
    bsp
        bsp_customer_1.c
        bsp_customer_1.h
        bsp_customer_2.c
        bsp_customer_2.h
    drivers
        device_a.c
        device_a.h
        device_b.c
        device_b.h
        device_c.c
        device_c.h
    devicetree
        customer_1.dts
        customer_2.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 unknown 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

Source compilation and CMake target

Custom BSP sources should be compiled within the pmsis CMake target. To enable this, the following line is required at the beginning of the CMake file:

set(ENV{CUSTOM_BSP_TARGET} pmsis)

Use boards and drivers from your custom BSP

Options defined in board.kconfig and drivers.kconfig file can be now selected either from a configuration file sdk.config or from menuconfig interface.

sdk.config file example

CONFIG_BOARD_CUSTOMER_1=y
CONFIG_DRIVER_A=y
CONFIG_DRIVER_C=y

In the menuconfig interface:

  • Custom BSP board options appear under GAP_SDK Board GWT Board

  • Custom BSP drivers appear under GAP_SDK Drivers Custom BSP Drivers.

Example

A simple custom BSP example can be found here in GAP SDK

examples/gap9/basic/bsp/custom_bsp