I do not know exact answer to your question but I suppose you are struggling with wrong clock settings.
I do not know what exactly you expect you will see but when the code reach this line that means that you have wrong clock settings and every attempt (when you have active all 3, then the board can try one by one) above failed, nothing more. So you need to step into clock settings and check which HAL function returned zero. That tell you which part of settings is probably wrong.
In official is just MSI I suppose you fill another from CUBEMX according to your board.
I’m not struggeling with the clock settings anymore but just wanted to know how you can read the error messages if they would be reached. I see error(…) at several places in the code but how to turn on/off these messages? Just to know because when I have to debug something else i’ts handy to know the procedure. Otherwise the controller is just hanging and you don’t know where and why.
In those links I don’t see any info how to use it. NDEBUG is somewhere defined by default? Do you have to adapt the Cmake file? You set it on and off per module or only globally? Will it work with stdio with the speed and pins defined in your config? Only questions about something looking very essential.
Results are not constentent.
Between each test I also did a hardware reset:
Compile with error(“Test\n”) and no debug option → hanging
Compile with error(“Test\n”) and debug option → hanging
Compile with //error(“Test\n”) and no debug option → Hello world
Compile with //error(“Test\n”) and debug option → Hello world
In the opposite direction I get Hello world until the second line.
It means the behavior of using the debug option is following the last result when compiling without debug option.
To be honest I never used profiles but maybe is necessary to re-compile whole project (I do not know if this is happening automatically when you change the profile in ARM Mbed).
I tried that with MbedCE because I do not use any Mbed offline solution anymore, just KeilsStudioCloud for some help to others.
// I placed this directly to main immediately after a printf with a Start string
// Console output with Debug profile
++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Error Value: 0x0
Current Thread: main Id: 0x20002B44 Entry: 0x8006AF5 StackSize: 0x1000 StackMem: 0x20001B20 SP: 0x20002A9C
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=NUCLEO_F446RE
-- MbedOS Error Info --
// Console output with Release profile
// Console output with Develop profile is same like first one (Debug)
In all cases the program hangs of course and is re-builded (not clean) and recompiled.
Important to know: The default profile is ‘develop’ when no --profile option is given in the command.
If you are using --clean, only the relevant folder is cleaned. It means --clean with --profile debug, the folder debug is rewritten and the folder develop is untouched.
That’s the cause of the strange ‘memory’ behavior.
In development profile I see debug() and error() messages.
In debug profile I see debug() and error() messages.
In release profile I see none of them, but firmware hangs.
This is only working when putting debug() and error() messages in main function as test.
If you put error(“Test\n”) when entering the SetSysClock in system_clock.c you see no error message in all cases. Even if I put a printf(“Test\n”) at this location, the firmware hangs.
So what is the sense to put an error in the code error(“SetSysClock failed\n”) in system_clock.c?
What’s the reason that printf() and error() is not working in system_clock.c?
It looks like you cannot execute error() before the call of mbed_rtos_start();
I have different results. If I put the error(“Test\n”) in main after another printf and compile with debug option I get (as you have) the error in the terminal as expected. If I put error(“Test\n”) in the beginning of SetSysClock funtion, the firmware hangs at that point without anything in the console window. There may be differences in CPU, compiling option etc. I can understand that the error() lines are there to be generic and may work in certain circumstances but this is clearly not always guaranteed.
Maybe another reason could be is that you use different pins for stdio (the standard ones?) and I use a dedicated setting.
One of the things I think on is that is may be possible that this error data is coming out to a different pin and once in main to the pin where my FTDI is connected on. I will make a variant of the same HW (more generic) where I can better test it. But I will not loose too much time because it’s a non blocking issue.