SAM9X75 Curiosity Pro - Modify, Build, and Debug the Project on MPLAB® Extension for VS Code®

Last modified by Microchip on 2026/11/20 06:09

Purpose

The goal of this training is to guide you in opening a project, modifying it, building, and debugging an application for the SAM9X75 using MPLAB® for VS Code®. You will gain hands-on experience with source-level debugging using OpenOCD.

Hardware Pre-Requisite

  • SAM9X75 Curiosity Pro Development board

SAM9X75 Curiosity Pro Development board

  • One USB Type-C cable
  • Power the board via the USB Type-C connector on the USBA port (J3) or via the DC jack connector (J1)
  • Jumper Settings:
    • Close Jumper J85 to enable VDDBU
    • Close 2-3 on Jumper J65 for DBGU Tx interface on FTDI
    • Close 2-3 on Jumper J67 for DBGU Rx interface on FTDI
  • One OpenOCD Debug Probe DV22S07A and one USB Type-C cable

Refer to "OpenOCD Debugging Prerequisites (Bare Metal and MPLAB® Harmony)" to ensure that all required software listed on the prerequisites page is installed before proceeding.

Procedure

Modify, Build, and Debug an Application on the Target

Clone the sam9x75_led_button from GitHub®.

Open the project from the class material by following these steps:​

  • Open MPLAB for VS Code. Click Create or Import MPLAB Project > Open MPLAB X Project Folder.
  • Navigate to your project folder cloned via git. Click Select Folder to import the project.

Open existing project


Open the main.c file.

  • This main.c code waits for user input through the user button
  • Based on the button press, it triggers the LED to turn ON

Code Example

 


To build the project, confirm the compiler details. To do this, go to Command Palette and launch MPLAB: Edit project properties (UI). Go to Toolchain and confirm that XC32 compiler is chosen.

Compiler settings


By default, MPLAB X IDE only generates ELF and HEX format output files. To generate application output in binary format, a post-build step needs to be added to the project properties. To do this, go to Overview > Post-build Steps > Add Item. Then add the following command:

${MP_CC_DIR}/xc32-objcopy -O binary %{TargetDirRelative}/%{ConfigurationName}.elf %{TargetDirRelative}/harmony.bin

 Add post-build step


Clean and build the project by using MPLAB CMake: Clean and build. You will see a message on the output console that the project was successfully built.

This completes the building of the MPLAB Harmony application.

CMake Build


To resolve "unable to find header file" errors, if any, update your project configuration. Select View > Command Palette > MPLAB: Edit Project Properties (UI) > Compiler > Global > Include Directories > Add Path (your project configuration path).

Add Path


 

Note: This step is only necessary for using the cortex-debug extension with the on board programmer debugger. This not necessary for using the MPLAB extensions with the MPLAB PICKit® 5 In-Circuit Debugger.

Note that the OpenOCD configuration files are in the project folder:

sam9x75.cfg defines settings such as the interface, target device, transport, reset behavior, and JTAG/SWD parameters, which are essential for establishing the debug session.

Copy the sam9x75.cfg file from the GitHub directory to the user project.

launch.json specifies details such as the executable file, GDB path, OpenOCD server connection, configuration files, and debug actions like reset, halt, load and run.

Copy the launch.json file from the GitHub directory to the user project/.vscode.

Add required files to the project


Copy at91bootstrap.elf from GitHub into the ./binaries folder of the project directory. This at91bootstrap is used to debug an MPLAB Harmony application in VS Code.

Add at91bootstrap


Open Jumpers J78 and J77 to disable boot from Quad Serial Peripheral Interface (QSPI) and NAND.

 
Connect the OpenOCD Debug Probe Board (DV22S07A) to 20-pin JTAG header J64 on the SAMA7D65 Curiosity Pro board.

Power the OpenOCD Debug Probe Board (DV22S07A) by connecting a USB Type-C cable to J4 from host PC. 

Power the SAMA7D65 Curiosity Pro board by connecting a USB-Type C cable to J1 from host PC.

Now press the RESET button.

Setup


Now execute UsbDriverTool.exe from open_ocd_tools\UsbDriverTool.

Configure Channel A of the FT4232H to use the libusb-winusb driver so it can be used for OpenOCD-based debugging in VS Code. The goal is to switch FT4232H / FT4232HQ “Channel A” to the WinUSB (libusb-winusb) driver. This is required because OpenOCD uses libusb/WinUSB to talk to the JTAG interface, and it will not work if Channel A is still using the default FTDI driver.

Configure Channel A as JTAG


Connect the FTDI USB-UART serial cable to J63 to use the Serial Monitor in VS Code.

  • Serial Monitor configuration and connection: The image shows the VS Code Serial Monitor with the correct settings selected, including Serial Monitor mode, COM3 – USB Serial Port, Line Ending as CR and a baud rate of 115200, with monitoring actively running
  • Sending commands to the target: At the bottom, you can send inputs as text, indicating that control commands are being transmitted from the host to the target over Universal Asynchronous Receiver/Transmitter (UART), enabling interactive control of application behavior in real time
  • You can see the “RomBOOT” message being printed on the console upon reset every 15s

RomBoot


Now start debugging. Go to View > Command Palette > Debug: Start Debugging. When prompted, choose Cortex debug/OpenOCD debug or click the debug symbol as shown in the accompanying image.

Debugging


Click the Continue button in the debugging window.

Now place a breakpoint at line LED_ON();. 

Press the USER button on the board; then the breakpoint should hit as shown in the accompanying image.

Debug Output

Now click the Continue button in the debugging window.

Now the green LED should turn ON.

Output

Back to Top

Results

You have successfully modified and built an application for the SAM9X75 using the MPLAB Extension for VS Code. You verified correct functionality through source‑level debugging with OpenOCD, observing application behavior.

Back to Top