Modify, Build, and Debug the Project on MPLAB® for VS Code® Extensions
Purpose
This tutorial demonstrates how to open a project, modify, build, and debug an application for the SAM9X75 using the MPLAB® for VS Code® Extensions, while gaining hands‑on experience with source‑level debugging using OpenOCD.
Hardware Pre-Requisite
- SAM9X75 Curiosity Hybrid evaluation board

- Two USB Type-C® cables
- Power the board via a 5V adapter through J14 or J1
- Jumper settings:
- Close 1-2 pins of jumper13 for the 5V power selection via FTDI USB(J14)
- Close 2-3 pins of jumper13 for the 5V power selection via USB-A (J1)
- Close jumper J3 to enable VDDBU
Modify, Build and Debug an Application on the Target
Clone test_sam9x75 hybrid_curiosity from GitHub®.
Open the MPLAB Harmony project from the class material by following the steps below:
- Open MPLAB in VS Code. Click Create or Import MPLAB Project and select Open MPLAB X Project Folder.
- Navigate to your project folder cloned via git. Click Select Folder to import the project.

Open main.c file.
- This main.c code waits for user input through the console.
- Based on the entered value, it triggers different LED flashing patterns.

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

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 |

Clean and build the project 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.

Note the OpenOCD configuration files 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 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 launch.json file from the GitHub folder to the user project/.vscode.

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

Project properties are configured with the required settings to ensure a successful and error-free build of the application.
Now ensure 1-2 pins of the jumper J13 are closed to power the board via FTDI USB. Open jumpers J10 and J9 to disable boot from QSPI and NAND.
Power the board by connecting a USB Type-C cable to J14 from the host PC. Now press the reset button.
Now execute UsbDriverTool.exe from Designing_with_Hybrid_MCU_pre_work\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.

Connect to Channel C of the FT4232H to use the FTDI using the extension 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, COM25 – USB Serial Port (from the on‑board FT4232HQ), 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 UART, enabling interactive control of application behavior in real time.
- You can see the “RomBOOT” message being printed on the console upon reset every 15 seconds.

Now start to debug. 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:

Click the run or play button in the debugging window and observe output logs in the serial console.
Selecting different pattern numbers in the serial console causes the LEDs to flash in different patterns.
The sample output is shown:

This image shows the VS Code Serial Monitor output where the system is waiting for user input to select an LED pattern.
The serial console waits for input, and when the user presses ‘0’, it flashes a specific LED pattern 10 times with a 250ms interval and then returns to waiting for the next user input.

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


