#ld #memory

ld-memory

Helper crate to programmatically create GNU ld MEMORY blocks

4 releases

0.2.2 Jul 5, 2021
0.2.1 Jun 21, 2021
0.2.0 Jun 21, 2021
0.1.0 Mar 16, 2021

#106 in Build Utils

Download history 8/week @ 2022-03-11 16/week @ 2022-03-18 4/week @ 2022-04-22 26/week @ 2022-04-29 16/week @ 2022-05-06 68/week @ 2022-05-13 14/week @ 2022-05-20 28/week @ 2022-05-27 29/week @ 2022-06-03 2/week @ 2022-06-17

59 downloads per month

MIT/Apache

12KB
227 lines

ld-memory

This crate allows creating MEMORY blocks programmatically.

It is supposed to be used in build.rs of crates that now ship memory.x files, which don't easily allow specifying offsets and limits as needed for e.g., a bootloader taking space in front of the application binary.

Example:

This code:

use ld_memory::{Memory, MemorySection};

pub fn main() {
    let memory = Memory::new()
        .add_section(MemorySection::new("FLASH", 0, 0x40000))
        .add_section(MemorySection::new("RAM", 0x20000000, 0x10000));

    println!("{}", memory.to_string());
}

... will print this:

MEMORY
{
    FLASH : ORIGIN = 0x00000000, LENGTH = 262144
    RAM : ORIGIN = 0x20000000, LENGTH = 65536
}

License

This work is licensed under either of

at your option.

No runtime deps