1725 views|20 replies

1127

Posts

17

Resources
The OP
 

How does the STM32 Bootloader know the frequency of the crystal you soldered? How does it make the judgment? [Copy link]

 

Many STM32 chips have USB upgrade function, so how does the Bootloader know how many M crystal oscillators you have soldered?

Then the USB frequency happens to be multiplied to 48M?

Most STM32s require an external crystal oscillator to use the USB function, and only a few support crystal-free USB function.

Is it determined by the USB sof signal or the built-in RC clock?

I think I used 8M and 12M before, no problem.

I write my own program and I know my own crystal oscillator, but how does the bootloader detect it?

This post is from stm32/stm8

Latest reply

Yes, there is not much information above , just a general description www.tsingmicro.com   Details Published on 2024-2-23 09:52
 

6742

Posts

2

Resources
2
 

The bootloader should use the internal high-speed crystal oscillator.

This post is from stm32/stm8

Comments

When using USB for DFU upgrade, an external crystal must be used. For example, the STM32H7 manual says that it does not support USB operation without a crystal oscillator. Similarly, the STM32F072 supports USB function without a crystal oscillator. So your statement is not valid.  Details Published on 2024-2-22 09:14
 
 

1127

Posts

17

Resources
3
 
wangerxian posted on 2024-2-22 09:12 The bootloader should use the internal high-speed crystal oscillator.

When using USB for DFU upgrade, you must use an external crystal oscillator. For example, the STM32H7 manual says that it does not support running USB without a crystal oscillator. Similarly, the STM32F072 supports USB functions without a crystal oscillator.

So your statement is not valid.

The DFU I'm talking about is the DFU function that comes with the bootloader, not the DFU of the user program.

This post is from stm32/stm8

Comments

Then I think we can test whether the manufacturer's bootloader's DFU can run without connecting the external crystal oscillator.  Details Published on 2024-2-22 09:19
 
 

6742

Posts

2

Resources
4
 
fxyc87 posted on 2024-2-22 09:14 When using USB for DFU upgrade, you must use an external crystal oscillator. For example, the STM32H7 manual says that it does not support running USB without a crystal oscillator. There are similar ST ...

Then I think we can test whether the manufacturer's bootloader's DFU can run without connecting the external crystal oscillator.

This post is from stm32/stm8
 
 
 

6062

Posts

4

Resources
5
 

I feel:

The manufacturer's bootloader knows the crystal oscillator inside. Because this is fixed, it can be configured with a value to reach 48M.

It can start the internal crystal oscillator first to measure the external crystal oscillator, whether it can be started, what the frequency is, and whether it is stable. If there is no external crystal oscillator, it will continue to use the internal crystal oscillator to run. In fact, the CPU starts using the internal crystal oscillator. If an external crystal oscillator is to be used, it will wait until the external crystal oscillator is stable before switching to it.

This post is from stm32/stm8
 
 
 

5998

Posts

6

Resources
6
 

What is the basis for the bootloader process? For ARM such as STM32, it should be the startup file (startup....s), which contains SystemInit, which has been initialized. You can change it or reconfigure it after entering the main program

This post is from stm32/stm8

Comments

I mean the bootloader that comes with the MCU, not the user program that comes with the chip when it leaves the factory. For example, for some STM32 chips, when boot0 is pulled low, the program can be upgraded using the serial port or USB. In this mode, how does it know what frequency the external crystal oscillator is soldered to?  Details Published on 2024-2-22 11:01
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

1127

Posts

17

Resources
7
 
Qintianqintian0303 posted on 2024-2-22 10:38 What is the basis for the bootloader process? For ARM such as STM32, it should be the startup file (startup....s), which contains Syst ...

I mean the bootloader that comes with the MCU, not the user program

It is provided by the chip when it leaves the factory. For example, some STM32 chips can use the serial port or USB to upgrade the program when boot0 is pulled low.

In this mode, how does it know the frequency of the external crystal oscillator soldered?

This post is from stm32/stm8

Comments

SystemInit is in the factory startup file. It usually starts with the internal clock, and then configures the external clock data. There are external clock parameters in the startup file. We also need to change this when changing the external clock.  Details Published on 2024-2-22 11:59
 
 
 

2145

Posts

8

Resources
8
 

I am not sure how it is implemented. I guess there may be internal counting. The RC has been calibrated at the factory. Although the accuracy is low, 1-2% should be achievable.

Our chips start the BootLoader from the internal RC by default, and then switch to the high-frequency clock. From this, we can guess that our chips do not automatically identify the crystal frequency. The default is whatever it is, and the user cannot choose it.

This post is from stm32/stm8

Comments

If USB is not used, the bootloader can ignore the external crystal oscillator and use the internal RC. However, if USB is used, the internal RC accuracy is not enough, which will cause external USB communication failure. The answer on the 10th floor should be correct.  Details Published on 2024-2-22 19:38
If USB is not used, the bootloader can ignore the external crystal oscillator and use the internal RC. However, if USB is used, the internal RC accuracy is not enough, which will cause external USB communication failure. The answer on the 10th floor should be correct.  Details Published on 2024-2-22 16:07
 
Personal signature坐而言不如起而行
 
 

5998

Posts

6

Resources
9
 
fxyc87 posted on 2024-2-22 11:01 I mean the bootloader that comes with the MCU, not the user program that comes with the chip when it leaves the factory. For example, some STM32 chips, when boot0 is pulled low, you can...

SystemInit is in the factory startup file. It usually starts with the internal clock, and then configures the external clock data. There are external clock parameters in the startup file. We also need to change this when changing the external clock.

This post is from stm32/stm8

Comments

The answer on the 10th floor is correct. SystemInit is a user program, not the MCU's bootloader. The MCU's own bootloader is not open.  Details Published on 2024-2-22 16:06
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

31

Posts

0

Resources
10
 

According to STMicroelectronics' AN3156, the USB part in the bootloader uniformly uses the DFU protocol, and the processing of the USB clock source is different: one type of chip directly uses HSI to multiply the frequency to 48MHz and then allocates it to the USB module; another type of chip first runs with HSI and establishes a connection with the USB Host, then tries to use different external clock configurations to multiply the frequency and allocate it to the USB module, and tests whether it can successfully send and receive messages. If it fails, try the next set of configurations...

As for which chips execute according to which configuration, see AN2606.

In summary, the Bootloader does not know the frequency of the external crystal oscillator, and either uses HSI to run the USB interface or repeatedly tries USB communication according to several specific sets of frequencies (8MHz, 14.7456MHz, 25MHz).

This post is from stm32/stm8

Comments

Thanks for clarifying this, this is the correct answer.  Details Published on 2024-2-22 16:05

赞赏

1

查看全部赞赏

 
 
 

1127

Posts

17

Resources
11
 
Ejack1979 posted on 2024-2-22 15:07 According to STMicroelectronics' AN3156, the USB part in the bootloader uniformly adopts the DFU protocol, and the processing of the USB clock source is different: a type of chip directly...

Thanks for clarifying this, this is the correct answer.

This post is from stm32/stm8
 
 
 

1127

Posts

17

Resources
12
 
Qintianqintian0303 posted on 2024-2-22 11:59 SystemInit is in the factory startup file. It is usually started with the internal clock, and then the external clock data is configured. There is an external clock in the startup file...

The answer on the 10th floor is correct.

SystemInit is a user program. Not the MCU's bootloader.

The bootloader that comes with the MCU is not open.

This post is from stm32/stm8

Comments

Oh, then we probably haven't touched on it very deeply. This startup file is also provided by the manufacturer.  Details Published on 2024-2-22 16:25
 
 
 

1127

Posts

17

Resources
13
 
wsmysyn posted on 2024-2-22 11:25 It is not clear how it is implemented. I guess there may be a counter inside. The RC has been calibrated at the factory. Although the accuracy is low, 1-2% should be...

If USB is not used, the bootloader can ignore the external crystal and use the internal RC

However, if USB is used, the internal RC accuracy will not be sufficient, which will cause external USB communication to fail.

The answer on the 10th floor should be correct.

This post is from stm32/stm8

Comments

For most peripherals, the RC accuracy is definitely not enough. Generally, the BootLoader starts with the RC clock, configures the PLL after startup, and then switches to the PLL clock. If there is any,   Details Published on 2024-2-22 19:34
 
 
 

5998

Posts

6

Resources
14
 
fxyc87 posted on 2024-2-22 16:06 The answer on the 10th floor is correct. SystemInit is a user program. It is not the MCU's bootloader. The MCU's own bootloader is not open.

Oh, then we probably haven't touched on it very deeply. This startup file is also provided by the manufacturer.

This post is from stm32/stm8
 
Personal signature

在爱好的道路上不断前进,在生活的迷雾中播撒光引

 
 

2145

Posts

8

Resources
15
 
fxyc87 posted on 2024-2-22 16:07 If USB is not used, the bootloader can ignore the external crystal oscillator and use the internal RC. But if USB is used, the internal RC accuracy is not enough, which will cause external...

For most peripherals, the RC accuracy is definitely not enough. Generally, the BootLoader starts with the RC clock, configures the PLL after startup, and then switches to the PLL clock. If there is any,

This post is from stm32/stm8
 
Personal signature坐而言不如起而行
 
 

6742

Posts

2

Resources
16
 
I'm not sure how it's implemented specifically. My guess is that there may be a counter inside, and the RC has been calibrated at the factory. Although the accuracy is low, 1-2% should be about right. Our chips start the BootLoader from the internal RC by default, and then switch to the high-frequency clock. Based on this, I guess that our chip does not automatically identify the crystal frequency. The default is whatever it is, and the user cannot choose.
Are you a chip developer?
This post is from stm32/stm8

Comments

No, I do chip testing. I just know more about the internal design of the chip than ordinary users. Some test modes are not open to users. I communicate more with design colleagues.  Details Published on 2024-2-22 19:44
 
 
 

2145

Posts

8

Resources
17
 
wangerxian posted on 2024-2-22 19:38 Are you engaged in chip development?

No, I do chip testing. I just know more about the internal design of the chip than ordinary users. Some test modes are not open to users. I communicate more with design colleagues.

This post is from stm32/stm8

Comments

Which domestic chip factory?  Details Published on 2024-2-22 19:54
 
Personal signature坐而言不如起而行
 
 

6742

Posts

2

Resources
18
 
wangerxian posted on 2024-2-22 19:38 Are you a chip developer?
No, I do chip testing. I just know more about the internal design of the chip than ordinary users. Some test modes are not open to users. I communicate more with design colleagues
Which domestic chip factory are you from? []
This post is from stm32/stm8

Comments

Qingwei, the team of Tsinghua University Microelectronics Institute is not a general market, but some specific scenarios, smart door locks, smart cameras, and cloud-based AI chips.  Details Published on 2024-2-22 20:00
 
 
 

2145

Posts

8

Resources
19
 
wangerxian posted on 2024-2-22 19:54 No, I do chip testing. I just know more about the internal design of the chip than ordinary users. Some test modes are not open to users, and...

Qingwei, a team from the Institute of Microelectronics at Tsinghua University

It’s not the general market, but some specific scenarios, such as smart door locks, smart cameras, and cloud-based AI chips.

This post is from stm32/stm8

Comments

Is there an official website? Let’s take a look at your chips.  Details Published on 2024-2-23 09:12
 
Personal signature坐而言不如起而行
 
 

6742

Posts

2

Resources
20
 
wsmysyn posted on 2024-2-22 20:00 Qingwei, the team from Tsinghua University Microelectronics Institute is not a general market, some specific scenarios, smart door locks, smart cameras, and cloud push...

Is there an official website? Let’s take a look at your chips.

This post is from stm32/stm8
 
 
 

Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
MATLAB APP Designer serial port debugging tool writing

This post was last edited by lb8820265 on 2019-5-9 23:11 Previously, we introduced two ways to use VC6 to make serial ...

About the original picture and packaging

Does anyone have the original picture and package of STM32F103 series?

How to use CPLD to collect asynchronous signals

Scenario: Use CPLD to decode a serial data channel. The data has no accompanying clock and has a fixed frequency but a d ...

Measuring poles and zeros from a Bode plot

This post was last edited by Jack315 on 2021-1-25 00:52 The transfer function of a single zero is: 522846 The Bode plot ...

Encoder counting principle and motor speed measurement principle - multi-picture analysis

This post was last edited by DDZZ669 on 2021-2-14 23:30 Encoder is a sensor used to measure mechanical rotation or displ ...

35 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (Realizing Hello World)

The best way to learn ROS is to use it. The ROS official website has a Chinese version of the tutorial . After install ...

36 "Ten Thousand Miles" Raspberry Pi Car——ROS Learning (VSCode to Implement Hello World)

It is very convenient to run ROS projects in VSCode. In this section, we use ROS to write and run the "Hello world" pro ...

[The strongest open source] Hand-rubbed 120W switching power supply

I recently took the time to make a switching power supply 645265 645262 645263 645264 645261 645260

Record a blue screen pit

I mentioned a while ago that my company's computers would occasionally blue screen. Now I think about it, the blue scree ...

ESP8266 01+DHT11 acquisition

Could anyone give me some advice? When I collect DHT11 data through one of GPIO 0 and 2, the 8266 01 keeps restarting. O ...

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list