Semihosting for e200

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

Semihosting for e200

Jump to solution
3,005 Views
yveslhuillier
Contributor I

Seems that everything is almost ready to setup semihosting I/Os for powerpc;

except maybe a C IO library implementation relying on DNH (debug notify halt) instructions.

Is there any project to have this up & running ?

... Especially for the pemicro multilink universal fx probe I'm using now ?

Labels (2)
0 Kudos
1 Solution
2,174 Views
stanish
NXP Employee
NXP Employee

Hi Yves,

Indeed  semihosting is now supported in S32DS for Power v1.2.

Just create a new project and select "Debugger Console" -> I/O Support:

pastedImage_1.png

Now add some I/O e.g. printf() into your project:

pastedImage_5.png

The debug configurations created by the project wizard should have semihosting option already enabled so you can just press debug button:

pastedImage_3.png

When the debug session is established switch the console to "Semihosting Console" and check the output. You should observe printf() outputs within the console:

pastedImage_4.png

This feature is implemented by using system call  "se_sc" instruction. It's supported by both NewLib/EWL libs.

pastedImage_6.png

This instruction is executed by low level printf/scanf I/O functions: sys_read* / sys_write*

"<S32DS_Power_v1.2>\S32DS\e200_ewl2\EWL_Runtime\src\pa\semihosted_console_io.c"

e.g.:

/*
 * sys_writec - write a character to the console via semihosting interface
 *
 */
void sys_writec(register void *cp) _EWL_WEAK _EWL_DO_NOT_INLINE;
void sys_writec(register void *cp)
{
 // r0 = 4 (OsWrite)
 // r3 = file handle returned from system call open(...)
 // r4 = character buffer cast as void* pointer
 // r5 = number of bytes (nbyte) to write 
 int value;
#ifdef __VLE__
 __asm volatile ("se_li 0, %1; se_mr 3, %2; se_mr 4, %3; se_mr 5, %4; se_sc; se_mr %0, 0"
 :"=kregs" (value)
 :"i" (Semihosting_Write), "kregs"(((semihost_readwrite_parms *)cp)->handle), "kregs"(((semihost_readwrite_parms *)cp)->data), "kregs"(((semihost_readwrite_parms *)cp)->count)
 :"r0", "r3", "r4", "r5");
#endif 
}

Pemicro recognizes several parameters stored in registers R0 - R5 and transfers the data to/from MCU memory and reads/displays them on semihosting console.

 

There is a default exception handler IVOR8  to to recognize semihosting request:

VEC_ALIGN;
PPCASMF( IVOR8_Vector: );
PPCASMF( se_illegal ); /* for semihosting support */
PPCASMF( se_rfi );

Hope it helps.

Stan

View solution in original post

0 Kudos
1 Reply
2,175 Views
stanish
NXP Employee
NXP Employee

Hi Yves,

Indeed  semihosting is now supported in S32DS for Power v1.2.

Just create a new project and select "Debugger Console" -> I/O Support:

pastedImage_1.png

Now add some I/O e.g. printf() into your project:

pastedImage_5.png

The debug configurations created by the project wizard should have semihosting option already enabled so you can just press debug button:

pastedImage_3.png

When the debug session is established switch the console to "Semihosting Console" and check the output. You should observe printf() outputs within the console:

pastedImage_4.png

This feature is implemented by using system call  "se_sc" instruction. It's supported by both NewLib/EWL libs.

pastedImage_6.png

This instruction is executed by low level printf/scanf I/O functions: sys_read* / sys_write*

"<S32DS_Power_v1.2>\S32DS\e200_ewl2\EWL_Runtime\src\pa\semihosted_console_io.c"

e.g.:

/*
 * sys_writec - write a character to the console via semihosting interface
 *
 */
void sys_writec(register void *cp) _EWL_WEAK _EWL_DO_NOT_INLINE;
void sys_writec(register void *cp)
{
 // r0 = 4 (OsWrite)
 // r3 = file handle returned from system call open(...)
 // r4 = character buffer cast as void* pointer
 // r5 = number of bytes (nbyte) to write 
 int value;
#ifdef __VLE__
 __asm volatile ("se_li 0, %1; se_mr 3, %2; se_mr 4, %3; se_mr 5, %4; se_sc; se_mr %0, 0"
 :"=kregs" (value)
 :"i" (Semihosting_Write), "kregs"(((semihost_readwrite_parms *)cp)->handle), "kregs"(((semihost_readwrite_parms *)cp)->data), "kregs"(((semihost_readwrite_parms *)cp)->count)
 :"r0", "r3", "r4", "r5");
#endif 
}

Pemicro recognizes several parameters stored in registers R0 - R5 and transfers the data to/from MCU memory and reads/displays them on semihosting console.

 

There is a default exception handler IVOR8  to to recognize semihosting request:

VEC_ALIGN;
PPCASMF( IVOR8_Vector: );
PPCASMF( se_illegal ); /* for semihosting support */
PPCASMF( se_rfi );

Hope it helps.

Stan

0 Kudos