liveBook · Manning

NOLOAD

As explained in Embedded Software with Rust

NOLOAD is a linker-script directive that reserves runtime memory for a section without storing its contents in the loadable image.

NOLOAD is a linker-script directive for a section that occupies memory at runtime but does not need its contents stored in the firmware image. It is useful for zero-initialized data, provided startup code or another guarantee establishes the required initial values. section 4.1.3 section 5.4.4

For ordinary writable data, .bss is placed in RAM and marked NOLOAD; startup code zeroes it before the program runs. By contrast, .data has initial values stored in FLASH and must be copied to RAM during startup. section 4.1.3

.data :
  {
    *(.data .data.*)
  } > RAM AT > FLASH

  .bss (NOLOAD) :
  {
    . = ALIGN(8);
    *(.bss .bss.*)
  } > RAM
}

This linker script places .data in RAM with its initial contents in FLASH. It places .bss in RAM with NOLOAD and aligns it to an 8-byte boundary. section 4.1.3

Custom sections need special care. A Rust static can use #[unsafe(link_section)] to select a dedicated section, and the linker script can map that section to DTCM with NOLOAD. cortex-m-rt automatically initializes the standard .bss and .data sections, not custom sections. Arrange explicit initialization where needed, or ensure the custom data is genuinely zero-initialized. For nonzero initial values, arrange storage in FLASH and copying to DTCM during startup. section 5.4.4

MEMORY {
  ITCM     : ORIGIN = 0x00000000, LENGTH = 64K
  DTCM     : ORIGIN = 0x20000000, LENGTH = 64K
  FLASH    : ORIGIN = 0x08000000, LENGTH = 1M
}

SECTIONS {
  .tcm_data (NOLOAD) : ALIGN(4) {
    KEEP(*(.tcm_data*))
  } > DTCM
}

The .tcm_data section occupies DTCM without storing its contents in the firmware image. This example targets devices with DTCM, such as the Cortex-M7-based STM32F746 or STM32H743. section 5.4.4

How Embedded Software with Rust covers it

How deep it goes
Explains section placement and startup initialization, contrasting NOLOAD with FLASH-backed data and noting custom-section initialization requirements.
Examples
Uses an aligned .bss mapping and a Rust buffer mapped into a NOLOAD DTCM section.
What you can do after
Operate/configure NOLOAD sections in a linker script while accounting for their startup initialization requirements.
How it connects
Connects linker scripts with .bss, .data, startup code, FLASH, RAM, and DTCM.

This explainer was generated by Manning's knowledge graph from the text of Embedded Software with Rust. The section links point to the parts of the book it draws on.