Question about project configuration and how it relates to debug_printf working...

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

Question about project configuration and how it relates to debug_printf working...

1,160 Views
dave408
Senior Contributor II

This question is completely unrelated to the other debug_printf issue I just posted a moment ago.

I have two projects, both setup to use PEx and MQX Standard.  One project has "debug console" as an "Inherited component" as shown below:

pastedImage_0.png

The other has "fsl_debug_console" as a "Shared component" as shown below:

pastedImage_1.png

I am pretty sure I created the projects the same way, so I must have done something different afterward, when assigning the UART.  But I don't know what I did.  The former example does not work, while the latter does.  I assume the non-working project isn't working because DbgCs1 is disabled in PEx (to get past the code generation errors due to conflicts), but I don't know how to remove fsl_uart1 and then make DbgCs1 a "shared component".  I tried to delete fsl_uart1 but it doesn't look like it's possible.  I tried to choose a different UART, but that doesn't work -- when I look at DbgCs1, KDS tells me this:

pastedImage_4.png

EDIT -- I just realized by changing from MQX to BareMetal and back, that one project was using MQX Standard (that's what I really want), and the other working project was using MQX Lite.  So to answer part of my question, MQX Lite "shares" the DbgCs1 component, but MQX Standard wants its own.  I vaguely recall reading something about this on the forum (I may have even responded to it...).

So perhaps the solution is to just leave (or delete) DbgCs1, and if that is the case, why is it that when I set up fsl_uart1 for MQX Standard that debug_printf doesn't work?  printf does work properly.

9 Replies

583 Views
FeibiaoZhou
Contributor II

I had the same problem with MQX standard. Thanks for all your suggestion which I followed.

Here are my steps to make the UART0 console work with MQX standard:

1) Delete the DbgCs1 component (right click, delete).

2) Select "MQX Standard" option (through Component Inspector).

3) Click the "Generate Processor Expert Code", this will make Processor Expert to generate the code but the more important is it picks up the "MQX Standard" flag that will enable the include <stdio.h>, which then will define the "printf()" function.

4) Configure the "usrt1:fsl_uart" for Device to "UART0". Without above steps the UART0 will not show as an option.

5) Define UART0 Receiver Pin to DBG_CONSOLE_RX and Transmitter to DNG_CONSOLE_TX.

6) Click the "Generate Processor Expert Code" button again to generate the last version code by the Processor expert.

7) Build the user application and run.

Board: FRDM64F120, KDS 3.0.0, Processor expert 3.0.1, KSDK 1.3.0

583 Views
dave408
Senior Contributor II

Thank you for sharing the details of your solution, Feibiao!  I'm going to give this a try very soon and I will post up my results.  I'll mark your answer as the correct one should everything go well!

0 Kudos

583 Views
marek_neuzil
NXP Employee
NXP Employee

Hello Dave,

The MQX Standard version does not support fsl_debug_console component in the project (this functionality is integrated in the MQX Standard and fsl_debug_console driver is used). When you use MQX Standard and fsl_debug_console in you application the fsl_debug_console driver will not work properly (as you have mentioned).

You can find the following definition in KSDK_1.1.0\platform\utilities\inc\fsl_debug_console.h header file:

#if (defined (FSL_RTOS_MQX) && (MQX_COMMON_CONFIG != MQX_LITE_CONFIG))

#define PRINTF          printf

#define SCANF          scanf

#define PUTCHAR        putchar

#define GETCHAR        getchar

#else

/*Configuration for toolchain's printf/scanf or KSDK version printf/scanf */

#define PRINTF          debug_printf

//#define PRINTF          printf

#define SCANF          debug_scanf

//#define SCANF          scanf

#define PUTCHAR        debug_putchar

//#define PUTCHAR        putchar

#define GETCHAR        debug_getchar

//#define GETCHAR        getchar

#endif

Therefore you can use PRINTF() function in your application and it will work for both variants of MQX (MQX Lite with fsl_debug_console component and MQX Standard).

Best Regards,

Marek Neuzil

583 Views
dave408
Senior Contributor II

Thanks, Marek!  I'll replace with PRINTF and see how that goes across my various projects.

0 Kudos

583 Views
F50SC
Contributor III

Hi dave408

How did you go getting printf with MQX standard?

I've been using MQX Lite with PE debug console for a while without any issues, but now I need another feature of MQX that 's not included with MQX Lite.

I have switched to MQX standard, deleted (or disabled) the PE debug console, and setup the appropriate UART for the target board....However after
compiling and testing it on the target MQX is asserting after calling the first printf statement it encounters......also when printf is called the first function it calls is puts() not printf()....I'm not sure why that is or where this is configured..

I have tried on two different boards with the same result.....a custom board AND also the FRDM-K22F dev board

Has anyone got printf working with MQX standard and wouldn't mind sharing their code?

Freescale????? C'mon need more examples using PEx, Linked & Standlone modes AND also on custom boards or processors not just development boards.

Regards

Jerome

0 Kudos

583 Views
F50SC
Contributor III

Ok so I managed to work out why printf is calling puts() in this definition in mqx_sdk_config.h.
I changed this to 1 to enable the I/O system it now calls debug_printf as per MQX_Lite..
pastedImage_1.png

Although the result is still the same....an assert fires after calling lock_fd_table() from _nio_write()

pastedImage_0.png

0 Kudos

583 Views
F50SC
Contributor III

Update...

Ok so the above problem is when I use printf from int main {}........if I comment out the printf statement, printf functions correctly within the tasks themselves.

So it appears the problem is to do with printf outside an MQX task and from main..

0 Kudos

583 Views
dave408
Senior Contributor II

Hey F50SC​, thanks for posting your findings!

0 Kudos

583 Views
admin
Specialist II

thanks

0 Kudos