Skip to content

Commit 117d951

Browse files
authored
Merge pull request #59 from NickeZ/nickez/custom-section
Add support for custom linker sections
2 parents ab0fb98 + 1b53df2 commit 117d951

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rtt-target/src/init.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ macro_rules! rtt_init_channels {
2020
size: $size:expr
2121
$(, mode: $mode:path )?
2222
$(, name: $name:literal )?
23+
$(, section: $section:literal )?
2324
$(,)?
2425
}
2526
$($tail:tt)*
@@ -31,6 +32,7 @@ macro_rules! rtt_init_channels {
3132
$( mode = $mode; )?
3233

3334
$field[$number].init(name, mode, {
35+
$( #[link_section = $section] )?
3436
static mut _RTT_CHANNEL_BUFFER: MaybeUninit<[u8; $size]> = MaybeUninit::uninit();
3537
_RTT_CHANNEL_BUFFER.as_mut_ptr()
3638
});
@@ -71,6 +73,7 @@ macro_rules! rtt_init_wrappers {
7173
/// size: 1024, // buffer size in bytes
7274
/// mode: NoBlockSkip, // mode (optional, default: NoBlockSkip, see enum ChannelMode)
7375
/// name: "Terminal" // name (optional, default: no name)
76+
/// section: ".segger_term_buf" // Buffer linker section (optional, default: no section)
7477
/// }
7578
/// 1: {
7679
/// size: 32
@@ -82,6 +85,7 @@ macro_rules! rtt_init_wrappers {
8285
/// name: "Terminal"
8386
/// }
8487
/// }
88+
/// section_cb: ".segger_rtt" // Control block linker section (optional, default: no section)
8589
/// };
8690
/// ```
8791
///
@@ -118,6 +122,7 @@ macro_rules! rtt_init {
118122
{
119123
$(up: { $($up:tt)* } )?
120124
$(down: { $($down:tt)* } )?
125+
$(section_cb: $section_cb:literal )?
121126
} => {{
122127
use core::mem::MaybeUninit;
123128
use core::ptr;
@@ -136,6 +141,7 @@ macro_rules! rtt_init {
136141
#[used]
137142
#[no_mangle]
138143
#[export_name = "_SEGGER_RTT"]
144+
$( #[link_section = $section_cb] )?
139145
pub static mut CONTROL_BLOCK: MaybeUninit<RttControlBlock> = MaybeUninit::uninit();
140146

141147
#[allow(unused)]

0 commit comments

Comments
 (0)