5 exercises on embedded memory terminology: flash, SRAM, linker script, .bss section, and .data section. Advanced
0 / 5 completed
1 / 5
A firmware engineer reports: "The firmware image is 96 KB and fits comfortably in flash — we have 128 KB total."
What is flash memory in an embedded system?
Correct: B.Flash memory is non-volatile — it holds data without power. On most microcontrollers the firmware image (text section + read-only data) is stored in on-chip flash and executed in-place (XIP) or copied to SRAM for faster access. Writing to flash requires erase-before-write at page granularity, making it unsuitable for frequent runtime writes.
Memory type
Volatile?
Typical use
Flash
No
Firmware image, const data
SRAM
Yes
Stack, heap, runtime variables
EEPROM
No
Config, calibration, counters
2 / 5
During a memory audit your lead comments: "The task stacks and the heap are both allocated in SRAM — make sure we have enough for all tasks plus the FreeRTOS heap."
What is SRAM in an embedded context?
Correct: B.SRAM (Static Random-Access Memory) is the main runtime memory on a microcontroller. Unlike DRAM it requires no refresh, making it suitable for real-time systems. It holds the call stack for every task, the FreeRTOS heap (from which task stacks and kernel objects are allocated), and all read-write global variables. SRAM is typically 10–100× smaller than flash on the same MCU.
SRAM consumer
Notes
Task stacks
Each RTOS task needs its own stack
Heap
Dynamic allocations; fragmentation risk
.data section
Initialized globals copied from flash at startup
.bss section
Zero-initialized globals cleared at startup
3 / 5
Your team needs to place the bootloader in the first 32 KB of flash and the application at 0x08008000. The senior engineer says: "Edit the linker script to define those regions."
What is a linker script?
Correct: B. A linker script (also called a scatter file on ARM RVDS/Keil) is a text file — usually with a .ld extension for GNU ld — that tells the linker the memory layout of the target hardware and how to map object file sections into that layout. Every embedded project must have one; without it the linker cannot produce a correctly addressed binary.
Linker script concept
Purpose
MEMORY block
Declares available memory regions and their addresses
SECTIONS block
Maps .text, .data, .bss, etc. to memory regions
Symbols (e.g. _edata)
Provide addresses to startup code for copy/clear loops
4 / 5
A code reviewer comments: "This large uninitialized array will go in .bss — make sure the startup code clears it before main() runs."
What is the .bss section?
Correct: B. The .bss section (Block Started by Symbol) holds global and static variables declared without an explicit initializer (C guarantees they are zero). Because they are all zero, there is no need to store initialization data in flash — the startup code simply does memset(bss_start, 0, bss_size) before calling main(), saving flash space.
Section
Initial value
Stored in flash?
In SRAM?
.bss
Zero
No (size only)
Yes
.data
Non-zero
Yes (init values)
Yes (copy)
.rodata
Constant
Yes (in place)
No
5 / 5
Your startup code review notes say: "After zeroing .bss, copy the .data initializers from flash to SRAM before calling main()."
What is the .data section?
Correct: B. The .data section contains global and static variables with non-zero initial values (e.g., int baud_rate = 115200;). The initial values are stored in flash (in a load region sometimes called .data_init), and the startup code copies them into SRAM before main() runs. This copy loop is typically generated by the linker script symbols _sdata / _edata / _sidata.