elf2flash_core/
address_range.rs

1#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2pub enum AddressRangeType {
3    /// May have contents
4    Contents,
5    /// Must be uninitialized
6    NoContents,
7    /// will be ignored
8    Ignore,
9}
10
11#[derive(Copy, Clone, Debug)]
12pub struct AddressRange {
13    pub typ: AddressRangeType,
14    pub to: u32,
15    pub from: u32,
16}
17
18impl AddressRange {
19    pub const fn new(from: u32, to: u32, typ: AddressRangeType) -> Self {
20        Self { typ, to, from }
21    }
22}
23
24impl Default for AddressRange {
25    fn default() -> Self {
26        Self {
27            typ: AddressRangeType::Ignore,
28            to: 0,
29            from: 0,
30        }
31    }
32}
33
34pub const FLASH_SECTOR_ERASE_SIZE: u32 = 4096;
35pub const MAIN_RAM_START: u32 = 0x20000000;
36pub const MAIN_RAM_END: u32 = 0x20042000;
37pub const FLASH_START: u32 = 0x10000000;
38pub const FLASH_END: u32 = 0x15000000;
39pub const XIP_SRAM_START: u32 = 0x15000000;
40pub const XIP_SRAM_END: u32 = 0x15004000;
41pub const MAIN_RAM_BANKED_START: u32 = 0x21000000;
42pub const MAIN_RAM_BANKED_END: u32 = 0x21040000;
43pub const ROM_START: u32 = 0x00000000;
44pub const ROM_END: u32 = 0x00004000;
45
46pub const RP2040_ADDRESS_RANGES_FLASH: &[AddressRange] = &[
47    AddressRange::new(FLASH_START, FLASH_END, AddressRangeType::Contents),
48    AddressRange::new(MAIN_RAM_START, MAIN_RAM_END, AddressRangeType::NoContents),
49    AddressRange::new(
50        MAIN_RAM_BANKED_START,
51        MAIN_RAM_BANKED_END,
52        AddressRangeType::NoContents,
53    ),
54];
55
56pub const RP2040_ADDRESS_RANGES_RAM: &[AddressRange] = &[
57    AddressRange::new(MAIN_RAM_START, MAIN_RAM_END, AddressRangeType::Contents),
58    AddressRange::new(XIP_SRAM_START, XIP_SRAM_END, AddressRangeType::Contents),
59    AddressRange::new(ROM_START, ROM_END, AddressRangeType::Ignore), // for now we ignore the bootrom if present
60];