Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

ModusToolbox 2.2 and later: Make a Custom BSP - KBA231373

ModusToolbox 2.2 and later: Make a Custom BSP - KBA231373

50 questions asked 25 likes received 25 sign-ins

ModusToolbox 2.2 and later: Make a Custom BSP - KBA231373

Version: *A


Translation - Japanese: ModusToolbox 2.2以降用:カスタムBSPを作成する - KBA231373 - Community Translated (JA)


How do I create a custom Board Support Package (BSP) for my own hardware?


Follow the steps in this article. This article is for ModusToolbox v2.2 and later. Some details of this process have changed. For information about ModusToolbox v2.1, see KBA230822.



The BSP is at the core of the ModusToolbox software. We provide a BSP for each of our kits. A BSP includes (among other things):

  • Linker scripts and startup code for the part on the kit
  • A configuration file (default name design.modus) that sets up clocks, peripherals, and pins
  • Files that add libraries required to support the board

For a custom BSP, these elements must be adjusted for your hardware. This KBA explains how to accomplish that goal. At a high level, the steps are straightforward:

  1. Create an application using an existing BSP.
  2. Create a new BSP based on the existing BSP.
  3. Update the new BSP.

The new BSP includes a copy of the design.modus file, and it uses the same libraries as the original BSP. This KBA starts with the generic BSP and shows you how to add functionality. This results in a minimalist BSP to which you can add functionality for your hardware. The generic BSP is a lowest-common denominator that supports all PSoC 6 MCU devices; however, it will support very few code examples because most examples require some kit functionality.

As an alternative, you can create your application with a kit BSP that has more functionality. For example, if your design uses capacitive sensing, use a BSP for a kit that has CapSense functionality. The design files and libraries used by the BSP are set up for that kit. When you start with a more capable BSP, you modify and/or remove functionality to match your hardware, but the principles outlined here are identical.


Step 1: Create an application using an existing BSP.

  1. Use the ModusToolbox Project Creator.
         For this example, we'll create a PSoC 6 application. Select PSOC6-GENERIC as your starter BSP.
  2. Click Next >.
  3. Choose a template application.
         Use the Empty PSoC6 App, give it a name, and ensure the root path is where you want the new application directory to appear.
  4. Click Create.

When the Project Creator is done you have an application directory. The original BSP will be in the mtb_shared directory, adjacent to the application directory. However, you really don’t need to know where it is. You do your work in the application directory.


Step 2: Create a new BSP.

  1. Open a command window (macOS or Linux) or run the modus-shell program (Windows).
  2. Go to the top level of your new application directory where the makefile is located and use the make bsp command.


This command has three parameters:

    • TARGET_GEN is the name of your new BSP
    • DEVICE_GEN is the part number. DEVICE_GEN is optional if the part on your board is the same part as in the existing BSP
    • ADDITIONAL_DEVICES_GEN is the optional part number for an additional part (typically a WiFi or Bluetooth radio device) supported by the BSP.

Using the simple case of a new device, your command would look something like this:



The ModusToolbox build system creates the new BSP at the top level of the application directory, and it is named TARGET_ followed by whatever you named it. In this example it is TARGET_MyBSP.

The new BSP includes part-specific linker scripts and startup code automatically. The design.modus file is identical to the original BSP. If the original design does not work for the new part, you will see an error.

In this example the new part cannot be clocked at the same frequency. You fix these errors in the next step.



Step 3: Update the new BSP.

There are two primary tasks: update the device configuration in the design.modus file, and add libraries. The application you used when creating the new BSP has a makefile. In this example it is in Empty_PSOC6_App.

  1. Open that file and change the TARGET variable to point to your new BSP.
  2. Save the change. Then in the command window, issue this make command
         make config

The build system launches the Device Configurator for your new BSP/device. Resolve any errors and modify the design as required for your hardware. For example, in this case you must set the PLL frequency to a value supported by the part.




If you are unfamiliar with the Device Configurator read the documentation to learn how to enable and configure clocks, pins, peripherals, and other features of the device.


The libraries included with the BSP are in this directory: TARGET_MyBSP/deps. If you start with the generic BSP, these represent the minimal set of libraries required for your device. Each .lib and corresponding .mtbx file is a URL to a git repository that contains the library files.




Note The .mtbx files are used for the MTB library management flow while the .lib files are used by the LIB library management flow. Depending on the flow your application uses, only one of each pair of files will be used. Refer to the Library Manager Guide for descriptions of each flow.


To add an additional library to your BSP, simply put the corresponding .lib and .mtbx file in this directory.


If you create a custom BSP based on a kit BSP, there may be additional libraries. You can also study code examples to see which libraries they use. ModusToolbox libraries are all available on GitHub.


Step 4: Use the new BSP.

When you are done setting up the new BSP, you can move it anywhere you want; it is a self-contained library. Check the BSP into a version control system if you wish.

There are several ways you can use this BSP. Here are a few:

  • Import the BSP into the Project Creator when creating a new application. Refer to the Project Creator Guide for details.



  • Copy the entire BSP directory into the root of an application project.
    • Update the makefile TARGET variable to match the BSP's name.
    • Create .mtb files in the application's deps directory for the BSP’s dependencies. You can do this using the make import_deps command. For example:

make import_deps IMPORT_PATH=TARGET_MyBsp

  • Add the BSP files directly to an application project in an IDE.
    • Update the makefile TARGET
    • Create .mtb files in the application's deps directory for the BSP’s dependencies You can do this using the make import_deps command. For example:

make import_deps IMPORT_PATH=TARGET_MyBsp

    • You may need to update launch configurations to use the new BSP.


  • If using git, create a .mtb file (if using the MTB flow) or .lib file (if using the LIB flow) that points to your BSP repository, and include that file in your application’s deps (dependencies) directory. Examine a code example to see how this is done.

  • Modify the ModusToolbox manifest files so that your BSP appears automatically in the Project Creator. Then pick your BSP when creating a new application. For information see the Manifest Files chapter of the ModusToolbox User Guide.