Diff
1diff --git a/platforms/chibios/boards/GENERIC_STM32_F405XG/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F405XG/configs/config.h
2index 90a41326a16ea70a14f0ccfa73e938cf2da7520c..5333a919a0b7be7304bfedf83fe51de290fb6476 100644
3--- a/platforms/chibios/boards/GENERIC_STM32_F405XG/configs/config.h
4+++ b/platforms/chibios/boards/GENERIC_STM32_F405XG/configs/config.h
5@@ -21,3 +21,13 @@
6 #ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
7 # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
8 #endif
9+
10+#ifdef WEAR_LEVELING_EMBEDDED_FLASH
11+# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
12+# ifdef BOOTLOADER_TINYUF2
13+# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
14+# else
15+# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
16+# endif
17+# endif
18+#endif
19diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h
20index 90a41326a16ea70a14f0ccfa73e938cf2da7520c..5333a919a0b7be7304bfedf83fe51de290fb6476 100644
21--- a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h
22+++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/config.h
23@@ -21,3 +21,13 @@
24 #ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
25 # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
26 #endif
27+
28+#ifdef WEAR_LEVELING_EMBEDDED_FLASH
29+# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
30+# ifdef BOOTLOADER_TINYUF2
31+# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
32+# else
33+# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
34+# endif
35+# endif
36+#endif
37diff --git a/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h
38index cbb98f90980e54f8b148c38314f297e571ec27c1..362327efded69906c2f151df5611a78aa60b6142 100644
39--- a/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h
40+++ b/platforms/chibios/boards/GENERIC_STM32_F446XE/configs/config.h
41@@ -17,3 +17,13 @@
42 #ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP
43 # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
44 #endif
45+
46+#ifdef WEAR_LEVELING_EMBEDDED_FLASH
47+# ifndef WEAR_LEVELING_EFL_FIRST_SECTOR
48+# ifdef BOOTLOADER_TINYUF2
49+# define WEAR_LEVELING_EFL_FIRST_SECTOR 3
50+# else
51+# define WEAR_LEVELING_EFL_FIRST_SECTOR 1
52+# endif
53+# endif
54+#endif
55diff --git a/platforms/chibios/boards/common/ld/STM32F401xC.ld b/platforms/chibios/boards/common/ld/STM32F401xC.ld
56index 8bc1cda09c9967b44c8a361cfe4c113f9625175d..64f019706fa48f150311ebb4834f2ba7d531497a 100644
57--- a/platforms/chibios/boards/common/ld/STM32F401xC.ld
58+++ b/platforms/chibios/boards/common/ld/STM32F401xC.ld
59@@ -5,6 +5,9 @@
60 */
61
62 f4xx_flash_size = 256k;
63-f4xx_ram_size = 64k;
64+f4xx_ram1_size = 64k;
65+f4xx_ram2_size = 0;
66+f4xx_ram4_size = 0;
67+f4xx_ram5_size = 0;
68
69 INCLUDE stm32f4xx_common.ld
70diff --git a/platforms/chibios/boards/common/ld/STM32F401xC_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F401xC_tinyuf2.ld
71index 9e0306bde85b1cbed61cda61f7668e3dfae081e0..05aa51917f694c88eeec00711f0a609ce70a6894 100644
72--- a/platforms/chibios/boards/common/ld/STM32F401xC_tinyuf2.ld
73+++ b/platforms/chibios/boards/common/ld/STM32F401xC_tinyuf2.ld
74@@ -5,6 +5,9 @@
75 */
76
77 f4xx_flash_size = 256k;
78-f4xx_ram_size = 64k;
79+f4xx_ram1_size = 64k;
80+f4xx_ram2_size = 0;
81+f4xx_ram4_size = 0;
82+f4xx_ram5_size = 0;
83
84 INCLUDE stm32f4xx_tinyuf2_common.ld
85diff --git a/platforms/chibios/boards/common/ld/STM32F401xE.ld b/platforms/chibios/boards/common/ld/STM32F401xE.ld
86index 3c2a93bd30435269bd65e3ba394dcedaff520d5c..6c72c8f127f515c5dbdc79e0d16918244faa1e25 100644
87--- a/platforms/chibios/boards/common/ld/STM32F401xE.ld
88+++ b/platforms/chibios/boards/common/ld/STM32F401xE.ld
89@@ -5,6 +5,9 @@
90 */
91
92 f4xx_flash_size = 512k;
93-f4xx_ram_size = 96k;
94+f4xx_ram1_size = 96k;
95+f4xx_ram2_size = 0;
96+f4xx_ram4_size = 0;
97+f4xx_ram5_size = 0;
98
99 INCLUDE stm32f4xx_common.ld
100diff --git a/platforms/chibios/boards/common/ld/STM32F401xE_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F401xE_tinyuf2.ld
101index a7fa419cfbdfc866f92cdec37c70d2f1ee3ecd58..65272ec015f65739d01cee8eade641e919305a49 100644
102--- a/platforms/chibios/boards/common/ld/STM32F401xE_tinyuf2.ld
103+++ b/platforms/chibios/boards/common/ld/STM32F401xE_tinyuf2.ld
104@@ -5,6 +5,9 @@
105 */
106
107 f4xx_flash_size = 512k;
108-f4xx_ram_size = 96k;
109+f4xx_ram1_size = 96k;
110+f4xx_ram2_size = 0;
111+f4xx_ram4_size = 0;
112+f4xx_ram5_size = 0;
113
114 INCLUDE stm32f4xx_tinyuf2_common.ld
115diff --git a/platforms/chibios/boards/common/ld/STM32F405xG.ld b/platforms/chibios/boards/common/ld/STM32F405xG.ld
116index b7d0baa210305dc1033c84c95152ee6cc4515d7c..d9468e18c57bd057a0c5049012a8fca7faf074e1 100644
117--- a/platforms/chibios/boards/common/ld/STM32F405xG.ld
118+++ b/platforms/chibios/boards/common/ld/STM32F405xG.ld
119@@ -1,86 +1,13 @@
120 /*
121- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
122-
123- Licensed under the Apache License, Version 2.0 (the "License");
124- you may not use this file except in compliance with the License.
125- You may obtain a copy of the License at
126-
127- http://www.apache.org/licenses/LICENSE-2.0
128-
129- Unless required by applicable law or agreed to in writing, software
130- distributed under the License is distributed on an "AS IS" BASIS,
131- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132- See the License for the specific language governing permissions and
133- limitations under the License.
134-*/
135-
136-/*
137- * STM32F405xG memory setup.
138- * Note: Use of ram1 and ram2 is mutually exclusive with use of ram0.
139+ * Copyright 2006..2018 Giovanni Di Sirio
140+ * Copyright 2022 QMK contributors
141+ * SPDX-License-Identifier: GPL-2.0-or-later
142 */
143-MEMORY
144-{
145- flash0 (rx) : org = 0x08000000, len = 16k /* Sector 0 - Init code as ROM bootloader assumes application starts here */
146- flash1 (rx) : org = 0x08004000, len = 16k /* Sector 1 - Emulated eeprom */
147- flash2 (rx) : org = 0x08008000, len = 1M - 32k /* Sector 2..6 - Rest of firmware */
148- flash3 (rx) : org = 0x00000000, len = 0
149- flash4 (rx) : org = 0x00000000, len = 0
150- flash5 (rx) : org = 0x00000000, len = 0
151- flash6 (rx) : org = 0x00000000, len = 0
152- flash7 (rx) : org = 0x00000000, len = 0
153- ram0 (wx) : org = 0x20000000, len = 128k /* SRAM1 + SRAM2 */
154- ram1 (wx) : org = 0x20000000, len = 112k /* SRAM1 */
155- ram2 (wx) : org = 0x2001C000, len = 16k /* SRAM2 */
156- ram3 (wx) : org = 0x00000000, len = 0
157- ram4 (wx) : org = 0x10000000, len = 64k /* CCM SRAM */
158- ram5 (wx) : org = 0x40024000, len = 4k /* BCKP SRAM */
159- ram6 (wx) : org = 0x00000000, len = 0
160- ram7 (wx) : org = 0x00000000, len = 0
161-}
162-
163-/* For each data/text section two region are defined, a virtual region
164- and a load region (_LMA suffix).*/
165-
166-/* Flash region to be used for exception vectors.*/
167-REGION_ALIAS("VECTORS_FLASH", flash0);
168-REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
169-
170-/* Flash region to be used for constructors and destructors.*/
171-REGION_ALIAS("XTORS_FLASH", flash2);
172-REGION_ALIAS("XTORS_FLASH_LMA", flash2);
173-
174-/* Flash region to be used for code text.*/
175-REGION_ALIAS("TEXT_FLASH", flash2);
176-REGION_ALIAS("TEXT_FLASH_LMA", flash2);
177-
178-/* Flash region to be used for read only data.*/
179-REGION_ALIAS("RODATA_FLASH", flash2);
180-REGION_ALIAS("RODATA_FLASH_LMA", flash2);
181-
182-/* Flash region to be used for various.*/
183-REGION_ALIAS("VARIOUS_FLASH", flash2);
184-REGION_ALIAS("VARIOUS_FLASH_LMA", flash2);
185-
186-/* Flash region to be used for RAM(n) initialization data.*/
187-REGION_ALIAS("RAM_INIT_FLASH_LMA", flash2);
188-
189-/* RAM region to be used for Main stack. This stack accommodates the processing
190- of all exceptions and interrupts.*/
191-REGION_ALIAS("MAIN_STACK_RAM", ram0);
192-
193-/* RAM region to be used for the process stack. This is the stack used by
194- the main() function.*/
195-REGION_ALIAS("PROCESS_STACK_RAM", ram0);
196-
197-/* RAM region to be used for data segment.*/
198-REGION_ALIAS("DATA_RAM", ram0);
199-REGION_ALIAS("DATA_RAM_LMA", flash2);
200-
201-/* RAM region to be used for BSS segment.*/
202-REGION_ALIAS("BSS_RAM", ram0);
203
204-/* RAM region to be used for the default heap.*/
205-REGION_ALIAS("HEAP_RAM", ram0);
206+f4xx_flash_size = 1M;
207+f4xx_ram1_size = 112k;
208+f4xx_ram2_size = 16k;
209+f4xx_ram4_size = 64k;
210+f4xx_ram5_size = 4k;
211
212-/* Generic rules inclusion.*/
213-INCLUDE rules.ld
214+INCLUDE stm32f4xx_common.ld
215diff --git a/platforms/chibios/boards/common/ld/STM32F405xG_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F405xG_tinyuf2.ld
216index 1ee4aa1a06c64c696ff9e8e74fa92fad3959e721..51c4b625ac8e9817043814bc6b7208dacfc0b54a 100644
217--- a/platforms/chibios/boards/common/ld/STM32F405xG_tinyuf2.ld
218+++ b/platforms/chibios/boards/common/ld/STM32F405xG_tinyuf2.ld
219@@ -1,89 +1,13 @@
220 /*
221- ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
222-
223- Licensed under the Apache License, Version 2.0 (the "License");
224- you may not use this file except in compliance with the License.
225- You may obtain a copy of the License at
226-
227- http://www.apache.org/licenses/LICENSE-2.0
228-
229- Unless required by applicable law or agreed to in writing, software
230- distributed under the License is distributed on an "AS IS" BASIS,
231- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
232- See the License for the specific language governing permissions and
233- limitations under the License.
234-*/
235-
236-/*
237- * STM32F405xG memory setup.
238- * Note: Use of ram1 and ram2 is mutually exclusive with use of ram0.
239+ * Copyright 2006..2018 Giovanni Di Sirio
240+ * Copyright 2022 QMK contributors
241+ * SPDX-License-Identifier: GPL-2.0-or-later
242 */
243-MEMORY
244-{
245- flash0 (rx) : org = 0x08000000 + 64k, len = 1M - 64k /* tinyuf2 bootloader requires app to be located at 64k offset for this MCU */
246- flash1 (rx) : org = 0x00000000, len = 0
247- flash2 (rx) : org = 0x00000000, len = 0
248- flash3 (rx) : org = 0x00000000, len = 0
249- flash4 (rx) : org = 0x00000000, len = 0
250- flash5 (rx) : org = 0x00000000, len = 0
251- flash6 (rx) : org = 0x00000000, len = 0
252- flash7 (rx) : org = 0x00000000, len = 0
253- ram0 (wx) : org = 0x20000000, len = 128k /* SRAM1 + SRAM2 */
254- ram1 (wx) : org = 0x20000000, len = 112k /* SRAM1 */
255- ram2 (wx) : org = 0x2001C000, len = 16k /* SRAM2 */
256- ram3 (wx) : org = 0x00000000, len = 0
257- ram4 (wx) : org = 0x10000000, len = 64k /* CCM SRAM */
258- ram5 (wx) : org = 0x40024000, len = 4k /* BCKP SRAM */
259- ram6 (wx) : org = 0x00000000, len = 0
260- ram7 (wx) : org = 0x00000000, len = 0
261-}
262-
263-/* For each data/text section two region are defined, a virtual region
264- and a load region (_LMA suffix).*/
265-
266-/* Flash region to be used for exception vectors.*/
267-REGION_ALIAS("VECTORS_FLASH", flash0);
268-REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
269-
270-/* Flash region to be used for constructors and destructors.*/
271-REGION_ALIAS("XTORS_FLASH", flash0);
272-REGION_ALIAS("XTORS_FLASH_LMA", flash0);
273-
274-/* Flash region to be used for code text.*/
275-REGION_ALIAS("TEXT_FLASH", flash0);
276-REGION_ALIAS("TEXT_FLASH_LMA", flash0);
277-
278-/* Flash region to be used for read only data.*/
279-REGION_ALIAS("RODATA_FLASH", flash0);
280-REGION_ALIAS("RODATA_FLASH_LMA", flash0);
281-
282-/* Flash region to be used for various.*/
283-REGION_ALIAS("VARIOUS_FLASH", flash0);
284-REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
285-
286-/* Flash region to be used for RAM(n) initialization data.*/
287-REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
288-
289-/* RAM region to be used for Main stack. This stack accommodates the processing
290- of all exceptions and interrupts.*/
291-REGION_ALIAS("MAIN_STACK_RAM", ram0);
292-
293-/* RAM region to be used for the process stack. This is the stack used by
294- the main() function.*/
295-REGION_ALIAS("PROCESS_STACK_RAM", ram0);
296-
297-/* RAM region to be used for data segment.*/
298-REGION_ALIAS("DATA_RAM", ram0);
299-REGION_ALIAS("DATA_RAM_LMA", flash0);
300-
301-/* RAM region to be used for BSS segment.*/
302-REGION_ALIAS("BSS_RAM", ram0);
303-
304-/* RAM region to be used for the default heap.*/
305-REGION_ALIAS("HEAP_RAM", ram0);
306
307-/* Generic rules inclusion.*/
308-INCLUDE rules.ld
309+f4xx_flash_size = 1M;
310+f4xx_ram1_size = 112k;
311+f4xx_ram2_size = 16k;
312+f4xx_ram4_size = 64k;
313+f4xx_ram5_size = 4k;
314
315-/* TinyUF2 bootloader reset support */
316-_board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
317+INCLUDE stm32f4xx_tinyuf2_common.ld
318diff --git a/platforms/chibios/boards/common/ld/STM32F407xE.ld b/platforms/chibios/boards/common/ld/STM32F407xE.ld
319new file mode 100644
320index 0000000000000000000000000000000000000000..66dd99116342685dc7ac5b0309485ca427ab7503
321--- /dev/null
322+++ b/platforms/chibios/boards/common/ld/STM32F407xE.ld
323@@ -0,0 +1,13 @@
324+/*
325+ * Copyright 2006..2018 Giovanni Di Sirio
326+ * Copyright 2022 QMK contributors
327+ * SPDX-License-Identifier: GPL-2.0-or-later
328+ */
329+
330+f4xx_flash_size = 512k;
331+f4xx_ram1_size = 112k;
332+f4xx_ram2_size = 16k;
333+f4xx_ram4_size = 64k;
334+f4xx_ram5_size = 4k;
335+
336+INCLUDE stm32f4xx_common.ld
337diff --git a/platforms/chibios/boards/common/ld/STM32F407xE_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F407xE_tinyuf2.ld
338new file mode 100644
339index 0000000000000000000000000000000000000000..0cb7b89636d1927f5b8a4036d4faf90c3c9e9449
340--- /dev/null
341+++ b/platforms/chibios/boards/common/ld/STM32F407xE_tinyuf2.ld
342@@ -0,0 +1,13 @@
343+/*
344+ * Copyright 2006..2018 Giovanni Di Sirio
345+ * Copyright 2022 QMK contributors
346+ * SPDX-License-Identifier: GPL-2.0-or-later
347+ */
348+
349+f4xx_flash_size = 512k;
350+f4xx_ram1_size = 112k;
351+f4xx_ram2_size = 16k;
352+f4xx_ram4_size = 64k;
353+f4xx_ram5_size = 4k;
354+
355+INCLUDE stm32f4xx_tinyuf2_common.ld
356diff --git a/platforms/chibios/boards/common/ld/STM32F411xC.ld b/platforms/chibios/boards/common/ld/STM32F411xC.ld
357index 7827c9c7d2c726068dd0ca3d9c0444e756bd4722..5e3f7e034bc325fc77b84916547f2108b149ce36 100644
358--- a/platforms/chibios/boards/common/ld/STM32F411xC.ld
359+++ b/platforms/chibios/boards/common/ld/STM32F411xC.ld
360@@ -5,6 +5,9 @@
361 */
362
363 f4xx_flash_size = 256k;
364-f4xx_ram_size = 128k;
365+f4xx_ram1_size = 128k;
366+f4xx_ram2_size = 0;
367+f4xx_ram4_size = 0;
368+f4xx_ram5_size = 0;
369
370 INCLUDE stm32f4xx_common.ld
371diff --git a/platforms/chibios/boards/common/ld/STM32F411xC_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F411xC_tinyuf2.ld
372index 0367b49f8fcb763ca69de65d00b8a0e8dbcaf555..63a33309fde70e9d191bc5089bbceae3ea015123 100644
373--- a/platforms/chibios/boards/common/ld/STM32F411xC_tinyuf2.ld
374+++ b/platforms/chibios/boards/common/ld/STM32F411xC_tinyuf2.ld
375@@ -5,6 +5,9 @@
376 */
377
378 f4xx_flash_size = 256k;
379-f4xx_ram_size = 128k;
380+f4xx_ram1_size = 128k;
381+f4xx_ram2_size = 0;
382+f4xx_ram4_size = 0;
383+f4xx_ram5_size = 0;
384
385 INCLUDE stm32f4xx_tinyuf2_common.ld
386diff --git a/platforms/chibios/boards/common/ld/STM32F411xE.ld b/platforms/chibios/boards/common/ld/STM32F411xE.ld
387index c621ede53a466173fa5f98177a614cf5ea685ff8..c798a775e9974c894f9f5c1f87d0e2e08e504948 100644
388--- a/platforms/chibios/boards/common/ld/STM32F411xE.ld
389+++ b/platforms/chibios/boards/common/ld/STM32F411xE.ld
390@@ -5,6 +5,9 @@
391 */
392
393 f4xx_flash_size = 512k;
394-f4xx_ram_size = 128k;
395+f4xx_ram1_size = 128k;
396+f4xx_ram2_size = 0;
397+f4xx_ram4_size = 0;
398+f4xx_ram5_size = 0;
399
400 INCLUDE stm32f4xx_common.ld
401diff --git a/platforms/chibios/boards/common/ld/STM32F411xE_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F411xE_tinyuf2.ld
402index d982f7fb8f66d119f62b36d5620f3c851ad8c952..25253f559075259e0eb22cb6aaa28dd3c668bb21 100644
403--- a/platforms/chibios/boards/common/ld/STM32F411xE_tinyuf2.ld
404+++ b/platforms/chibios/boards/common/ld/STM32F411xE_tinyuf2.ld
405@@ -5,6 +5,9 @@
406 */
407
408 f4xx_flash_size = 512k;
409-f4xx_ram_size = 128k;
410+f4xx_ram1_size = 128k;
411+f4xx_ram2_size = 0;
412+f4xx_ram4_size = 0;
413+f4xx_ram5_size = 0;
414
415 INCLUDE stm32f4xx_tinyuf2_common.ld
416diff --git a/platforms/chibios/boards/common/ld/STM32F446xE.ld b/platforms/chibios/boards/common/ld/STM32F446xE.ld
417new file mode 100644
418index 0000000000000000000000000000000000000000..6e6c5dd3a4e7589dbed7b983ae74bd72ac1f8d62
419--- /dev/null
420+++ b/platforms/chibios/boards/common/ld/STM32F446xE.ld
421@@ -0,0 +1,13 @@
422+/*
423+ * Copyright 2006..2018 Giovanni Di Sirio
424+ * Copyright 2022 QMK contributors
425+ * SPDX-License-Identifier: GPL-2.0-or-later
426+ */
427+
428+f4xx_flash_size = 512k;
429+f4xx_ram1_size = 112k;
430+f4xx_ram2_size = 16k;
431+f4xx_ram4_size = 0;
432+f4xx_ram5_size = 4k;
433+
434+INCLUDE stm32f4xx_common.ld
435diff --git a/platforms/chibios/boards/common/ld/STM32F446xE_tinyuf2.ld b/platforms/chibios/boards/common/ld/STM32F446xE_tinyuf2.ld
436new file mode 100644
437index 0000000000000000000000000000000000000000..676ffbdf0c0ba8f93c24a48e3e18a34b931f28e7
438--- /dev/null
439+++ b/platforms/chibios/boards/common/ld/STM32F446xE_tinyuf2.ld
440@@ -0,0 +1,13 @@
441+/*
442+* Copyright 2006..2018 Giovanni Di Sirio
443+ * Copyright 2022 QMK contributors
444+ * SPDX-License-Identifier: GPL-2.0-or-later
445+ */
446+
447+f4xx_flash_size = 512k;
448+f4xx_ram1_size = 112k;
449+f4xx_ram2_size = 16k;
450+f4xx_ram4_size = 0;
451+f4xx_ram5_size = 4k;
452+
453+INCLUDE stm32f4xx_tinyuf2_common.ld
454diff --git a/platforms/chibios/boards/common/ld/stm32f4xx_common.ld b/platforms/chibios/boards/common/ld/stm32f4xx_common.ld
455index 1ddf7e96bc96915c87ccc584683897e9c1392a47..d5c7c736264055e5a5714f1867ba07c6f301ee12 100644
456--- a/platforms/chibios/boards/common/ld/stm32f4xx_common.ld
457+++ b/platforms/chibios/boards/common/ld/stm32f4xx_common.ld
458@@ -24,12 +24,12 @@ MEMORY
459 flash5 (rx) : org = 0x00000000, len = 0
460 flash6 (rx) : org = 0x00000000, len = 0
461 flash7 (rx) : org = 0x00000000, len = 0
462- ram0 (wx) : org = 0x20000000, len = f4xx_ram_size
463- ram1 (wx) : org = 0x00000000, len = 0
464- ram2 (wx) : org = 0x00000000, len = 0
465+ ram0 (wx) : org = 0x20000000, len = f4xx_ram1_size + f4xx_ram2_size /* SRAM1 + SRAM2 */
466+ ram1 (wx) : org = 0x20000000, len = f4xx_ram1_size /* SRAM1 */
467+ ram2 (wx) : org = 0x20000000 + f4xx_ram1_size, len = f4xx_ram2_size /* SRAM2 */
468 ram3 (wx) : org = 0x00000000, len = 0
469- ram4 (wx) : org = 0x00000000, len = 0
470- ram5 (wx) : org = 0x00000000, len = 0
471+ ram4 (wx) : org = 0x10000000, len = f4xx_ram4_size /* CCM SRAM */
472+ ram5 (wx) : org = 0x40024000, len = f4xx_ram5_size /* BCKP SRAM */
473 ram6 (wx) : org = 0x00000000, len = 0
474 ram7 (wx) : org = 0x00000000, len = 0
475 }
476@@ -80,4 +80,3 @@ REGION_ALIAS("HEAP_RAM", ram0);
477
478 /* Generic rules inclusion.*/
479 INCLUDE rules.ld
480-
481diff --git a/platforms/chibios/boards/common/ld/stm32f4xx_tinyuf2_common.ld b/platforms/chibios/boards/common/ld/stm32f4xx_tinyuf2_common.ld
482index ab03a9e68335f6e7fbf3df9a7e43e694fa1de3ff..d995bd014a3c5de0f88b8ead541660a0d4f9ff4e 100644
483--- a/platforms/chibios/boards/common/ld/stm32f4xx_tinyuf2_common.ld
484+++ b/platforms/chibios/boards/common/ld/stm32f4xx_tinyuf2_common.ld
485@@ -27,12 +27,12 @@ MEMORY
486 flash5 (rx) : org = 0x00000000, len = 0
487 flash6 (rx) : org = 0x00000000, len = 0
488 flash7 (rx) : org = 0x00000000, len = 0
489- ram0 (wx) : org = 0x20000000, len = f4xx_ram_size
490- ram1 (wx) : org = 0x00000000, len = 0
491- ram2 (wx) : org = 0x00000000, len = 0
492+ ram0 (wx) : org = 0x20000000, len = f4xx_ram1_size + f4xx_ram2_size /* SRAM1 + SRAM2 */
493+ ram1 (wx) : org = 0x20000000, len = f4xx_ram1_size /* SRAM1 */
494+ ram2 (wx) : org = 0x20000000 + f4xx_ram1_size, len = f4xx_ram2_size /* SRAM2 */
495 ram3 (wx) : org = 0x00000000, len = 0
496- ram4 (wx) : org = 0x00000000, len = 0
497- ram5 (wx) : org = 0x00000000, len = 0
498+ ram4 (wx) : org = 0x10000000, len = f4xx_ram4_size /* CCM SRAM */
499+ ram5 (wx) : org = 0x40024000, len = f4xx_ram5_size /* BCKP SRAM */
500 ram6 (wx) : org = 0x00000000, len = 0
501 ram7 (wx) : org = 0x00000000, len = 0
502 }
503@@ -86,5 +86,3 @@ INCLUDE rules.ld
504
505 /* TinyUF2 bootloader reset support */
506 _board_dfu_dbl_tap = ORIGIN(ram0) + 64k - 4; /* this is based off the linker file for tinyuf2 */
507-
508-