cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 bootloader ''limiitation''.....

re.wolff9
Senior
Posted on January 23, 2015 at 15:58

Hi, 

I think I've found a ''bug'' in the bootloader. 

AN2606 documents for '051 chips on page 58 that: [quote] When the user application configures a value of HSI TRIM bits (in RCC_CR register) and then jumps to the  bootloader, the HSITRIM value is reset to its default value (0) at bootloader startup[/quote]

The same thing seems to happen for the 072 bootloader. 

But that isn't the problem... The problem is that the HSI TRIM default is not 0 but 16. This results in the CPU running about 40kHz * 16 = 640 kHz slower than the 1% calibrated 8MHz..... Apparently ''autobauding'' for the serial ports and ''crystalless USB'' end up compensating for this so that nobody has noticed that the bootloader runs at a multiple of 7.3MHz instead of 8MHz. 

All this isn't really a problem until you let the bootloader jump to your application and then end up with baud rates that are off by ''too much''. 

P.S. I checked the datasheet for the '51 and it too has ''16'' as the default HSITRIM. 

#nmp
5 REPLIES 5
Posted on January 23, 2015 at 17:45

The user application code really needs to configure it's environment the way it wants and be agnostic to initial conditions.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
re.wolff9
Senior
Posted on January 28, 2015 at 10:51

Clive, 

I'm really sorry, but now you're pissing me off. 

There is no reason for the bootloader to mess with the internal clock settings. The bootloader tries to ''clean up'' after itself and resets  the register ''to its reset value'' as documented under ''limitations'' for the '051. However someone at ST didn't read the manual properly and the reset-to-zero is NOT the reset value. 

Why do you document ''reset values'' for registers? That's so that you can optimize. Some registers do not need initializing because their reset value is already as you want it. 

But even then, a processor like the STM32-series is so complicated with over 1000 pages of ''reference manual'' that it is impossible for normal humans to read through and remember everything. So the processor is and needs to be designed so that many modules that a user won't need are initialized in a way that it is not necessary to read the manual for that module. 

So now there is a register documented as: ''reset value is 16'' and that's exactly what I want. For future compatibility, do I explicitly write it to 16 because that's what I want, or do I leave it ''at reset value'' to keep as much future-compatibility as possible?

The bootloader is documented to be able to boot from several devices and it is documented to leave those devices in a possibly enabled state when leaving the bootloader. However, This is not mentioned. 

The proper response is: ''You might be right, we'll investigate, and if it turns out you're right, we'll document it as a ''limitation'' and fix it for future revisions. Thank you for reporting this''. 

Saying: ''it is all your fault!'' is not making any friends. 
Posted on February 26, 2015 at 09:17

Hi Roger,

Thank you for reporting this issue, we confirm that reset value is not set correctly when Bootloader jumps to user application (0x03 instead of 0x83).

This limitation will be reported in next release of AN2606.

We apologize for any disagreement.

Regards,

Heisenberg.

Posted on February 26, 2015 at 13:05

I'm really sorry, but now you're pissing me off. 

Whatever, I have no responsibility with regard to this, and even less to the hundreds of thousands of parts that are ROM'd with code that isn't doing what you'd like. Fixing new devices won't address anything that you'd still need to address yourself. Your best course of action is to identify, in your code, devices that have zero written into the register and change it to 16 or whatever you think is a more reasonable default.

The proper response is: ''You might be right, we'll investigate, and if it turns out you're right, we'll document it as a ''limitation'' and fix it for future revisions. Thank you for reporting this''.

From whom? Who would give you such a response, and where do I fit into that matrix?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on February 26, 2015 at 14:55

> where do I fit into that matrix?

Well, apparently, you are The Keymaker, Clive... 😉

(Sorry, I couldn't resist.)

Jan