Skip to content

Commit 44c5618

Browse files
committed
Doc adding memory sections in memory.x
1 parent 1ac1453 commit 44c5618

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

cortex-m-rt/src/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
//! _stext = ORIGIN(FLASH) + 0x40C
9393
//! ```
9494
//!
95+
//!
9596
//! # An example
9697
//!
9798
//! This section presents a minimal application built on top of `cortex-m-rt`. Apart from the
@@ -387,6 +388,39 @@
387388
//! undefined behavior. At some point in the future we may add an attribute to safely place static
388389
//! variables in this section.
389390
//!
391+
//! ## Extra Sections
392+
//!
393+
//! Some microcontrollers provide additional memory regions beyond RAM and FLASH.
394+
//! For example, some STM32 devices provide "CCM" or core-coupled RAM that is
395+
//! only accessible from the core. In order to access these using
396+
//! `#[link_section=".foo"]` from your code, you need to modify `memory.x`
397+
//! to declare the additional sections:
398+
//!
399+
//! ```text
400+
//! MEMORY
401+
//! {
402+
//! FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
403+
//! RAM (rw) : ORIGIN = 0x20000000, LENGTH = 128K
404+
//! CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K
405+
//! }
406+
//!
407+
//! SECTIONS
408+
//! {
409+
//! .ccmram (NOLOAD) : ALIGN(4)
410+
//! {
411+
//! *(.ccmram .ccmram.*);
412+
//! . = ALIGN(4);
413+
//! } > CCMRAM
414+
//! } INSERT AFTER .bss;
415+
//! ```
416+
//!
417+
//! You can then use something like this to place a variable into this specific section of memory:
418+
//!
419+
//! ```no_run,edition2018
420+
//! #[link_section=".ccmram.BUFFERS"]
421+
//! static mut BUF: [u8; 1024] = [0u8; 1024];
422+
//! ```
423+
//!
390424
//! [attr-entry]: attr.entry.html
391425
//! [attr-exception]: attr.exception.html
392426
//! [attr-pre_init]: attr.pre_init.html

0 commit comments

Comments
 (0)