FreeRTOS+CLI problem when built with -Os optimize for size

I use FreeRTOS+CLI in my project and it works wonderfully when I build with no optimization. But if I turn on size optimization (-Os), then typing ‘help’ results in

Enter ‘help’ for list of commands
helphephel

help:
Lists all the registered commands

If I turn off optimization for just the file having vCommandConsoleTask in it, there is no problem.

Any suggestions?

Which compiler and compiler version are you using?

13.3

I think I found the problem.

vCommandConsoleTask calls cliWrite((char *)&cRxedChar). However, cRxedChar is definied as
int8_t cRxedChar. Function cliWrite is defined as

void cliWrite(const char *str)
{
printf(“%s”, str);
// flush stdout
fflush(stdout);
}

This shouldn’t work in the first place. since cRxedChar is a character, not a string. Optimization merely exposes the issue.

1 Like

Your assessment looks correct. Would you please share link of the code too? Also, assuming that it is a code in one of our repos, are you willing to raise a PR to fix it?

I’ve never helped maintain open-source code before, but I’m willing to try.

1 Like

Let us know if you face any problem.

Like I said, I’ve never done tis before. I suppose a start by cloning a repo, but which one? And I’m not familiar with pull requests, so I need newbie-level guidance.

Where did you get the code you mentioned?

I think I got it from the GitHub niesteszeck/FreeRTOS/tree/master/FreeRTOS-Plus/FreeRTOS-Plus-CLI

But is that an official repo?

Now I remember, I got the FreeRTOSv202406.01-LTS.zip file and found the CLI code there.

I do not think that it is correct. The LTS bundle includes our LTS libraries and that does not include the CLI sample. You can verify that here - Release 202406.01-LTS · FreeRTOS/FreeRTOS-LTS · GitHub.