User Guide

About this document

Version

2.4.0

Scope and purpose

ModusToolbox™ software is a set of tools that enable you to integrate our devices into your existing development methodology. One of the tools is a multi-platform, Eclipse-based Integrated Development Environment (IDE) that supports application configuration and development.

The ModusToolbox™ ecosystem includes IoT development platforms like Mbed OS and Amazon FreeRTOS, in addition to the software installed on your computer and available on GitHub. For a more comprehensive description of the ModusToolbox™ software, refer to the ModusToolbox™ user guide.

Intended audience

This document provides information about creating applications as well as building, programming, and debugging them. This guide primarily covers the Eclipse IDE aspects of these concepts. It also covers various aspects of the software installed along with the IDE, where applicable. For information about using Mbed OS, refer to the Mbed OS to ModusToolbox™ flow chapter in this document. For information about using Amazon FreeRTOS, refer to the their website.

Document conventions

Convention

Explanation

Bold

Emphasizes heading levels, column headings, menus and sub-menus

Italics

Denotes file names and paths.

Courier New

Denotes APIs, functions, interrupt handlers, events, data types, error handlers, file/folder names, directories, command line inputs, code snippets

File > New

Indicates that a cascading sub-menu opens when you select a menu item

Reference documents

Refer to the following documents for more information as needed:

1 Getting started

This section provides a basic walkthrough for how to create a couple applications using the IDE, selecting a BSP. It also covers how to build and program them using the IDE and basic launch configurations supplied for the applications.

1.1 Launch Eclipse IDE

The Eclipse IDE is installed in the following directory, by default:

<install_path>\ModusToolbox\ide_<version>\eclipse\

Note

If the software is not installed in the default location, you will need to set an environment variable. Refer to the ModusToolbox™ installation guide for details.

To launch the Eclipse IDE:

  • On Windows, select the Eclipse IDE for ModusToolbox™ <version> item from the Start menu.

  • For other operating systems, run the “modustoolbox” executable file.

When launching the Eclipse IDE, it provides an option to select the workspace location on your machine. This location is used by the IDE for creating and storing the files as part of application creation for a particular platform. The default workspace location is a folder called “mtw” in your home directory. You may add additional folders under the “mtw” folder or to choose any other location for each workspace.

For more details about Eclipse, refer to the Eclipse documentation, as well as the Eclipse survival guide.

1.2 Open Project Creator tool

Click the New Application link in the Eclipse IDE Quick Panel.

image1

You can also select File > New > ModusToolbox™ Application.

image2

These commands launch the Project Creator tool, which provides several applications for use with different development kits. The kits available may change over time.

image3

For more details about using this tool, refer to the Project Creator user guide.

1.3 Create an application

This section provides a walkthrough for creating a ModusToolbox™ application.

1.3.1 Choose board support package

The Project Creator tool displays a list of boards, showing the Kit Name, MCU, and Connectivity Device (if applicable). As you select each of the kits shown, the description for that kit displays on the right. Depending on the settings for your system, you may see different categories, including PSoC™ 4, PSoC™ 6, and AIROC™ Bluetooth® BSPs. For this example, select the CY8CKIT-062-WIFI-BT kit.

image4

1.3.2. Select application

Click Next > to open the Select Application page. This page lists various applications available for the selected kit. As you select an application, a description displays on the right. You can select multiple applications for the selected BSP by enabling the check box next to the applicable applications.

image5

Note

For BTSDK v2.7 and earlier, you must also create the project called “wiced_btsdk,” which contains the SDK, BSPs, and libraries that are shared among all applications in a workspace. Refer to the ModusToolbox™ 2.1 version of this document for details.

For this example:

  • Select the check box next to the “Hello World” application.

  • If desired, type a name for the application under New Application Name. Do not use spaces in the application name. In this case, we use the default “Hello_World” as the name.

Note

You can use the*Importbutton image6 to select other examples you downloaded from the web or received from a colleague. In the Open dialog, select only examples that are supported by the BSP you selected for this application. Then, the example will be shown in the dialog with all the other applications. See also Import application/code examplefor additional details.

1.3.3 Create application

Click Create to begin the project creation process.

image7

Note

The application creation process performs a git clone operation, and downloads the selected application from the GitHub website. Depending on the selected application, this process can take several minutes.

When complete, the Project Creator tool closes automatically. In the IDE, a message displays about importing the project:

image8

After several moments, the application opens with the Hello_World in the Project Explorer, and the README.md

file opens in the file viewer.

image9

Note

Many AIROC™ Bluetooth® applications contain multiple projects. For example, the BLE- 20819EVB02 application contains projects for Bluetooth® Low Energy services such as anc, ans, bac, bas, beacon, etc.

1.4 Build application

After loading an application, build it to generate the necessary files. Select a project. Then, in the Quick Panel, click the Build <project> Application link. The following images show the Quick Panel for a typical PSoC™ MCU application and an AIROC™ Bluetooth® application.

image10

Messages display in the Console, indicating whether the build was successful or not. For more details about building applications and the various Consoles available, see the Build applications chapter.

1.5 Program application

There are many more details about programming an application. This section only covers it briefly. For more detailed information, see the Program and debug chapter.

In the Project Explorer, select the desired project. Then, in the Quick Panel, click the <app-name> Program (KitProg3_MiniProg4) link for a PSoC™ MCU application, and <app-name> Program for an AIROC™ Bluetooth® application.

image11

1.6 Export/share application

The Eclipse IDE has several methods to export and share applications, and ModusToolbox™ software supports all of them. Keep in mind that a typical ModusToolbox™ application includes many libraries that are available on GitHub. Those libraries are updated during the make getlibs command that the Project Creator tool and Library Manager tool run as part of their operations. Therefore, you can substantially reduce the size of your exported application by excluding the libraries. They can be regenerated by the recipient of the imported application. The following image shows the Eclipse IDE Export dialog with the mtb_shared directory de- selected in order to exclude the libraries.

image12

1.7 Import application/code example

Whether you’ve downloaded an example, or received one from a colleague, Cypress recommends one of the

following methods to import the example into the Eclipse IDE:

1.7.1 Project Creator import option

Use the Project Creator tool to create a new application, and in that process select the Import button image13to select a folder that contains the application to import. Refer to the Project Creator user guide for details.

1.7.2 Eclipse IDE import option

If you have an Eclipse-ready code example (for example, a project exported from Eclipse) that you want to import into the Eclipse IDE, use the Import Application link on the Quick panel.

image14

On the next page, click the Browse… button, navigate to the application directory, and click Select Folder.

image15

Click Finish to begin the import process. This will take a few moments, and then the application will display in the Eclipse IDE Project Explorer.

If the Console displays a message, such as “Error creating Eclipse configurations,” open the Library Manager and click Update. This runs the make getlibs operation to generate the necessary files and libraries.

Note

There are various ways to import examples into Eclipse. If you prefer a different method, make sure that all of the project files are copied into the workspace directory.

1.8 Search online for code examples

Cypress provides many code examples. These examples allow you to explore the capabilities provided by the SDK, create applications based on them, examine the source code demonstrated in them, and read their associated documentation. The Quick Panel provides a link to access online code examples. Click the Search Online for Code Examples link.

image16

This opens a web browser to the GitHub repository to select and download the appropriate examples.

image17

1.9 Search online for libraries/BSPs

Cypress also provides all the libraries and BSPs online at GitHub. The Quick Panel provides a link to access these. Click the Search Online for Libraries and BSPs link.

image18

This opens a web browser to the GitHub repository that shows the ModusToolbox™ software page.

image19

1.10 Access training material

Cypress also provides training material at GitHub. The Quick Panel provides a link to access these. Click the

Training Material link.

image20

This opens a web browser to the GitHub repository that shows the ModusToolbox™ training page.

image21

2 IDE description

The IDE is based on the Eclipse IDE. It uses several plugins, including the Eclipse C/C++ Development Tools (CDT) plugin. For more information about Eclipse, refer to the Eclipse Workbench User Guide. We also provide a document called the Eclipse IDE survival guide, which provides tips and hints for how to use the Eclipse IDE.

The IDE contains Eclipse standard menus and toolbars, plus various panes such as the Project Explorer, Code Editor, and Console. One difference from the standard Eclipse IDE is the “ModusToolbox™ Perspective.” This perspective provides the “Quick Panel,” and adds tabs to the Project Explorer. “Perspective” is an Eclipse term for the initial set and layout of views in the IDE.

image22

Note

If you switch to a different perspective, you can restore the ModusToolbox™ Perspective by clicking the ModusToolbox™ icon button in the upper-right corner. You can also select*Perspective > Open Perspectivefrom theWindowmenu. To restore the ModusToolbox™ Perspective to the original layout, selectPerspective > Reset Perspectivefrom theWindowmenu.

The following describe different parts of the IDE:

  • Menus and toolbars – Use the various menus and toolbars to access build/program/debug commands for your application. Many of these are covered in the Eclipse Workbench User Guide.

  • Project Explorer – Use the Project Explorer to find and open files in your application. See Project Explorer for more information.

  • Quick Panel – Use this tab to access appropriate commands, based on what you select in the Project Explorer.

  • Code Editor – Use the Code Editor to edit various source files in your application.

  • Console – Use these tools to review messages and access the integrated terminal.

2.1 Project Explorer

In the Eclipse IDE, after creating an application, the Project Explorer contains one or more related project folders. The following images show a PSoC™ MCU application and an AIROC™ Bluetooth® application. For applications imported from Mbed OS, see Mbed OS to ModusToolbox™ flow.

image23

Both types of applications contain a similar project structure. Each contains the main application source code, and a Makefile. Note that PSoC™ MCU applications contain a libs directory, while AIROC™ Bluetooth® applications have a wiced_btsdk project with shared SDK, BSPs, and libraries for all applications in a workspace.

2.2 Quick Panel

As stated previously, the Quick Panel is part of the “ModusToolbox™ Perspective.” It provides quick access to commands and documentation based on what you have selected in the Project Explorer.

image24

The Quick Panel contains links to various commands and documentation, organized as follows:

  • Start – This contains the New Application link to create new applications, and links to find Code Examples, Libraries, BSPs, and training material.

  • Selected <app-name> project – This contains different project-related links based on the project that is selected in the Project Explorer, as well as the type of application. Links here include: Build and Clean the application.

  • Launches – This contains various Launch Configurations, based on the selected application project and device, which can be used to program the device and launch the debugger. This area is only populated if you have the top project in your application selected (<app-name>). For more information, see Launch configurations.

  • Tools – This contains links to the various tools available for the selected project. For more information, see Use configurators and Use tools.

  • Documentation – This may contain several documents in HTML format, which are included as part of the chosen BSP.

3 Configure applications

This chapter covers how to make various changes to your application. It includes:

3.1 Modify code

Most code examples work as they are, and there is no need to add or modify code in order to build or program them. However, if you want to update and change an application to do something else, or if you are developing your own application, open the appropriate file in the code editor.

  • PSoC™ MCU: In the Project Explorer, double-click the main.c file.

image25

Note

The “includes” in this example show “unresolved inclusions” because the files are located in the mtb_shared folder. This and other issues with IntelliSense are resolved after a build.

  • AIROC™ Bluetooth®: In the Project Explorer, expand the <app-name> project folder and double-click the application <app-name>.c file.

image26

As you type into the file, an asterisk (*) will appear in the file’s tab to indicate changes were made. The

Save/Save As commands will also become available to select.

3.2 Use configurators

ModusToolbox™ software provides graphical applications called configurators that make it easier to configure a hardware block. However, before you make changes to settings in configurators, you should first copy the configuration information to the application and override the BSP configuration or create a custom BSP. If you make changes to a standard BSP library, it will cause the repo to become dirty. Additionally, if the BSP is in the shared asset repository, changes will impact all applications that use the shared BSP. For more information, refer to the ModusToolbox™ user guide.

Each configurator provides a separate guide, available from the configurator’s Help menu.

3.2.1 Launching configurators from the IDE

To launch a configurator from the Eclipse IDE, right-click on the <app-name> project in the Project Explorer, select ModusToolbox™, and then select the appropriate configurator.

image27

Note

You can also launch available configurators from links in the Quick Panel.

Depending on the enabled resources in your application, there may be several configurators available to launch.

  • If you launch the Device Configurator from the IDE, you are opening the project’s design.modus file, which is responsible for holding all of the BSP configuration information. It contains the following:

    • Selected device

    • Resource parameters

    • Constraints

  • If you launch any of the other configurators from the IDE, they will open using that configurator’s configuration file (design.cycapsense, design.cyseglcd, etc.). These files are specific to the given resource, and they may rely on configuration data from the design.modus file.

3.2.2 Launching configurators without the IDE

To launch any Configurator without using the IDE, refer to the applicable configurator guide for details about configuration information. You may need to open a configuration file or create a new one.

3.3 Use tools

In addition to the configurators, there are several tools, including Library Manager, BTSpy, ClientControl, and Device Firmware Update (DFU) Host Tool. Many tools do not apply to all types of projects. So, the available tools depend on the project/application you have selected in the Project Explorer.

3.3.1 Launching tools from the IDE

To launch a tool from the Eclipse IDE, right-click on the <app-name> project in the Project Explorer, select

ModusToolbox™, and then select the appropriate tool.

image28

Note

You can also launch available tools from links in the Quick Panel.

3.3.2 Library Manager

The Library Manager allows you to select which Board Support Package (BSP) and version should be used by default when building a ModusToolbox™ application. It also allows you to add and remove libraries, as well as change their versions.

For more information about how to use this tool, refer to the Library Manager user guide.

3.3.3 BTSpy and ClientControl

BTSpy is a trace utility that can be used in the AIROC™ Bluetooth® applications to view protocol and generic trace messages from the embedded device. The tool listens on the UDP port 9876 and can receive specially formatted message from another application on the same or different system.

BTSpy can be used in conjunction with ClientControl to receive, decode and display protocol application and stack trace messages. ClientControl communicates with the embedded app to perform various functionalities, tests, exercising features, etc.

3.3.4 DFU Host tool

The Device Firmware Update (DFU) Host tool is a stand-alone program used to communicate with a PSoC™ MCU that has already been programmed with an application that includes device firmware update capability. For more information, refer to the Device Firmware Update Host tool user guide.

3.4 Use integrated terminal

The Eclipse IDE for ModusToolbox™ software includes an integrated terminal where you can enter various commands for the selected project. To view the terminal, click the Terminal tab in the bottom pane. Then, select a project in the Project Explorer to open a shell in the project directory.

image29

Note

You can configure the terminal colors for the Workspace under*Window > Preferences >Terminal.

3.4.1 Switch projects

When you switch projects, the Eclipse IDE creates additional tabs and automatically switches between them, so that a shell in the current project directory is always in focus. To disable this automatic switching, deselect the Track Current Project button in the terminal toolbar.

image30

3.4.2 Specify alternate shell

By default, the terminal uses your login shell on Linux and macOS, or the “modus-shell” Cygwin bash shell provided with your ModusToolbox™ tools installation on Windows. You can specify a different shell from Window > Preferences > ModusToolbox™ Tools.

image31

3.4.3 Update local terminal settings

By default, the local terminal uses your User home directory as the Initial Working Directory. You can specify different options from Window > Preferences > Local Terminal.

image32

Note

Linux and macOS include additional settings for Shell Command and Arguments.

3.4.4 Connect to remote machine/board

You can also connect to a remote machine or board via serial, telnet, or SSH by clicking the Open a Terminal

button in the terminal toolbar.

image33

Use the Choose terminal pull-down menu to select the appropriate terminal.

3.5 Refresh Quick Panel

When you use tools external to the Eclipse IDE, such as the Library Manager or Device Configurator, it is likely that the Eclipse IDE will not refresh to detect changes made in those other tools. Use this link to refresh the Eclipse IDE. You may notice new documentation links or a new Active BSP in the Quick Panel as an indication that your application has new libraries and/or components.

image34

3.6 Rename application

The Eclipse IDE for ModusToolbox™ software uses the standard Eclipse rename functionality. That is, right-click on the application and select Rename. If you use the rename feature, you will need to update your application’s launch configurations. The easiest way to do this is to use the “Generate Launches…” link in the Quick Panel.

After renaming the application, select it in the Project Explorer and notice that there is only one item under Launches. Click on the Generate Launches for… link. After a few moments, the generate process completes. Click on the application again in the Project Explorer and notice that all the items are shown under Launches in the Quick Panel.

image35

3.7 Restore shared directory

Beginning with the ModusToolbox™ 2.2 release, shared BSPs, libraries, and versions are located in a shared directory (named mtb_shared, by default) adjacent to your application directories. You can delete the mtb_shared directory at any time because it can be recreated. You might do this when sharing the application, for example. The shared directory only contains files that are already controlled and versioned, so you should NOT check it into a revision control system.

When using the Eclipse IDE, if you delete the shared library directory from disk and then regenerate it, the directory will not be restored properly. This is because several files required by the Eclipse IDE are not restored as they were when the application was created. To resolve this:

  1. Regenerate the mtb_shared directory and assorted libraries on disk using make getlibs or the Library Manager.

  2. In the Eclipse IDE, delete the “mtb_shared” folder shown in the Project Explorer.

    Note

    Do*NOTselect the check box “Delete project contents on disk” (if you do, you will have to regenerate it again).

  3. Then, select File > Import > C/C++ > Existing Code as Makefile Project and click Next >

    image36

  4. On the Import Existing Code page:

    image37

    1. Under Existing Code Location, click Browse…, navigate to the application’s root directory, select the “mtb_shared” folder, and click Select Folder.

    2. Under Toolchain for Indexer Settings, select ARM Cross GCC.

    3. Click Finish.

  5. After the import completes, build the application.

4 Build applications

This chapter covers various aspects of building applications. Building applications is not specifically required, because building is performed as part of the programming and debugging process. However, if you are running the Eclipse IDE without any hardware attached, you may wish to build your application to ensure all the code is correct. If you changed code in one of your projects, you may wish to build just that project.

4.1 Build with Make

You can build applications from the command line using Make. Refer to the ModusToolbox™ user guide (also located in the <install>/ide_<version>/docs directory) for more information. The document is also available from the IDE’s Help menu.

4.2 Build with IDE

After loading an application, it is best to first build everything to generate the necessary files. Click on a project in the Project Explorer. Then in the Quick Panel, click the “Build <app-name> Application” link.

image38

Building an application will typically allow IntelliSense to work better. It may also be useful to right-click on a project and select Index > Rebuild to allow IntelliSense to find references.

Messages display in the Console, indicating whether the build was successful or not.

image39

Note

Be aware that there are several Console views available.

You can access the different views using the Display Selected Console image40 button (or the pull-down arrow). The Global Build Console is the only way to see all of the results in one place. If you just have the standard Console open, it resets every time a new project in the application starts building. You won’t see any errors if they are not on the final project that gets built.

For subsequent updates, you can build one or more projects using the right-click menu options. Any projects that are dependent on the project being built will also be built. The Eclipse IDE supports all the usual application and build options available for the native Eclipse IDE.

Note

When the active build configuration is changed it affects only the selected project. The active build configuration for any dependent projects is specified separately for each project. Therefore, if you want to use the same configuration for all projects (for example, Debug or Release), it must be set for each project. It is possible to select multiple projects at once from the Project Explorer and then select the active configuration.*

4.3 GCC version

ModusToolbox™ software includes GCC version 10.2 as the preferred toolchain to use with the Eclipse IDE. If you have a different version of GCC you prefer, update the project properties to point to the appropriate toolchain folder. Open the project Properties dialog, and click the Toolchains tab, and then click the appropriate link to update global or workspace preferences, or project properties.

image41

5 Program and debug

Programming and debugging is native to your chosen development environment. Cypress devices are supported in the major program and development solutions. Primarily, this means J-Link and OpenOCD. These solutions provide for programming flash within a device and provide a GDB server for debugging.

This chapter covers various topics related to building and debugging, including:

5.1 PSoC™ MCU programming/debugging

5.1.1 Launch configurations

The flow for programming and debugging is similar for all devices. The Eclipse IDE contains several Launch Configurations that control various settings for programming the devices and launching the debugger.

Depending on the kit and type of applications you are using, there are various Launch Configurations available.

There are two sets of configurations: one for KitProg3_MiniProg4 (included on-board on most Cypress PSoC™ 6 and PSoC™ 4 based kits) and another for SEGGER J-Link.

Note

The KitProg3_MiniProg4 launch configuration also supports the MiniProg4, which you attach to the kit via a 10-pin debug connection. See the* MiniProg4 product pagefor details. The MiniProg3 is not supported.

The Launch Configurations are shown in the Run/Debug Configurations dialog, similar to the following.

image42

You can open these dialogs from the Run menu or by selecting the down arrow image43 next to the Run and Debug commands.

These configurations include the application name and protocol, for example:

CapSenseSlider Program (KitProg3_MiniProg4)

CapSenseSlider Debug (JLink)

Note

KitProg3_MiniProg4 configurations may not work if a J-Link probe is attached to the kit.*

When an application is created, the tool generates the following launch configurations for both KitProg3_MiniProg4 and J-Link. Some items display in the Quick Panel, and some are in the Run/Debug Configurations dialog only.

  • Attach: This launch configuration starts a Cortex-M4 debugging session attaching to a running PSoC™ 6 target without programming or reset.

  • Debug: This launch configuration builds the entire application on both cores, programs all the device’s memories, and then starts a Cortex-M4 debugging session.

  • Erase: This launch configuration erases all internal memories.

  • Program: This launch configuration builds the entire application on both cores, programs all the device’s memories, and then runs the program.

5.1.2 Using JTAG interface in MiniProg4

The MiniProg4 can interact with the target via the SWD or JTAG protocol. By default, the SWD protocol will be used.

In order to use JTAG, you need to add specific commands for the appropriate Debug Configuration. Under the Debugger tab in the Config options field (after -c “source [find interface/kitprog3.cfg]”), insert the following lines:

image44

  • -c “cmsis_dap_vid_pid 0x04B4 0xF151 0x04B4 0xF152”

  • -c “transport select jtag”

5.1.3 Erasing external memory

To erase external memory, you must modify the “Erase” launch configuration options on the Debugger tab as follows:

For PSoC™ 64 Secure Boot kits, such as CY8CKIT-064S0S2-4343W and CY8CPROTO-064S1-SB, enter the following to disable external memory programming via SMIF:

-c “set DISABLE_SMIF 1”

image45

For all other kits, add the path to the GeneratedSource folder (after -s “${openocd_path}/../scripts”):

-s “./libs/<TARGET_NAME>/COMPONENT_BSP_DESIGN_MODUS/GeneratedSource”

image46

5.1.4 Programming eFuse

PSoC™ 6 MCUs contain electronic fuses (eFuses), which are one-time programmable. They store device specific information, protection settings and customer data.

By default, eFuses are not programmed even if they are present in the programming file. To enable eFuse programming, add the following command for the appropriate Debug Configuration, under the Debugger tab in the Config options field (after -c “source [find target/psoc6.cfg]”):

-c “psoc6 allow_efuse_program on”

image47

Attention

Because blowing an eFuse is an irreversible process, Cypress recommends programming only in mass production programming under controlled factory conditions and not prototyping stages. Programming fuses requires the associated I/O supply to be at a specific level: the device VDDIO0 (or VDDIO if only one VDDIO is present in the package) supply should be set to 2.5 V (±5%).*

5.1.5 Debug connection options

By default, a typical PSoC™ 6 application created in the Eclipse IDE includes launch configurations set up for two probes: Cypress KitProg3 (built into Cypress kits) and Segger J-Link.

Communication Firmware

Debug Connection

More Information

Cypress-provided KitProg3

OpenOCD via CMSIS-DAP

https://www.cyp ress.com/products/ps oc-programming- solutions

SEGGER-provided J-Link DLL

SEGGER J-Link

SEGGER J-Li nk

5.1.6 Select specific CMSIS-DAP device

If there are two or more CMSIS-DAP devices connected to your computer, the first detected device will be used by default. KitProg3 supports both CMSIS-DAP modes – HID and BULK. BULK devices are selected first, then HID devices. You can specify a CMSIS-DAP device by:

  • VID and PID of the USB device

  • Serial Number of the USB device

  • VID, PID, and Serial Number of the USB device

To do this, you must add a specific command for the appropriate Debug Configuration, under the Debugger

tab in the Config options field (after -c “source [find interface/kitprog3.cfg]”)

image48

5.1.6.1 Selecting by VID and PID

Use OS-specific tools to determine the VID and PID of connected devices. For example, on Windows, use the Device Manager. Use the “cmsis_dap_vid_pid” command to select a CMSIS-DAP device with a specific VID and PID. If there are two or more devices with the same specified VID/PID pair, OpenOCD uses the first detected device from the passed list.

  • To specify KitProg3 in CMSIS-DAP BULK mode with VID = 0x04B4 and PID = 0xF155:

    cmsis_dap_vid_pid 0x04B4 0xF155

  • To specify KitProg3 in CMSIS-DAP HID mode with VID = 0x04B4 and PID = 0xF154:

    cmsis_dap_vid_pid 0x04B4 0xF154

  • To specify any (HID or BULK) connected KitProg3 device:

    cmsis_dap_vid_pid 0x04B4 0xF154 0x04B4 0xF155

5.1.6.2 Selecting by serial number

There should not be more than one device with the same serial number. Use this method if you want to use only one specific device. Use OS-specific tools to determine the Serial Number of connected devices. You can also use the fw-loader utility with –device-list option. See KitProg Firmware Loader.

Use the “cmsis_dap_serial” command to select a CMSIS-DAP device with a specific Serial Number.

  • To specify a CMSIS-DAP device with Serial Number = 0B0B0F9701047400 the following command is used:

cmsis_dap_serial 0B0B0F9701047400

5.1.6.3 Selecting by both VID/PID and serial number

You can use both commands together in any order. For example:

cmsis_dap_vid_pid 04B4 F155 cmsis_dap_serial 0B0B0F9701047400

5.1.8 KitProg Firmware Loader

The PSoC™ MCU kits include onboard programmer/debug firmware, called KitProg. The CY8CPROTO-062- 4343W kit has KitProg3 by default. However, the CY8CKIT-062-BLE and CY8CKIT-062-WIFI-BT kits come with KitProg2 firmware installed, which does not work with the ModusToolbox™ software. You must update to KitProg3. KitProg3 provides the CMSIS-DAP (Bulk) protocol by default, which is up to ~2.5 times faster than the CMSIS-DAP (HID) protocol. Both modes can be used via OpenOCD.

ModusToolbox™ software includes a command-line tool “fw-loader” to update kits and switch the KitProg firmware from KitProg2 to KitProg3, and back. The following is the default installation directory of the tool:

<install_path>\ModusToolbox\tools_<version>\fw-loader\bin\

Use the fw-loader tool to update the KitProg firmware as required for your needs. KitProg2 does not work with the ModusToolbox™ software. Likewise, if you update to KitProg3, PSoC™ Creator won’t work with kits until you restore KitProg2.

Note

On a Linux machine, you must run the udev_rulesinstall_rules.sh script before the first run of the fw-loader.*

For more details, refer to the KitProg3 user guide. The fw-loader tool also provides a readme text file in the fw- loader installation directory.

5.1.9 Power cycle programming mode with KitProg3_MiniProg4

By default, Launch Configurations use Reset mode to program the device. However, Reset mode is not available in all situations (for example, if the XRES pin is not available on the part’s package). In these cases, Launch Configurations use an alternative reset using software. However, using the software reset type is not sufficient in some cases when access to the device’s DAP is restricted (such as when set by security settings).

If there is no XRES pin available and DAP access is restricted, the only way to reset a part is to use Power Cycle mode. Follow these instructions to add commands to the launch configuration and switch to Power Cycle mode.

  1. Open the Launch Configuration to modify.

  2. Select the Debugger tab.

  3. In the Config options field, insert the following lines

(after -c “source [find interface/kitprog3.cfg]” ) :

image50

For PSoC™ 6:

-c “set ENABLE_POWER_SUPPLY <mV>

-c “set ENABLE_ACQUIRE 2”

For PSoC™ 4:

-c “set ENABLE_POWER_SUPPLY <mV>

-c “set PSOC4_USE_ACQUIRE 2”

Where, <mV> defines target voltage in millivolts, (for example, use -c “set ENABLE_POWER_SUPPLY 3300” for 3.3 V).

Note

Verify the voltage range supported by the target MCU, since it can be damaged by supplying unsupported voltage. Make sure that your MCU is not powered externally before supplying power via the KitProg3_MiniProg4.*

5.1.10 PSoC™ 4 flash security programming

PSoC™ 4 devices include a flexible flash-protection system that controls access to flash memory. This feature secures proprietary code, but it can also be used to protect against inadvertent writes to the bootloader portion of flash. Refer to the device’s Architecture Technical Reference Manual for details.

Flash consists of rows (64/128/256 bytes, depending on the PSoC™ 4 device). Each row of flash can have its protection level independently set. You can assign one of two protection levels to each row, as shown in the following table:

Protection Setting

Allowed

Not Allowed

Unprotected

External read and write, Internal read and write

Full Protection

External read, Internal read

External write, Internal write

To apply flash security, include the appropriate data in the application by creating an array of num_rows / 8 size, where num_rows is the actual number of flash rows on the device. Each byte of this array is responsible for protection of 8 flash rows, and it sets one of two protection levels:

  • 0 – unprotected

  • 1 – full protection

For example, to protect the first 25 rows and the last 5 out of 256 rows, include the following array in your application:

CY_SECTION(“.cyflashprotect”) USED

static const unsigned char flash_protect[0x20] =

{

0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

};

To enable flash security, program the device with the updated code. If you wish to reprogram a protected device, you must first erase it.

5.2 AIROC™ Bluetooth® programming/debugging

AIROC™ Bluetooth® applications have different launch configurations than PSoC™ MCU applications. Bluetooth® applications use External Tools configurations for programming the device, and Attach configurations for attaching to the debugger. The Program launch configurations are available from the Quick Panel when you select <app name> project. Each configuration is preceded by the application name.

image51

5.2.1 Program configuration

This launch configuration runs a script and programs the device’s memories.

  • <app-name> Program: Program is used to build and program embedded applications onto the target device.

5.2.2 Attach configurations

The Attach configurations are used to attach to the debugger without first programming the device. They include:

  • <app-name> Attach_JLink

  • <app-name> Attach_KitProg3_MiniProg4

5.2.3 Debug settings

AIROC™ Bluetooth® devices use the JTAG SWD interface on a kit for debug via OpenOCD or J-Link probe. Typically, GPIOs need to be reprogrammed (via firmware) to enable SWD, so debug can’t be performed directly after a device reset. The debugger is usually attached to a running device and symbols only are loaded.

The CYW920819EVB-02 and CYBT-213043-MESH kits have additional requirements in order to launch the Eclipse IDE debugger. In general, most debugging for these kits is done with logs and sniffers, since real time execution is usually needed for the protocols to run properly.

Refer to the AIROC™ Hardware Debugging document for more details.

5.3 Mbed OS programming/debugging

5.3.1 Launch configurations

When an application is imported from Mbed OS into the Eclipse IDE, the tool generates the following launch configurations. There are three debug configurations and three program configurations:

<target>_<app-name>_debug – Programs the device as needed and launches the debugger.

<target>_<app-name>_erase – Erases the device.

<target>_<app-name>_program – Programs the device.

image52

Note

The three debug launches will attempt to switch to the debug perspective, while the three program launches will not. Cypress recommends using the debug launch for “debug” and the program launches for “erase” and “program.”

5.3.2 Change PyOCD message color

Messages in the console for pyOCD display in red because they are written to stderr. The Eclipse preference for stderr defaults to red. If you want to change the color of stderr:

  1. Open the Preferences dialog and select Run/Debug > Console.

  2. Click on the option for Standard Error text color, select the desired color, and click OK.

  3. Then, click Apply and Close to close the Preferences dialog.

5.3.3 Attach to running target (PyOCD)

There are some cases where you may wish to attach to a running PSoC™ 6 target as part of a debug session. This is accomplished by copying and modifying existing debug configurations.

  1. See Mbed OS to ModusToolbox™ flow for instructions to import an example Mbed project into the Eclipse IDE workspace.

  2. Open the Debug Configurations dialog, and duplicate the Debug configuration; for example, “CY8CPROTO_062_4343W_mbed-os-example-blinky_debug.”

    image53

  3. Rename the new Debug configuration to something meaningful, such as “CY8CPROTO_062_4343W_mbed- os-example-blinky_attach.”

  4. Go to the Startup tab.

    image54

    1. Unselect Initial Reset.

    1. Unselect Load executable.

    2. Unselect Pre-run/Restart reset.

    3. Unselect Set breakpoint at.

    4. Select Continue.

  5. Ensure your KitProg3 is in DAPLink mode and your target is running. See KitProg Firmware Loader.

  6. Click Debug to attach to the running target using the new launch configuration.

6 Mbed OS to ModusToolbox™ flow

For ModusToolbox™ 2.0 and later, we enabled several kits to be used in the Mbed ecosystem. For more information, refer to the webpage on the Mbed OS website: https://os.mbed.com/teams/Cypress/.

These kits support various connectivity applications that you cannot create from the Eclipse IDE. You must use the Mbed OS flow for these types of applications. This section provides the necessary steps to import, build, program, and debug Mbed OS applications in the Eclipse IDE. The main steps include:

6.1 Install and configure Mbed CLI

You should be familiar with Arm Mbed OS and the command line interface (CLI). Refer to the official Mbed OS instructions:

https://os.mbed.com/docs/mbed-os/v6.14/build-tools/install-and-set-up.html

Note

ModusToolbox™ version 2.2 and later only support Python version 3. Refer to the*ModusToolbox™ installation guidefor details. As of this writing, the Mbed OS installers provide Python version 2.7. We recommend following the manual instructions to install Mbed OS CLI.

6.1.1 Install/update PyOCD

In order for Mbed applications to work with ModusToolbox™ software, make sure the Mbed Python packages are installed and updated to versions compatible with Cypress kits. See https://github.com/mbedmicro/pyOCD#installing for more details, including information about libusb installation.

For macOS, run the MBEDCLI application to start an mbed-capable terminal before installing pyocd. This ensures pyocd installs in the self-contained mbed environment. PyOCD is directly supported by the Python bundled with the MBEDCLI application.

Run the following command from a terminal window:

pyocd –version

The reply should be version 0.16.1 through 0.27.3.

Note

The latest version of PyOCD (0.30.x) is not compatible with the GCC version in ModusToolbox™ software.

If you don’t have the correct version, run:

pip install -U pyocd==0.27.3

6.1.2 Configure compilers

Install and configure the appropriate compilers for Mbed CLI. Refer to the Mbed OS for website supported compilers:

https://os.mbed.com/docs/mbed-os/latest/tools/after-installation-configuring-mbed-cli.html

6.1.2.1 GCC

To use the GCC distribution bundled with ModusToolbox™ software, run the mbed config command as appropriate for you operating system:

  • For Windows and Linux:

    mbed config -G GCC_ARM_PATH ~/ModusToolbox/tools_<version>/gcc/bin

  • For macOS:

    mbed config -G GCC_ARM_PATH /Applications/ModusToolbox/tools_<version>/gcc/bin

6.1.2.2 Other compilers

To use another compiler, run the mbed config command and enter the appropriate path. The following are a few typical paths for compilers on Windows:

mbed config -G GCC_ARM_PATH “C:Program Files (x86)GNU Tools ARM Embedded6 2017- q2-updatebin”

mbed config -G ARM_PATH “C:Program Files (x86)ARM_Compiler_5.06u6” mbed config -G ARMC6_PATH “C:Program FilesARMCompiler6.11bin”

mbed config -G IAR_PATH “C:Program Files (x86)IAR SystemsEmbedded Workbench 7.5arm”

To use the ARM v5/v6 compilers bundled with Keil MDK v5, use one of these commands as appropriate:

mbed config -G ARM_PATH “C:Keil_v5ARMARMCC”

mbed config -G ARMC6_PATH “C:Keil_v5ARMARMCLANGbin”

6.3 Create application in Mbed CLI

Open an Mbed CLI prompt and create the directory for Mbed examples. For example:

mkdir mbed-examples cd mbed-examples

Note

On Windows, do*notuse a Cygwin terminal window, and make sure Cygwin is not in your Windows PATH system environment variable. Use the MINGW bash terminal instead.

Import the mbed-os-example-blinky example:

mbed import mbed-os-example-blinky

Switch to the example directory:

cd mbed-os-example-blinky

6.4 Compile application in Mbed CLI (optional)

Note

This step is optional. It may be useful to confirm that the application builds successfully and produces a HEX file.

Compile the Mbed application for one of the supported target boards with one of the supported toolchains

mbed compile –target TARGET –toolchain TOOLCHAIN

where TARGET is one of:

CY8CKIT_062_WIFI_BT CY8CPROTO_062_4343W CY8CKIT_062_BLE CY8CKIT_062_4343W

and TOOLCHAIN is one of:

GCC_ARM

ARM

IAR

For example:

mbed compile –target CY8CKIT_062_WIFI_BT –toolchain GCC_ARM

6.5 Export application from Mbed CLI

To export the Mbed application for use in the Eclipse IDE, use the Mbed CLI export command. For example:

mbed export -i eclipse_gcc_arm -m CY8CKIT_062_WIFI_BT

6.6 Import Mbed OS application into Eclipse IDE

Use the standard Eclipse Import function to import the Mbed application. Expand the C/C++ folder and select the Existing Code as Makefile Project option. Click Next >.

image55

Click Browse… and navigate to the directory where you exported the application. Ensure the Toolchain for Indexer Settings is set to ARM Cross GCC. Do not change any other settings. Click Finish.

image56

When the import finishes, the Mbed OS application will be shown in the Project Explorer.

image57

6.7 Configure Eclipse IDE

6.7.1 Define the workspace pyOCD path

Open the Preferences dialog (using Windows, Window > Preferences), select MCU > Workspace pyOCD Path, and set the following workspace paths (adjust the path to the Scripts directory for your python/pyocd installation):

image58

Note

Your path folder may differ from these examples. Check the correct path folder using the which pyocd-gdbserver command.

Windows:

  • Workspace pyOCD Path > Executable = pyocd-gdbserver

  • Workspace pyOCD Path > Folder = C:Python37Scripts

    macOS:

  • Workspace pyOCD Path > Executable = pyocd-gdbserver

  • Workspace pyOCD Path > Folder = /Applications/MBEDCLI.app/Contents/Resources/miniconda/bin

    Linux:

  • Workspace pyOCD Path > Executable = pyocd-gdbserver

  • Workspace pyOCD Path > Folder = ~/.local/bin

After updating the settings, click Apply and Close.

6.7.2 Verify properties settings

Right-click on the project and select Properties. Navigate to C/C++ Build > Settings. Verify that the Toolchain path and Build tools path have appropriate vales. Click Apply and then click Apply and Close.

image59

Note

This step is needed due to a defect in Eclipse.

6.8 Build, program, debug application

6.8.1 Build

In the Quick Panel, click the Build mbed-os-example-blinky Application link to build the project and generate the HEX file.

image60

When complete, the Console displays a message similar to the following:

link: mbed-os-example-blinky.elf
arm-none-eabi-objcopy -O binary mbed-os-example-blinky.elf mbed-os-example-blinky.bin
===== bin file ready to flash: BUILD/mbed-os-example-blinky.bin =====
arm-none-eabi-objcopy -O ihex mbed-os-example-blinky.elf mbed-os-example-blinky.hex

12:03:47 Build Finished. 0 errors, 110 warnings. (took 1h:21m:30s.902ms)

6.8.2 Program

In the Quick Panel, under Launches, click the CY8CKIT_062_WIFI_BT_mbed-os-example-blinky_program link.

image61

Messages will display in the Console. When programming is complete, the LED should blink red on the board. You may need to press the Reset button.

6.8.3 Debug

In the Quick Panel, under Launches, click the CY8CKIT_062_WIFI_BT_mbed-os-example-blinky_debug link.

image62

The IDE will switch to debugging mode and will halt at the break, ready for debugging.

Note

While debugging, you may see various errors in your code (main.cpp file), such as “function ‘printf’ could not be resolved.” These are likely not real errors. They are caused by the import of the make file into Eclipse. To turn these errors off, go to Project > Properties > C/C++ > Code Analysis, and disable “Potential Programming Problems” and “Syntax and Semantic Errors.”

image63

Revision history

Revision

Date

Description

**

11/21/18

New document.

*A

2/22/19

Updates for ModusToolbox™ version 1.1.

*B

10/15/19

Updates for ModusToolbox™ version 2.0.

*C

10/29/19

Edits to various screen captures and related text.

*D

3/20/20

Updates for ModusToolbox™ version 2.1.

*E

4/1/20

Fix broken links.

*F

8/25/20

Updates for ModusToolbox™ version 2.2.

*G

10/30/20

Updated Import information.

Added information about exporting/sharing an application.

Added information about PSoC™ 4 support.

Added information about restoring shared directory.

*H

3/15/21

Updates for ModusToolbox™ version 2.3.

*I

9/27/21

Updates for ModusToolbox™ version 2.4.