The Portenta H7 M7 has support for an in-built debugger "Monitor for Remote Inspection" (MRI).
This can now be used out of the box in vMicro in a few simple steps, with no additional hardware.
This is available from vMicro versions 2021.0606.13 onwards, in conjunction with the "Arduino Mbed OS Portenta Boards" platform.
Simply connect your Portenta H7 M7 to your PC via the USB(C) cable as normal:
Ensure you have Visual Studio and the vMicro Extension Installed
Open your Sketch, and select the options from vMicro > Debugging as shown below:
NOTE - as the debugger uses the SerialUSB interface of the Portenta, you will have to remove all calls to Serial from your code. Alternatively use a seperate serial interface for your messages.
You will need to add a couple of additions to your sketch (also in output window on debugger select):
- Ensure you have the Debug Configuration selected from the Configuration Manager Window
- Check the COM Port on the Debug Toolbar is correct.
- Include the ThreadDebug.h file at the top of your sketch by adding the ThreadDebug Library
- Add the below code above setup():
ThreadDebug threadDebug(&debugComm, DEBUG_BREAK_IN_SETUP);
// Set to DEBUG_NO_BREAK_IN_SETUP to prevent automatic stop in setup
- If you know where you want the first breakpoint in your code, add it now
- Double Tap the Reset button to put the board into DFU Mode (Green LED fades in and out)
- Check the COM Port selected for Upload is still correct, and build and upload the code to the board
- To start the debugging session use "Debug > Attach to Process" (your code does not start executing until the debugger has attached)
Congratulations - you should have the debugger running, and further windows can be opened from the "Debug > Windows" menu once you have started debugging