Why is .data and .bss section copied to SRAM from the flash memory in the start up file?

131 views Asked by At

I was reading about the booting process in MCUs and got to know about the startup files and their functions but I'm not able to get through the concept where .data and .bss section of program is copied into flash memory, Can someone please elaborate it please?

I read about the startup file on the internet but was not able to fully understand this flash to SRAM copy of data.

1

There are 1 answers

0
Vlad On BEST ANSWER

The .data and .bss sections of the program are the read-write memory. The flash memory normally is not, at least it can't be treated as the memory that program has the same access to as to the ram.

At the same time some data in the ram must be initialized before program is started. The .data section has objects with initial values set, .bss section does not have the initial values explicitly set, but the variables there are expected to be initialized with zero.

But the ram in the MCU does not have the capability of starting up with initial content set. Here's where the flash and the ram meet. The flash stores the initial values to be copied into the .data section, and the startup code is responsible for copying that initial data into .data section, as well as zeroing out the static objects defined in .bss section.