SWO output bug on RT1024 - \n not handled properly in newlib (semihost)

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

SWO output bug on RT1024 - \n not handled properly in newlib (semihost)

849 Views
davenadler
Senior Contributor I

I'm debugging on RT1024EVK with a Segger J-Link using SWD (this is a separate debug probe, not the built-in debugger on the EVK). Debugging works great, with much faster software load than the built-in debugger. However, there's an SWO output bug on this platform. I'm working with a project based on EVK USB-FreeRTOS example...

printf is redirected to SWO (using the peripheral tool, Debug Console, set debug console functions type to “Toolchain” (from SDK), and set Serial Port Type to SWO (from UART)). A printf ending in \n prints text with a newline in the console, but then repeats the last 4 characters printed with a 2nd newline (see example below).

  1. Does anyone have a fix for this bug?
  2. In what code is output from printf redirected to SWO?

Thanks!
Best Regards, Dave

 

// Semihost output over SWO Bug:
// After each newline, prints line, newline, and then last 4 characters of line and another newline
printf("Line 1one\n");
printf("Line 2two\n");
//==Creates output like this==
// Line 1one
// 1one
// Line 2two
// 2two
// Bug specific to newline semihosting; redlib does not do this.

 

 

Update: This bug happens with newlib (semihost), but does not happen with Redlib (semihost-nb).
Unfortunately redlib is only for older C-only projects, not modern C++ as many of us require.

Labels (1)
Tags (3)
0 Kudos
6 Replies

800 Views
davenadler
Senior Contributor I

@jingpan- Did you test with SWO (external debug pod using this signal) and newlib-semihost?
Otherwise you will not see this bug.
This problem is absolutely not related to the clock rate (I did test with slow clock).
I clarified the question, please review...

0 Kudos

793 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @davenadler ,

I have a jlink plus and I also use the newlib semihost. But the hello_world_swo works fine.

I guess there is some software problem, buffer overlap for example. The newlib is from GNU and redlib from NXP. We recommend our customer use redlib. Our demo is also works better on redlib.

 

Regards,

Jing

0 Kudos

782 Views
davenadler
Senior Contributor I

Retested with FreeRTOS Hello example from SDK 2.13:
Selected newlib-semihost for managed linker library, and verified bug still occurs.

 

0 Kudos

724 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @davenadler ,

Here is my test project. It seems no problem. You can modify on it.

 

Regards,

Jing

0 Kudos

788 Views
davenadler
Senior Contributor I

Once again, NXP still has not updated redlib to support C++,
so those of us (many) who code in C++ cannot use redlib.

You guess there is some software problem? Really?

0 Kudos

811 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @davenadler ,

There is a hello_world_swo demo in RT1024 SDK. Have your refer to it? I tested on my board, it works fine, both MCUxpresso and keil. The swo clock is set to 4M in this demo. I think most of display problem is caused by the clock too much high.

 

Regards,

Jing

0 Kudos