From 30424d83ff127506cff088a9b8a6e9079ca5d3e9 Mon Sep 17 00:00:00 2001
From: James Munns <james@onevariable.com>
Date: Sat, 4 Nov 2023 13:17:54 +0100
Subject: [PATCH 1/2] Update RP2040 memory.x

The RP2040 has 264KiB of memory, not 256KiB.
---
 examples/rp/memory.x | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/rp/memory.x b/examples/rp/memory.x
index aba861aae..6ed984938 100644
--- a/examples/rp/memory.x
+++ b/examples/rp/memory.x
@@ -1,5 +1,5 @@
 MEMORY {
     BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
     FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
-    RAM   : ORIGIN = 0x20000000, LENGTH = 256K
-}
\ No newline at end of file
+    RAM   : ORIGIN = 0x20000000, LENGTH = 264K
+}

From f3c77e59c43b04e1002374fd91185cdee3883160 Mon Sep 17 00:00:00 2001
From: James Munns <james@onevariable.com>
Date: Sun, 19 Nov 2023 23:09:53 +0100
Subject: [PATCH 2/2] Add docs, touch all linker fragments

---
 examples/boot/application/rp/memory.x | 14 +++++++++++++-
 examples/boot/bootloader/rp/memory.x  | 14 +++++++++++++-
 examples/rp/memory.x                  | 12 ++++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/examples/boot/application/rp/memory.x b/examples/boot/application/rp/memory.x
index c19473114..2f8434b8a 100644
--- a/examples/boot/application/rp/memory.x
+++ b/examples/boot/application/rp/memory.x
@@ -5,7 +5,19 @@ MEMORY
   BOOTLOADER_STATE                  : ORIGIN = 0x10006000, LENGTH = 4K
   FLASH                             : ORIGIN = 0x10007000, LENGTH = 512K
   DFU                               : ORIGIN = 0x10087000, LENGTH = 516K
-  RAM                               : ORIGIN = 0x20000000, LENGTH = 256K
+
+  /* Pick one of the two options for RAM layout     */
+
+  /* OPTION A: Use all RAM banks as one big block   */
+  /* Reasonable, unless you are doing something     */
+  /* really particular with DMA or other concurrent */
+  /* access that would benefit from striping        */
+  RAM   : ORIGIN = 0x20000000, LENGTH = 264K
+
+  /* OPTION B: Keep the unstriped sections separate */
+  /* RAM: ORIGIN = 0x20000000, LENGTH = 256K        */
+  /* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K    */
+  /* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K    */
 }
 
 __bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOT2);
diff --git a/examples/boot/bootloader/rp/memory.x b/examples/boot/bootloader/rp/memory.x
index d6ef38469..c3b54976e 100644
--- a/examples/boot/bootloader/rp/memory.x
+++ b/examples/boot/bootloader/rp/memory.x
@@ -6,7 +6,19 @@ MEMORY
   BOOTLOADER_STATE                  : ORIGIN = 0x10006000, LENGTH = 4K
   ACTIVE                            : ORIGIN = 0x10007000, LENGTH = 512K
   DFU                               : ORIGIN = 0x10087000, LENGTH = 516K
-  RAM                               : ORIGIN = 0x20000000, LENGTH = 256K
+
+  /* Pick one of the two options for RAM layout     */
+
+  /* OPTION A: Use all RAM banks as one big block   */
+  /* Reasonable, unless you are doing something     */
+  /* really particular with DMA or other concurrent */
+  /* access that would benefit from striping        */
+  RAM   : ORIGIN = 0x20000000, LENGTH = 264K
+
+  /* OPTION B: Keep the unstriped sections separate */
+  /* RAM: ORIGIN = 0x20000000, LENGTH = 256K        */
+  /* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K    */
+  /* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K    */
 }
 
 __bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOT2);
diff --git a/examples/rp/memory.x b/examples/rp/memory.x
index 6ed984938..ef19dffe8 100644
--- a/examples/rp/memory.x
+++ b/examples/rp/memory.x
@@ -1,5 +1,17 @@
 MEMORY {
     BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
     FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
+
+    /* Pick one of the two options for RAM layout     */
+
+    /* OPTION A: Use all RAM banks as one big block   */
+    /* Reasonable, unless you are doing something     */
+    /* really particular with DMA or other concurrent */
+    /* access that would benefit from striping        */
     RAM   : ORIGIN = 0x20000000, LENGTH = 264K
+
+    /* OPTION B: Keep the unstriped sections separate */
+    /* RAM: ORIGIN = 0x20000000, LENGTH = 256K        */
+    /* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K    */
+    /* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K    */
 }