Skip to content

DebuggingDemoFirmware

Jake Carter edited this page Dec 14, 2023 · 1 revision

Debugging Demo Firmware Using MINGW on Windows


OpenOCD and GDB allow loading, debugging and running applications. This section shows how to do this specifically with MSYS on Windows. First, connect to the target with OpenOCD, then you can debug the target with GDB.

Open MinGW console and cd into one of the demo directories:

MAXDAP TYPE-C


Debugging MAX32666 Firmware


1 Connect the debugger/programmer to the MAXREFDES178 Cube Camera

  • MAXDAP-TYPE-C

    Insert the MAXDAP-TYPE-C into MAXREFDES178 MAX32666 (first debug channel). The MAXDAP-TYPE-C and MAXREFDES178 cube camera lens should face same direction.

MAXDAP TYPE-C


  • MAXDAP-TYPE-C DUAL

    When MAXDAP-TYPE-C-DUAL is the debugger/programmer, insert to the MAXREFDES178 as shown in the picture. Both components of the MAXDAP-TYPE-C-DUAL and MAXREFDES178 cube camera lens are facing same direction.

    Connect Micro-USB cable to U1 (first debug channel) of MAXDAP-TYPE-C-DUAL. In the picture, it is shown that a white Micro-USB cable is plugged in. Do not plug a USB cable into U2 (second debug channel) of MAXDAP-TYPE-C-DUAL. (Green cable in the picture shouldn't be connected)


MAXDAP TYPE-C


2 Start OpenOCD for MAX32666:

openocd -s ${TOOLCHAIN_PATH}/OpenOCD/scripts -f interface/cmsis-dap.cfg -f target/max32665_nsrst.cfg

3 When the connection is successful, you will see messages as shown below:


MAXDAP TYPE-C






Debugging MAX78000 Video or MAX78000 Audio Firmware


1 Connect the debugger/programmer to the MAXREFDES178 Cube Camera

  • MAXDAP-TYPE-C

    Insert the MAXDAP-TYPE-C into the MAXREFDES178 second debug channel. The MAXDAP-TYPE-C and the MAXREFDES178 cube camera lens should face opposite directions.

MAXDAP TYPE-C


  • MAXDAP-TYPE-C DUAL

    When MAXDAP-TYPE-C-DUAL is the debugger/programmer, insert to the MAXREFDES178 as shown in the picture. Both components of the MAXDAP-TYPE-C-DUAL and MAXREFDES178 cube camera lens are facing same direction.

    Connect Micro-USB cable to U2 (second debug channel) of MAXDAP-TYPE-C-DUAL. In the picture, it is shown that a green Micro-USB cable is plugged in. Do not plug a USB cable to U2 (first debug channel) of MAXDAP-TYPE-C-DUAL. (White cable in the picture shouldn't be connected)


MAXDAP TYPE-C


  1. Select MAX78000 Video or MAX78000 Audio target with the button ‘Y’.

  1. Start OpenOCD for MAX78000:
openocd -s ${TOOLCHAIN_PATH}/OpenOCD/scripts -f interface/cmsis-dap.cfg -f target/max78000_nsrst.cfg


Debug Target with GDB


1. Open another MinGW console and cd into a demo directory. Launch GDB using one of the following commands:
arm-none-eabi-gdb maxrefdes178_max32666/build/maxrefdes178_max32666.elf
arm-none-eabi-gdb maxrefdes178_max78000_video/build/maxrefdes178_max78000_video.elf
arm-none-eabi-gdb maxrefdes178_max78000_audio/build/maxrefdes178_max78000_audio.elf



  1. Connect GDB to OpenOCD and reset the target:

target remote localhost:3333
monitor reset halt

  1. Load and verify the application:

load
compare-sections

  1. Reset the device and run the application:

monitor reset halt
c

Debugging Applications with GDB


Follow the same steps provided in the Loading and Running Applications on the EV Kit section. While the application is running, use to interrupt the application and halt its execution. The table below lists a few of the commands available to you any time the application is halted:
Command Short Command Description
monitor halt Halt the microcontroller.
monitor reset halt Reset the microcontroller and halt immediately.
monitor max32xxx mass_erase 0 Mass erase the flash.
continue c Continue execution.
break <arg> b <arg> Set a breakpoint. Argument can be function_name, file:line_number,
print <variable> p Print the value of a variable. Variable must be in current scope.
backtrace bt Print contents of the stack frame.
step s Execute the next instruction.
next n Execute the next line of code.
finish f Continue to the end of the current function.
info reg Print the values of the ARM registers.
help Print descriptions for available commands
help <cmd> Print description for given command.




NEXT : App Switcher