"SetSysClock failed" on STM32L432 custom board

I have built a custom board for the STM32L432KC microcontroller. Before designing the board, I used the Nucleo-L432 development board for testing. The Nucleo board has an external oscillator, but the datasheet for it claims it will default to the internal oscillators if the external is not detected. Because my circuit is very small, relatively simple, and has no serious timing constraints, I had planned on using the internal oscillators to simplify my circuit and keep my cost low.

My code uses the Mbed framework and runs fine on the Nucleo dev board. I’m not new to Mbed, but I’m also not an expert. This board is a new iteration of an older circuit using the STM32F302k8 microcontroller which was programmed using Mbed which is why I’m using this framework. I was not the original developer of this but worked with him on it before he left the project. For reference, I am using the PlatformIO IDE for development, but as far as I can tell this seems like an Mbed issue.

Heres my problem… When I try to upload to my custom board I get an Mbed error message and it immediately hangs after getting this message:

++ MbedOS Error Info ++
Error Status: 0x80FF0100 Code: 256 Module: 255
Error Message: Fatal Run-time error
Location: 0x8003A47
Error Value: 0x0
Current Thread: <unnamed> Id: 0x0 Entry: 0x800230D StackSize: 0x0 StackMem: 0x8003A9D SP: 0x2000FF6C 
For more info, visit: https://mbed.com/s/error?error=0x80FF0100&tgt=NUCLEO_L432KC
-- MbedOS Error Info --
SetSysClock failed

I am able to upload using the Arduino framework with no problem so it seems like it cant be that big of an issue and it ran on the old mictocontroller just fine. To deduce the issue, I have been trying to upload an empty program, but the issue persists so it can’t be any libraries or functions I am using. As far as I can tell, it seems like it has to be an issue with configuring the clock source but I’ve gone down the rabbit hole trying just about anything I can. Mind you I’m a little green on Mbed so the complex stuff is more of a trial and error/just poking around.

I found these git issues with other microcontrollers in the same family which seem like they could very well be the same issue:


These examples are for slightly different chips in the STM32L4 family but I tried implementing a similar fix on mine without success, mind you I’m not sure I 100% know what I’m doing at that level but I’m still getting the exact same results.

Any insight you can provide would be greatly appreciated! This is driving me nuts!

Hi

Is it possible to try https://github.com/ARMmbed/mbed-os/commit/5188ae1b309b017dc3d8f8bae0319da470e583d6
?

Thx

Jerome

I just implemented that change and unfortunately the same error still persists…

Does it seem to you that this is a similar error to the other ones?

Need more info.

What do you change in mbed_app.json ?
Do you change NUCLEO HW solder bridges ?

I have not changed any jumpers on the Nucleo. As soon as I can get to work will try to remove the external oscillator to verify that it is causing the issue on the other board.

As for the mbed_app.json, platformIO didn’t used to support them but upon research, I found that they do now. In its absence I have been trying a variety of build flags but honestly I am having a hard time finding documentation as to which I should be using and if this should be causing the error. It is my understanding the chip should default to the internal oscillator if there is nothing else but understand that this may not be sufficient with Mbed without setting anything else. I do know that the PlatformIO board definition for this chip defines the cpu as 48000000L which is what the Nucleo is set up for I guess. I have a bit of confusion about that is that I thought the cpu speed was a function of the clock configuration so I don’t know what outright defining a cpu speed is supposed to do. Sorry my knowledge in this area is somewhat lacking.

As soon as I can remove the oscillator to try to recreate the problem I will report back.

1 Like

Hi Jerome,

I am seeing this issue too… I have a binary that works on the L432 Nucleo,. It also works on one of my custom boards, but not on another, and they are bascially the same, except some IO.

I have removed the external 32kHz from both my custom designs, one works one doesnt, so I dont think thats the issue.

I am now working though IO difference. One design has some pins that have weak pulldowns externally which the other doesnt. Like wise for some weak pull ups.

My assumption is that I am pulling a pin in one direction on one board but not on another, and that it makes a difference at reset. I’ve gone through all the pins, and I cant find anything yet.

Having ruled out the Oscillator, what else is likely to cause SetSystemClock to fail?

Thanks,
Chris

Hi
I am sorry, I think you will need to start debugger…

Hi Jerome, thanks for the reply.

Agree that debugging would be good. As the samebinary* works on all nucleo boards i have, in all of my first custom design, and then in only half of the next design, it sounds to me like looking at the source/assembly isn’t the place to start. I would expect it to always fail if there is a functional bug in the code.

I currently have 10 of my custom boards… 4 work, 6 don’t all with the same binary. So what I was hoping for some insights into from your experience, is whether there are some corner cases to look out for.

I have checked all the GPIO to make sure I don’t have a pull up/down on a pin that is used for configuration, so was hoping there might be a marginal “gotcha” that I’m not aware of.

Cheers,
Chris

I am not an expert, but maybe you can have a look on:

And change the value to check