SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Difference Between (Cortex-M3) STM32F1 Density Options for Boot from RAM
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Difference Between (Cortex-M3) STM32F1 Density Options for Boot from RAM

Neil Salmon
Last updated: October 5, 2023 9:55 am
Neil Salmon 7 Min Read
Share
SHARE

When selecting an STM32F1 microcontroller based on the Cortex-M3 core for a project, one of the key considerations is the density option. STM32F1 MCUs are available in different flash memory and SRAM sizes depending on the density option. This determines how much code can be stored and executed directly from flash memory versus needing to boot from RAM. Here we’ll examine the differences between density options and their impact on boot from RAM capabilities.

Contents
Overview of STM32F1 Density OptionsBoot from Flash vs RAMDensity Impact on Boot from RAM FeasibilityBootloader Code ImpactOptimizing for Boot from RAMCase Study: Sample ProjectConclusion

Overview of STM32F1 Density Options

STM32F1 MCUs based on the Cortex-M3 core are grouped into four density options – Low, Medium, High and Connectivity. Here is a brief overview of the memory sizes for each option:

  • Low Density – Up to 32KB flash memory and 4KB SRAM
  • Medium Density – Up to 128KB flash memory and 20KB SRAM
  • High Density – Up to 512KB flash memory and 64KB SRAM
  • Connectivity – Up to 512KB flash memory and 64KB SRAM plus additional hardware for connectivity features

In general, higher density options have more flash to store code and more SRAM to execute it from. The connectivity line adds communication peripherals without increasing memory size over the high density option.

Boot from Flash vs RAM

When an MCU first powers on, it needs to load the program code from non-volatile flash storage into volatile RAM in order to execute it. There are two main approaches to this:

  • Boot from Flash – Code executes directly from flash memory. No copy to RAM needed.
  • Boot from RAM – Code copied from flash to RAM on startup prior to execution.

For small programs, boot from flash allows saving the RAM needed for holding the copied code. However, execution from flash is slower than executing from RAM. As program size grows, some data or code must reside in RAM, requiring a flash to RAM copy on boot anyway. At that point, it becomes advantageous to just copy the entire program to RAM for faster execution.

Density Impact on Boot from RAM Feasibility

Whether an STM32F1 MCU can feasibly boot from RAM depends largely on the density option selected. Here are general guidelines:

  • Low Density – Typically not enough flash or RAM space for boot from RAM. Must boot directly from flash.
  • Medium Density – May support boot from RAM depending on program size. Up to 112KB flash could be copied to 20KB RAM.
  • High Density – Supports boot from RAM for most typical program sizes. Hundreds of KB flash can fit in 64KB RAM.
  • Connectivity – Same as High Density since memory is identical.

Note that medium and high density MCUs may still need to boot from flash if SRAM space is consumed by data requirements. But in general, the high density options provide enough headroom to make boot from RAM feasible in most cases.

Bootloader Code Impact

Another consideration is the memory needed for bootloader code. Typically an MCU boot process will consist of:

  1. Bootloader stored in flash runs on startup
  2. Copies main application code from flash to RAM
  3. Transfers execution to application code

Even if booting from flash, step 1 requires some bootloader code to always reside in flash. This consumes some of the available memory. Boot from RAM requires additional code to perform the copy in step 2. The more functionality built into the bootloader, the bigger its memory footprint in flash.

On lower density MCUs, say 32KB flash, using 8KB for a bootloader leaves only 24KB for the main application. This may dictate boot from flash instead. Higher densities have room for both bootloader and large applications in flash.

Optimizing for Boot from RAM

If aiming to boot from RAM on an STM32F1, follow these general guidelines for best results:

  • Select a high density option MCU with at least 192KB+ flash and 40KB+ SRAM
  • Allocate around 16-32KB flash for the bootloader
  • Keep bootloader code lean and efficient
  • Reserve sufficient SRAM for global data needs
  • Use linker scripts to control memory segment placement
  • Perform memory size checks and alarms during development

With careful design, even medium density STM32F1 MCUs can often be configured to boot from RAM. But high density options offer the most headroom and flexibility.

Case Study: Sample Project

Let’s look at a sample project to see how density options affect boot from RAM feasibility:

  • Application code size: 150KB
  • Data memory needed: 16KB
  • Desired bootloader functionality: medium complexity

For this project, we would recommend:

  • Low density – Insufficient flash and RAM. Must boot from flash.
  • Medium density – Possible but tight. Use 128KB flash version and optimize bootloader for 8KB.
  • High density – More than enough room. Use 256KB flash version for flexibility.
  • Connectivity – Same as high density – a good fit.

The high density or connectivity line MCUs would be the best fit to allow booting 150KB of code from the 256KB of flash into RAM. The medium density MCU could work but lacks headroom for growth.

Conclusion

In summary, density options directly impact the feasibility of booting from RAM versus flash on STM32F1 Cortex-M3 microcontrollers. Low density options lack the memory needed for boot from RAM in most cases. Medium density may work for smaller applications. High density options provide ample headroom for both bootloader and application code. When aiming to boot from RAM on STM32F1, high density or connectivity line MCUs are usually the best fit for maximum flexibility now and in the future.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article STM32F1(Cortex-M3) SRAM Boot Magic Values
Next Article What is the size of the ARM Cortex-M3’s address bus?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What exact difference is between NEON and SIMD instructions in cortex M7?

The key difference between NEON and SIMD instructions in Cortex-M7…

8 Min Read

Mapping External RAM Correctly with Scatter Load Files on ARM Cortex-M

When working with external RAM on an ARM Cortex-M chip,…

7 Min Read

What is arm usage fault?

An arm usage fault is an exception that occurs when…

10 Min Read

What is the most efficient ARM processor?

When evaluating ARM processors, efficiency is a key consideration along…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account