Modify, Build, and Debug the Project on MPLAB® Extension for VS Code®
Purpose
The goal of this training is to help you open a project, modify, build, and debug an application for the SAMA7D65 using the MPLAB® for VS Code®. You will also gain hands-on experience with source-level debugging through OpenOCD.
Hardware Pre-Requisite
- SAMA7D65 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 1 USB Type-C cable
Modify, Build, and Debug an Application on the Target
Clone the sama7d65_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 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

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.

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:

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 MPLAB Harmony application 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).

Note the OpenOCD configuration files in the project folder and in the openocd directory:
sama7d6.cfg defines settings such as the interface, target device, transport, reset behavior, and JTAG/SWD parameters, which are essential for establishing the debug session.
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 GitHub 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 in VS Code.

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 J37 on the SAMA7D65 Curiosity Pro board.
Power the OpenOCD Debug Probe Board (DV22S07A) by connecting a USB Type-C cable to J4 from the host PC.
Power the SAMA7D65 Curiosity Pro board by connecting a USB Type-C cable to J1 from the host PC.
Now press the RESET button.

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.

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 “RomBOOT” message being printed on the console upon reset every 15s

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.

Click the Continue button in the debugging window.
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.

Click the Continue button in the debugging window.
Now the green LED should turn ON.

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