Multicore Examples on LPC55S6x and MCUXPresso SDK - nxp-mcuxpresso/vscode-for-mcux GitHub Wiki

The following are required to follow this chapter:

  • MCUXpresso for VS Code v1.0 or later
  • LPCXpresso 55S69 EVK development board
  • LPCXpresso 55S69 EVK version 2.13 SDK or later

Overview

The LPC55xx series of MCUs contain a main or 'Primary' Cortex M33 core, plus an optional 'Secondary' Cortex M33 core (with reduced functionality).

On devices with both cores implemented, after a power-on or Reset, the Primary core starts executing, but the Secondary core is held in reset (i.e its code does not start to execute). Code running on the Primary core is then responsible for releasing the Secondary core from reset; hence the names Primary and Secondary. In reality Primary and Secondary only applies to the booting process; after boot, your application may treat either of the cores as the Primary or Secondary.

MCUXpresso for VS Code provides highly flexible support for creating and debugging LPC55xx applications, for both single core and multicore systems. This article details the process of creating and debugging such multicore applications. Note that it is assumed that you are familiar with standard MCUXpresso for VS Code behavior, such as downloading and installing an appropriate MCUXpresso SDK for an MCU, importing examples from the SDK. For more details of these and other operations, please consult the MCUXpresso for VS Code User Guide. The User Guide also provides more general information on multicore projects and debugging.

Importing Multicore Example Project

A multicore application in MCUXpresso for VS Code consists of two linked projects - one project containing the Secondary code, and the other project containing the Primary code. The 'Primary' project will also contain a link to the 'Secondary' project which will cause the output image from the 'Secondary' to be included into the 'Primary' image.

As a prerequisite, use MCUXpresso Installer to install ARM GNU toolchain component plus a Debug Probe software dedicated for your available debug probe (LinkServer, SEGGER J-Link, or PEmicro).

From the Quickstart view, select the 'Import Example from Repository', then select the installed repository, toolchain, and the LPCXpresso55S69 board.

On "Choose a template" section, type "trustzone", the filter will display only the examples containing the word "trustzone" and select either of the Hello World projects.

TrustZone Import Projects

Since these projects are linked, both the Secure (_s) and Non Secure (_ns) examples will be imported once the Create button is pressed.

Note: Linked projects are decorated with blue double-ring icon. Also, the tooltip indicates the linked projects as a list, marked by "Linked projects" label. Multicore Import Projects

Once imported, the PROJECTS view contains the projects as expected.

Multicore Project View

Notes about Multicore project contents and configuration

There are a few points to note about the projects that have been created by the above steps.

First of all, the main() routine in the Primary project contains a code sequence which will copy the Secondary core image from flash memory to the target RAM memory then it will boot the Secondary core application.

Multicore Secondary Load and Boot

The Secondary core image is loaded as binary file:

Multicore Secondary Load Image Bin

, generated by the Secondary core post build step:

Multicore Secondary Gen Image Bin

, and its path specified by the Primary core project include directory:

Multicore Secondary Use Image Bin

Note: The memory configuration for the two cores application can be visualized using the Memory nodes of each project in the PROJECTS view. Multicore Memory Configuration

Building a multicore application

The simplest way to build a multicore project is to trigger a build of the Primary project, typically using the “Build” option from the project's toolbar.

Multicore Build

As the Primary and Secondary projects are linked, this will trigger a build of the Secondary project first, followed by the build of the Primary project – which will embed a copy of the image from the Secondary project into the image generated by the build of the Primary project as depicted above.

At the end of build operation, the executable will be created and exit code 0 will be indicated in the Output console log.

Multicore Build Finished

Debugging a multicore application

Having built your simple multicore application, you can now debug it.

Note: In the debug example below we are going to use the on-board “LPC-Link2” debug probe on the LPCXpresso55S69 board. However, the details are basically the same if using a standalone “LPC-Link2” debug probe. We are not going to cover the use of a PEmicro or SEGGER J-Link probe in this article. General information on using these probes can be found on the wiki documentation.

First of all, start a debug session for Primary project using the Debug option on the project's toolbar.

Once in debug, the core #0 execution will stop at main.

Multicore Debug Core0

Since the core #0 is responsible to initialize the core #1, you need to start execute the core #0 application so select "Continue" from debug toolbar, allow 1-2 seconds for execution then press again in order to stop the execution.

Multicore Debug Run Core0

Now, it is expected that core #1 is initialized.

Multicore Debug Core1 Initialized

At this point, select the Secondary project in the PROJECTS view, then use Debug option to start the Secondary debug session.

Note: For multicore imported projects, the debug for the Secondary core will only attach to the second core, since it is supposed no additional download is needed. Multicore Debug Attach Json

Once the second debug session started, basically, in this moment more than a single debug session is available in VS Code. This is marked by the debug toolbar having now a debug session selector.

Multicore Debug Menu

Selecting one entry from the list will switch the available debug context to that debug session. The two debug sessions and their execution call stack status can be also visualized in the Call Stack view in the Run and Debug view. Also, selecting a call from that view will switch to the desired core debug context.

Multicore Debug 2 Sessions

Also, all the other debug views (Variables, Registers, Peripherals, etc.) will change their content according with the selected debug context.