Semi-Hosting in Kinetis Design Studio with MQX

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

Semi-Hosting in Kinetis Design Studio with MQX

Jump to solution
1,794 Views
jschepler
Contributor III

Hello,

When I build a baremetal project in Kinetis Design studio using the KSDK I can successfully get semi-hosting to work with printf outputs on the console inside of KDS. This is configured in the Debug Configuration > PEMicro Debugging > Startup tab.  I enable semi-hosting and route it to Telnet.  It works great!

 

However, I have another project that uses the MQX OS for Kinetis, and I cannot get the semi-hosting feature to work.  We have custom hardware built around the K64F processor and do not have any UART pins.  Does anyone have any tips on getting semi-hosting to work in Kinetis Design Studio using the KSDK and MQX? 

 

Any help would be appreciated!  Thanks!

Labels (1)
0 Kudos
1 Solution
874 Views
harlan86
Contributor I

I'm coming to the same problem and found 2 solutions for semihosting with MQX.

1. Use iodebug driver that coming with full version of MQX (i tried with 4.2).

The FSL_MQX_getting_started document showed possibility for use semihost with MQX  (chapter 5)

It refer to the document Freescale MQX™ RTOS I/O User's Guide (MQXIOUG) about description.

MQX_IO_User_Guide at chapter 26 describe usage example for iodebug  driver.

The MQX 4.2 have example project Freescale_MQX_4_2\mqx\examples\io that could be run with K64F.

What is need to be changed it's a installing driver for semihost during main_task run like a

   _io_debug_install("iodebug:", &_bsp_iodebug_init);

with _bsp_iodebug_init that define semihost option.

And BSP must be compiled with options

#define BSP_DEFAULT_IO_CHANNEL "iodebug:"

#define BSPCFG_ENABLE_IODEBUG 1

Also ttya/ttyb output could be removed if not needed.

With it semihost worked. 

I guess iodebug could be ported more or less easy to the another version of MQX (for example MQX from KSDK that don't have io, but use nio instead, so iodebug need to be ported with sybsystem)

2.  Use direct semihost stdio. The example below is for KSDK 1.3.

The list of changes are next:

a) Do a declaration of init routine:

extern void initialise_monitor_handles(void);

b) In the beginning of the main_task call

initialise_monitor_handles();

c) Cross ARM C Linker/Libraries

Remove nosys library

d) Cross ARM C Linker/Miscellaneous

Remove from 'other objects' ${ProjDirPath}/../../../../../../rtos/mqx/lib/frdmk64f.kds/debug/mqx_stdlib/lib_mqx_stdlib.a

Remove option Cross reference (-cref)

Other linker flags:

Add --specs=rdimon.specs

Remov -Xlinker -z -Xlinker muldefs --specs=nano.specs

Increase stack size.

With above changes I am able to get semihost even without commenting _read and _write routines from the fsl_debug_console.c

View solution in original post

7 Replies
875 Views
harlan86
Contributor I

I'm coming to the same problem and found 2 solutions for semihosting with MQX.

1. Use iodebug driver that coming with full version of MQX (i tried with 4.2).

The FSL_MQX_getting_started document showed possibility for use semihost with MQX  (chapter 5)

It refer to the document Freescale MQX™ RTOS I/O User's Guide (MQXIOUG) about description.

MQX_IO_User_Guide at chapter 26 describe usage example for iodebug  driver.

The MQX 4.2 have example project Freescale_MQX_4_2\mqx\examples\io that could be run with K64F.

What is need to be changed it's a installing driver for semihost during main_task run like a

   _io_debug_install("iodebug:", &_bsp_iodebug_init);

with _bsp_iodebug_init that define semihost option.

And BSP must be compiled with options

#define BSP_DEFAULT_IO_CHANNEL "iodebug:"

#define BSPCFG_ENABLE_IODEBUG 1

Also ttya/ttyb output could be removed if not needed.

With it semihost worked. 

I guess iodebug could be ported more or less easy to the another version of MQX (for example MQX from KSDK that don't have io, but use nio instead, so iodebug need to be ported with sybsystem)

2.  Use direct semihost stdio. The example below is for KSDK 1.3.

The list of changes are next:

a) Do a declaration of init routine:

extern void initialise_monitor_handles(void);

b) In the beginning of the main_task call

initialise_monitor_handles();

c) Cross ARM C Linker/Libraries

Remove nosys library

d) Cross ARM C Linker/Miscellaneous

Remove from 'other objects' ${ProjDirPath}/../../../../../../rtos/mqx/lib/frdmk64f.kds/debug/mqx_stdlib/lib_mqx_stdlib.a

Remove option Cross reference (-cref)

Other linker flags:

Add --specs=rdimon.specs

Remov -Xlinker -z -Xlinker muldefs --specs=nano.specs

Increase stack size.

With above changes I am able to get semihost even without commenting _read and _write routines from the fsl_debug_console.c

874 Views
BlackNight
NXP Employee
NXP Employee

Hi Jason,

I believe MQX is overwriting the _read() and _write() methods, and then semihosting won't work because it uses the wrong hooks. The Kinetis SDK has the same problem and prevents semihosting, see https://mcuoneclipse.com/2016/04/09/semihosting-with-eclipse-and-the-nxp-kinetis-sdk-v2-0/ . I suggest you check where it implements _read() and _write() and as outlined in that article you change the MQX implementation.

I hope this helps,

Erich

0 Kudos
874 Views
jschepler
Contributor III

Hi Erich,

Thank you for the response! I checked out the blog and it made a lot of sense, unfortunately it didn't work for us.

We are using KDS 3.0.0 and KSDK 1.2.0, and we actually do not have the fsl_debug_console.c file in our project.  We have fsl_debug_console.h, but not the .c file.

When we tried to remove the multi-definition command our project failed to build.

0 Kudos
874 Views
jschepler
Contributor III

I have found where _read and _write are located in the MQX Implementation:

SDK/rtos/mqx/mqx/source/nio/src/nio_std_adpt.c

Then the _read calls the read function located in:

SDK/rtos/mqx/mqx/source/nio/src/nio_posix.c

and the _write calls the write function located in:

SDK/rtos/mqx/mqx/source/nio/src/nio_posix.c

When I add #include <stdio.h> I do not see another _read or _write added to the files.  My understanding from reading the blog page was that it was going to add another instance of _read and _write.  However, I do not see this being added.

I also do not see a function named read or a function named write when adding <stdio.h>.

0 Kudos
874 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Jason,

I also test it , for the library on the C Linker is not the same as Erich's demo , and

when  change it , build, it will have error ,so i also failed .

And there have 5 UART, and does no one can not use? And you can through the

"Expressions" to check the variable .

If also have not resolved , you can tell me you want print what .

Hope it helps

Alice

0 Kudos
874 Views
jschepler
Contributor III

Hi Alice,

Thanks for the reply.

Our board is already maxed out on the pin count.  We don't have any spare I/O to use as a UART. 

The issue with using the "Expressions" to view variables is that you must pause the program to view the values.  We require having printf statements in the IDE so we can view the status of tasks real-time. 


If you are able to get this resolved please post back and I will mark it as correct.

0 Kudos
874 Views
DavidS
NXP Employee
NXP Employee
0 Kudos