STM32F4 fails to startup

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32F4 fails to startup

Post by rubenswerk »

Ops, I'm a stupid guy... I flashed the software from the wrong folder all the time.
My own boards works now with the ChibiOS F4 demo, and also with the original ST demo :)

The problem that it sometimes doesn't work with my own software (based on the Chibi demo) remains, but at least I know that the hardware is ok, so debugging should be much easier now.

I wasted several days searching for a hardware problem was was not there, but it was quite interesting. The micro also runs with wrong or even completely missing decoupling capacitors, the external crystal works without the C's and R. Finally I tried to unsolder the micro from the discovery board. I really put high temperature for a long time on it, but it seems that they use power glue to prevent people from unsoldering (the discovery board has about the same price as a single micro at RS). Even after this torture, it still was alive. So it seems to be quite a robust piece of hardware.

I'll hopefully find my software problem soon...
rubenswerk
Posts: 104
Joined: Wed Feb 22, 2012 11:39 am

Re: STM32F4 fails to startup

Post by rubenswerk »

The problem is linked to the compiler option -Os
I wanted to create a small bootloader, so I activated optimization for code size. This saved ~10% in my case. Without that option, everything works just perfect and reliable.

Don't ask me why this option leads to a code which sometimes works and sometimes not.
It is also linked to the overall code size.

I put a while(1) into different places of my main function to see how far it goes before crashing. With the standard makefile, the linker is told to remove all unused functions. Therefore, I got a very small 3kb bin file when the main function ended in an endless loop before doing something senseful. With that option, my board reached the endless loop.
Then I changed the makefile to NOT remove unused code. I got a 25kb bin file, and my program crashed.

I would like to understand where the problem comes from, but I alredy wasted so much time on that, that I prefer to use the standard optimization and forget the story.

Thanks for your support.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 fails to startup

Post by Giovanni »

I'll try -Os on the discovery demo.

Probably it is just increased stack usage, this is pretty common when optimizing for ROM size because the compiler does not aggressively inline static functions anymore, this results in more stack frames.

Giovanni
Post Reply