Can I program/debug a target via network in Modus ToolBox?

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

cross mob
bemale
Level 3
Level 3
100 sign-ins 50 sign-ins 25 sign-ins

Hello,

I would like to set a development env. up as following.

Workstation(installed Modus ToolBox) ---------(LAN)--------My laptop (target board with USB connection)

So, I want to edit/build source code on Workstation and flash/debug from my laptop side.

Is it possible? It means that Modus ToolBox can support a functionality for remote program/debug. 

Thanks~

0 Likes
1 Solution
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @bemale

I received an update from the internal team. 
OpenOCD is a GDB Server so it supports remote programming and debugging via GDB out of the box. In order to enable remote debugging please follow the steps below - 

Laptop (PC with target connected) -

Open the command prompt, traverse to the <ModusToolbox_installation_directory>\tools_2.3\openocd\bin\ directory and then run the following command - 

openocd -f interface/kitprog3.cfg -f target/<target_cfg_file> -c "bindto 0.0.0.0"

Replace the <target_cfg_file> with your target configuration file. The target configuration file can be found within the Config options in the Debugger tab of the Debug Configurations window. To open Debug Configurations, - click on Run tab in Eclipse IDE for ModusToolbox > Debug Configurations GDB OpenOCD Debugging <application_name> Debug (KitProg3_MiniProg4)

Rakshith_4-1623697914977.png

Workstation PC

1. In Eclipse IDE for ModusToolbox, click on Run tab > Debug Configurations GDB OpenOCD Debugging <application_name> Debug (KitProg3_MiniProg4)

Rakshith_0-1623696819612.png

2. Click on the Debugger tab.

3. Uncheck Start OpenOCD locally

Rakshith_1-1623696969069.png

4. Under the Remote Target section provide the IP address of your laptop (PC with target connected) and change the port number to 3334 -

Rakshith_2-1623697182685.png

5. Next click on the Startup tab. Enable Initial Reset and add the following command - 

mon psoc6.cpu.cm4 configure -rtos auto -rtos-wipe-on-reset-halt 1

Rakshith_3-1623697338305.png

6. Click on Apply and then click on Debug

In this case, elf file is loaded by GDB and then GDB passes this data to OpenOCD via remote connection. To program the device, you could transfer the hex file to the laptop using a post-build script and then run OpenOCD to program the device on the laptop as mentioned before or add the GDB quit command to the same configuration. In the latter case, you are starting a debug session that programs the device and then stopping the session.

This information will be added to the User Guide in the next update.

Hope this helps,

Thanks and Regards,
Rakshith M B

View solution in original post

3 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @bemale

Currently, ModusToolbox does not have support for remote programming/debugging. 
But you could try running a post-build script to transfer the hexfile to your laptop. For programming, you could run the make program command or directly use OpenOCD and this could still work. For debugging it would be a bit difficult as you will need gdb to run in parallel too. 

I will create an enhancement ticket so that the internal team can evaluate your request.

Thanks and Regards,
Rakshith M B
bemale
Level 3
Level 3
100 sign-ins 50 sign-ins 25 sign-ins

Thanks for your quick response~

Please let me know the feedback from your internal team when you get some information.

0 Likes
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi @bemale

I received an update from the internal team. 
OpenOCD is a GDB Server so it supports remote programming and debugging via GDB out of the box. In order to enable remote debugging please follow the steps below - 

Laptop (PC with target connected) -

Open the command prompt, traverse to the <ModusToolbox_installation_directory>\tools_2.3\openocd\bin\ directory and then run the following command - 

openocd -f interface/kitprog3.cfg -f target/<target_cfg_file> -c "bindto 0.0.0.0"

Replace the <target_cfg_file> with your target configuration file. The target configuration file can be found within the Config options in the Debugger tab of the Debug Configurations window. To open Debug Configurations, - click on Run tab in Eclipse IDE for ModusToolbox > Debug Configurations GDB OpenOCD Debugging <application_name> Debug (KitProg3_MiniProg4)

Rakshith_4-1623697914977.png

Workstation PC

1. In Eclipse IDE for ModusToolbox, click on Run tab > Debug Configurations GDB OpenOCD Debugging <application_name> Debug (KitProg3_MiniProg4)

Rakshith_0-1623696819612.png

2. Click on the Debugger tab.

3. Uncheck Start OpenOCD locally

Rakshith_1-1623696969069.png

4. Under the Remote Target section provide the IP address of your laptop (PC with target connected) and change the port number to 3334 -

Rakshith_2-1623697182685.png

5. Next click on the Startup tab. Enable Initial Reset and add the following command - 

mon psoc6.cpu.cm4 configure -rtos auto -rtos-wipe-on-reset-halt 1

Rakshith_3-1623697338305.png

6. Click on Apply and then click on Debug

In this case, elf file is loaded by GDB and then GDB passes this data to OpenOCD via remote connection. To program the device, you could transfer the hex file to the laptop using a post-build script and then run OpenOCD to program the device on the laptop as mentioned before or add the GDB quit command to the same configuration. In the latter case, you are starting a debug session that programs the device and then stopping the session.

This information will be added to the User Guide in the next update.

Hope this helps,

Thanks and Regards,
Rakshith M B