This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ASSERT message doesn't get printed over UART while debugging in SEGGER EmbStudio

Hello,

I am currently trying out the assert mechanism of Zephyr.

I have added CONFIG_ASSERT=y to my prj.conf file and included "sys/__assert.h" in my main.c.

My program looks something like this:

void main(void)
{
	console_getline_init();
	char * line;

	while (1)
	{
		line = console_getline();
		uint16_t len = strlen(line);

		if(len == 1)
		{
			if(*line == 'a')
			{
				__ASSERT(false, "Assert test");
			}
			else
			{
				// ...
			}
		}
		else if (len == 0)
		{
			printk("getline() returned empty line\n");
		}
		else
		{
			// ...
		}
	}
}

I am using Putty on my PC to communicate with the Thingy-91.

If I am debugging my application by starting the debug context in SEGGER Embedded Studio (Debug->Go), I don't get the assert message in Putty.
I either get nothing or it says UART FRAMING ERROR! CHECK BAUDRATE! 

But if I am running the application without the debug context, I receive the assert message in Putty plus the UART Framing error message, which is correct for these situations I guess.

Why don't I get the assert message while debugging the application?

Parents Reply Children
  • Hello Heidi,

    When I use stepwise debugging and step over an __assert() expression, I get the message on my serial monitor.

    But if I let the application run and I still have the debug context open in SEGGER Embedded Studio, I don't get the assert message.

    If I run the application without any debugging, I get the assert message, but still not every single time.

    It would be nice, if the assert mechanism would provide the message consistently every time an assertion triggers.

    Are there any known issues with the Zephyr assert mechanism?

  • Can you add a printk or similar to the if statement, and see if it gets printed every time?
    If the assert isn't being printed, there might be some kind of race condition that triggers it occasionally.
    You can zip your whole working directory and attach it, and I can try to reproduce what you are seeing and debug it for you.
Related