Summary:
This article takes Stm32f103rbt6 as an example to introduce some problems of on-chip Flash (Embedded Flash), including flash size (memory map), block size, page size, register. This knowledge is helpful for writing flash drivers.
First, how to see the size of flash
1.1 By model
Model will be printed on the MCU surface, can be obtained by observation, my is STM32F103RBT6 (the following analysis based on this model), the control of the STM32 product name, Stm32f103rbt6 Flash is 128KB.
()
Figure 1 Ordering Information scheme
1.2 via data sheet (memory map)
Flash size can also be obtained from the data sheet, first according to the model from the official website of the corresponding data sheet datasheet (click here, enter the MCU model for retrieval.) STM32F103RB related manuals are here: http://www.st.com/internet/mcu/product/164487.jsp), open to find the memory map of this picture, 2 red box shown (Figure 2 red box magnification is figure 3), Flash in memory mapping address 0x0800 0000 ~ 0x0801 FFFF, that is, the size of 128KB. This method can also be used to understand the memory mapping on-chip flash.
Figure 2 Memory Map
Figure 3 SRAM and Flash in Memory map
Second, block size
For systems, Flash is divided into flash on-chip (Embedded Flash) and external flash. Generally speaking, flash first divided into pieces of pages, erase is done by block, so the argument should be just external flash, for on-chip flash can be erased by the page can also erase the whole block, the English original is as follows [2]:
- The flash memory erase operation can be performed at page level or in the whole Flash area (mass-erase). The mass-erase does not affect the information blocks.
Three, page size
According to the 1.2 method of the MCU reference Manual, stm32f103rbt6 corresponding reference manual for RM0008 Reference manual, positioning to Embedded Flash memory chapter (also can be searched 0x0800 0000来 location). STM32 has 4 kinds of Flash module organization, namely: low-density devices (32kb,1kb/page), medium-density devices (128kb,1kb/page), High-density devices (512kb,2kb/page), Connectivity Line devices (256kb,2kb/page), xl-density (Devices (1m,2kb/page). From the above analysis, STM32F103RBT6 Flash is 128KB, visible is medium-density devices, as shown:
Figure 4 Flash Module Organization (medium-density devices)
Iv. Flash Related Registers
The flash registers are mapped in memory as follows [1]:
Figure 5 Flash Interface in Memory map
Flash registers the specific address is as follows [2]:
Figure 6 Flash Memory Interface Registers of medium-density devices
Specific to each register function, the bit meaning, the reference [3],flash register mapping is as follows:
Figure 7 Flash Register Map
Five, information block
The memory map of information block in Flash is as follows [1]:
Figure 8 System memory in memory map
The specific flash information block address is as follows:
Figure 9 Information block of medium-density devices
System memory contains a section of the boot program (when the systems from the flash on-chip will be used), Flash factory can not be modified, do not know I understand right, posted the original text as follows [3]:
- System memory is used-boot the device in System memory boot mode. The area was reserved for use by STMicroelectronics and contains the boot loader which are used to reprogram the Flash Memor Y using the USART1 serial interface. It is programmed by ST when the device is manufactured, and protected against spurious write/erase operations. For further details, refer to AN2606.
The option bytes is managed by an embedded Flash program/erase Controller (FPEC), see [3] for details.
Resources:
[1] ds5319:medium-density performance line arm-based 32-bit MCU with 7 KB Flash, USB, CAN, timers, 2 ADCs, 9 Co Mmunication Interfaces (data sheet) ds5319.pdf
[2] rm0008:stm32f101xx, stm32f102xx, stm32f103xx, stm32f105xx and stm32f107xx advanced arm-based 32-bit MCUs (Reference manual) Note: file ruler "Too big to upload:-(
[3] pm0075:stm32f10xxx flash memory microcontrollers (Flash programming Manual) Pm0075.pdf
STM32 Flash Memory Distribution Introduction