[K32W061] How to debug CHIP Lighting Example Application in MCUXpresso

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[K32W061] How to debug CHIP Lighting Example Application in MCUXpresso

2,353 Views
Yul81
Contributor II

Hi,

I followed the Getting started with K32W0x1 in Matter (K32W0X1-MATTER-QSG.pdf) guide. In chapter 4.4 explains how to debug with MCUXpresso. I followed the steps, and I was able to connect MCUXpresso with the DK6-K32W061 EVK board; thus, I have the chip-kw32w0x-light-example running in the board. My question is how can I debug step by step and follow with the code? Is that possible? As you can see in the picture source is not found. Maybe I am missing something. 

Thanks in advance

0 Kudos
5 Replies

2,256 Views
razvan_micu
NXP Employee
NXP Employee

Hi Julian,

Thank you for reaching out. From what I can see in the picture you provided, the project was not properly imported in MCUXpresso. If you look in the Project explorer tab on the top-left corner of the window, there is only the examples folder, if the Matter folder is imported correctly the Project explorer tab should look like in the bellow capture:    successfull_import.png

In order to help me narrow down the issue, can you right click on the project name > Show In > System Explorer and check if the opened folder contains all the files and folders present in the repository here ?

Alternatively, if all files and folders are present, can you try to go through the Debugging steps in a new workspace ? This is to make sure there is no faulty configuration in the current one that is causing this issue.

You can simply create a new workspace when you start MCUXpresso. You will be asked to chose a directory as workspace, press "Browse.." and when the current workspace folder opens go up a folder. There you can create a new folder and choose it as workspace directory, MCUXpresso will automatically do all the necessary configurations after this.

 

Best regards,

Razvan

0 Kudos

2,231 Views
Yul81
Contributor II

Hi, thanks for your response.

As you mentioned I had incorrectly imported the matter repository. I did import it correctly now or so I think so. I am using the matter v1.0-branch-nxp I also used a new workspace as you suggested but the result is the same as shown in the attached image. Is there any other thing that I am missing? 

0 Kudos

2,221 Views
razvan_micu
NXP Employee
NXP Employee

Hi,

Thank you for the confirmation, now that you are using the correct project folder I was able to replicate the issue. Unfortunately the pdf document is missing a step in the debugging chapter.

Since the K32W061 build for the lighting-app has the OTA feature enabled by default, the board flash needs to be written from address 0x0 to 0x4000 with a SSBL (second stage bootloader) described in chapter 4.2 of the document.  

In order to flash the board correctly and be able to debug the app you have two options:

1. Deactivating the OTA feature

     If you do not need the OTA feature you can deactivate it in the build command and rebuild the app without it:

$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"platform\" chip_with_se05x=0 chip_pw_tokenizer_logging=true chip_enable_ota_requestor=false"
$ ninja -C out/debug
$ $NXP_K32W0_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/

     After rebuilding the app without OTA you can perform the exact same steps and you should be able to debug the app without any other modification.

     Additionally, since the OTA feature is disabled, you can also disable the log tokenizer by setting pw_tokenizer_logging=flase in the command above.

2. Changing the MCUXpresso project configuration

    If you want to use the default app configuration, including the OTA feature, you will need to first write the SSBL binary and PSECT information on the board as described in section 4.3 ->"Flashing the application using DK6Programmer"

    After writing the SSBL and PSECT you will need to modify the MCU setting to change the flashing start address to 0x4000

flash_location.jpg

After applying the changes you can check that the configuration was correctly updated in Debug Configurations -> <your-config-name> -> GUI Flash Tool -> Program tab -> Options -> Base address field. If correctly modified it should look like bellow:

base_addr.png 

Lastly, you will need to change the Erase algorithm from "Mass erase" to "Erase by sector", otherwise MCUXpresso will erase the entire flash, including the previously written SSBL and PSECT, before writing the app. This can be done also from Debug Configurations -> <your-config-name> ->GUI Flash Tool -> Erase tab-> Algorithm section:

erase.png

After this the debugger will take you to the main.cpp file and you will be able to go through the code step by step.

Let me know if you encounter any issues while performing any of the two approaches.

Best regards,

Razvan

 

0 Kudos

2,204 Views
Yul81
Contributor II

By following your instructions, I was able to debug the application just once. After that I am getting into the issue shown in the attached image and I haven't been able to debug again. I have tried re-flashing the board with the SSBL and PSECT, restarting the MCUXpresso, even debugging just an example application from the SDK and then try again and no luck. Did I screw something?

0 Kudos

2,129 Views
razvan_micu
NXP Employee
NXP Employee

Hi, usually this sequence occurs if the board is manually reset with the debugger attached and the app should resume when pressing the run button. If I understand correctly, no matter what app is flashed, the board is stuck in this state?

As per the SSBL/PSECT flashing it seems it was done correctly otherwise you will not be able to see the code execution trace.

If the issue persists we can schedule a debug session at a time that is best suited for you. I am based in Bucharest, Romania on the UTC+3 time zone, let me know what time frame works best for you.

Regards,

Razvan 

 

0 Kudos