AnsweredAssumed Answered

Printf fails half way through printing, causing firmware to cease execution?

Question asked by Sean MacKay on Apr 24, 2015
Latest reply on Apr 29, 2015 by Sean MacKay

Hello,

I'm using the KSDK 1.1.0 and KDS 2.0.0 with a FRDM-K64F development board, running a new project I started with the guide in this discussion (How To: Create a New MQX RTOS for KSDK Project in KDS) I'm using the J-Link emulator with firmware 4.92 to debug. I can compile and run sample applications fine, or the Hello World application included in the linked post. However, when I then try to make a more complex project I'm running into an issue where my code ceases execution part way through printing a printf statement. I'll get partial output before debugging crashes and execution ceases like below. Flashing instead of debugging also does the same:

 

When the Hello and World tasks run first, I get this:

" Hello

World

Main task has started.

 

C"

 

And when I lower their priority I get this:

"Main task has started.

 

Config loaded, confi"

 

And when I remove them completely I get:

"Main task has started.

 

Config loaded, config" (One extra character).

 

(It should be printing "Config loaded, configID %d and errors %d" with 10 and 0, respectively.)

 

When I remove the config code and jump to the message queue code I instead get:

"Main task has started.

Initializing message que"

 

And there's no real code above that print so it seems to just freeze up on print calls.

 

I see in the debugger that _task_set_error() is entered, but in the Task List both the Main and _mqx_idle_task are OK with no error code.

 

In fact, I've removed almost all code except the printf statements, so it seems to be related to that that causes the crashing. Here is the most pared down code I've tried that still causes the error stopping at

"Main task has started.

Initializing message que"

 

 

 

 

#include <stdio.h>
#include <mqx.h>
#include <bsp.h>


void messaging_init(void);




void main_task(uint32_t temp)
{
  uint32_t  error, file_error;
  printf("Main task has started.\n");


  messaging_init();
}


void messaging_init(void)
{
  uint32_t result;
  printf("Initializing message queues...\n");
}

 

 

Thanks,

Sean

Outcomes