Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Debugging an application in Amazon FreeRTOS(AFR)

Debugging an application in Amazon FreeRTOS(AFR)

PriyaM_16
Moderator
Moderator
Moderator
250 replies posted 100 replies posted 50 replies posted

This blog discusses debugging of the default iot_mqtt_demo(MACRO: CONFIG_MQTT_DEMO_ENABLED) application in aws_demo project in WICED Studio 6.4 using AFR. The process is very similar to debugging in WICED Studio 6.4(non AFR) with some modifications in the debug configurations.

Steps to debug are:

1.  Remove the run flag from the default make target given for aws_demo

demo.aws_demo-CYW954907AEVAL1F-FreeRTOS-LwIP HOST_OS=Win32 download

2. Build the application by double clicking the make target.

3. Currently RTOS thread resolve during debug is not supported for AFR in WICED Studio.  As a work-around, open <wiced_studio_path>\43xxx_Wi-Fi\tools\OpenOCD\BCM4390x.cfg in a file editor and go to the line that has:

$_TARGETNAME configure -rtos auto -rtos-wipe

Remove “-rtos auto” from that line and save the file.

4. Open Run> debug_configurations or click the drop down button next to debug on toolbar and choose debug_configurations

pastedImage_3.png

5. Under GDB hardware Debugging, right-click on "43xxx_Wi-Fi_Debug_Windows” and click “Duplicate”. Change the name in the top of the window to “AFR Debug” or any other name you prefer.

pastedImage_6.png

6. In the “Main tab”

     6.1 click Browse under Project and select “aws_demos” project.

     6.2 Next, under C/C++ Application click "Search Project", select "last_built.elf" and click OK. Make sure it points to the last_built.elf of amazon-freertos. The location  is <afr_installation_path>\amazon-freertos\vendors\cypress\WICED_SDK\build\eclipse_debug\last_built.elf

pastedImage_24.png

7. Go to debugger tab and make sure the GDB command is pointing to the tools directory of your WICED SDK.

pastedImage_8.png

8. Apply the changes in debug configurations and click on debug. If you have connected the board and everything goes well, the debugger will start up and will pause execution in the start_GCC.S file.

pastedImage_190.png

9. You can open main.c and put a breakpoint at the line int main(void ) by double clicking on the left of the line or by right-clicking and selecting Toggle Breakpoint. (A check in front of the breakpoint shows that its an active breakpoint)

Click on the resume button to resume the execution of code and stopping on the next breakpoint. You can also use step in/over commands to step through your application.

pastedImage_0.png

Please note that if you wait indefinitely on a breakpoint inside a thread with a network connection it has a larger chance of getting disconnected. So, stopping execution while there is an active connection should be used sparingly.

Note that we have not modified the make target with the “-debug” flag that we usually use with other WICED Studio projects. The downside of not using -debug is that some variables may be optimized away.

841 Views
Contributors