commit:e1c120f100914ac7955f4e5068b6d552385deb5c
author:Chip
committer:Chip
date:Wed Sep 27 01:14:20 2023 -0500
parents:6971c7c4b333fa9c81155d8296d881b08579a77c
Rearrange memory layout

Main RAM block is now in the core 0 4K section, so .data and .bss get
put there for everything. The main 256K chunk is now dedicated to
application RAM.
diff --git a/memory.x b/memory.x
line changes: +13/-19
index 9cae830..a383771
--- a/memory.x
+++ b/memory.x
@@ -1,9 +1,9 @@
 MEMORY {
     BOOT2 (r)   : ORIGIN = 0x10000000, LENGTH = 0x100
     FLASH (rx)  : ORIGIN = 0x10000100, LENGTH = 1024K - 0x100
-    RAM   (rw)  : ORIGIN = 0x20000000, LENGTH = 256K
-    SRAM4 (rw)  : ORIGIN = 0x20040000, LENGTH = 4K
-    SRAM5 (rw)  : ORIGIN = 0x20041000, LENGTH = 4K
+    ARAM  (rw)  : ORIGIN = 0x20000000, LENGTH = 256K
+    RAM   (rw)  : ORIGIN = 0x20040000, LENGTH = 4K
+    RAM2  (rw)  : ORIGIN = 0x20041000, LENGTH = 4K
 }
 
 EXTERN(BOOT2_FIRMWARE)
@@ -17,26 +17,20 @@ SECTIONS {
 } INSERT BEFORE .text;
 
 SECTIONS {
-    .appram : {
+    .appram (NOLOAD) : {
         *(.appram);
         . = ALIGN(4);
-    } > RAM
+    } > ARAM
     _appram = ADDR(.appram);
     _appram_end = ADDR(.appram) + SIZEOF(.appram);
+} INSERT BEFORE .data;
 
-    .kgram1 : {
-        *(.kgram1);
-        . = ALIGN(4);
-    } > SRAM4 AT >FLASH
-    __skgram1 = ADDR(.kgram1);
-    __ekgram1 = ADDR(.kgram1) + SIZEOF(.kgram1);
-    __lkgram1 = LOADADDR(.kgram1);
-
-    .kgram2 : {
-        *(.kgram2);
+SECTIONS {
+    .ram2 : {
+        *(.ram2);
         . = ALIGN(4);
-    } > SRAM5 AT >FLASH
-    __skgram2 = ADDR(.kgram2);
-    __ekgram2 = ADDR(.kgram2) + SIZEOF(.kgram2);
-    __lkgram2 = LOADADDR(.kgram1);
+    } > RAM2 AT >FLASH
+    __sram2 = ADDR(.ram2);
+    __eram2 = ADDR(.ram2) + SIZEOF(.ram2);
+    __lram2 = LOADADDR(.ram2);
 } INSERT AFTER .bss; 
\ No newline at end of file

diff --git a/src/console.rs b/src/console.rs
line changes: +0/-1
index 4a1c0b1..8de8a81
--- a/src/console.rs
+++ b/src/console.rs
@@ -6,7 +6,6 @@ use usb_device::UsbError;
 
 use crate::{capabilities::CapType, peripherals::with_usb, task::with_task_manager};
 
-#[link_section = ".kgram1"]
 static CONSOLE: Mutex<RefCell<Console>> = Mutex::new(RefCell::new(Console::new()));
 
 #[derive(Debug)]

diff --git a/src/main.rs b/src/main.rs
line changes: +0/-11
index dd2b282..68c421b
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,20 +22,9 @@ use console::init_console;
 use task::{init_tasks, with_task_manager};
 
 use peripherals::init_peripherals;
-use r0;
-
-extern "C" {
-    static mut __skgram1: u32;
-    static mut __ekgram1: u32;
-    static mut __lkgram1: u32;
-}
 
 #[entry]
 fn main() -> ! {
-    unsafe {
-        r0::init_data(&mut __skgram1, &mut __ekgram1, &mut __lkgram1);
-    }
-
     init_peripherals();
     init_console();
     init_tasks();

diff --git a/src/panic.rs b/src/panic.rs
line changes: +0/-1
index 5a813b3..7ab451a
--- a/src/panic.rs
+++ b/src/panic.rs
@@ -3,7 +3,6 @@ use core::panic::PanicInfo;
 
 use crate::console::{write, ConsoleError};
 
-#[link_section = ".kgram1"]
 static mut ALREADY_PANICKING: bool = false;
 
 fn print_panic(info: &PanicInfo) -> Result<(), ConsoleError> {

diff --git a/src/peripherals.rs b/src/peripherals.rs
line changes: +0/-1
index 38b32e7..b9c2861
--- a/src/peripherals.rs
+++ b/src/peripherals.rs
@@ -20,7 +20,6 @@ pub use usbdev::with_usb;
 
 const EXTERNAL_XTAL_FREQ_HZ: u32 = 12_000_000;
 
-#[link_section = ".kgram1"]
 static PERIPHERALS: Mutex<RefCell<Option<Peripherals>>> = Mutex::new(RefCell::new(None));
 
 type LedPin = gpio::Pin<gpio::bank0::Gpio7, gpio::Output<gpio::PushPull>>;

diff --git a/src/peripherals/usbdev.rs b/src/peripherals/usbdev.rs
line changes: +0/-2
index dd84397..77fd3c2
--- a/src/peripherals/usbdev.rs
+++ b/src/peripherals/usbdev.rs
@@ -12,9 +12,7 @@ use usbd_human_interface_device::device::keyboard::NKROBootKeyboard;
 use usbd_human_interface_device::prelude::*;
 use usbd_serial::SerialPort;
 
-#[link_section = ".kgram1"]
 static mut USB_ALLOCATOR: Option<UsbBusAllocator<UsbBus>> = None;
-#[link_section = ".kgram1"]
 static USB_MANAGER: Mutex<RefCell<Option<UsbManager>>> = Mutex::new(RefCell::new(None));
 
 pub struct UsbManager<'a> {

diff --git a/src/timer.rs b/src/timer.rs
line changes: +0/-1
index 658ffc2..0ba2131
--- a/src/timer.rs
+++ b/src/timer.rs
@@ -5,7 +5,6 @@ use cortex_m::peripheral::SCB;
 use cortex_m_rt::exception;
 use critical_section::Mutex;
 
-#[link_section = ".kgram1"]
 static TIMER: Mutex<RefCell<Option<Timer>>> = Mutex::new(RefCell::new(None));
 
 pub type Ticks = u32;