This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 92fe3b67be7 nuttx/Kconfig: add option to select linker defined image
configuration
92fe3b67be7 is described below
commit 92fe3b67be7791f32f3f006ceb4cf11c43edbaf3
Author: Laczen JMS <[email protected]>
AuthorDate: Tue Nov 17 13:28:10 2026 +0100
nuttx/Kconfig: add option to select linker defined image configuration
A option is added to the build configuration to select a image configuration
(e.g. flash and ram) as defined in the linker script. This option is needed
when NuttX is used in combination with a bootloader (e.g. nxboot or
mcuboot). The linker script remains the source of truth, but it has
multiple configurations built-in. When the option
CONFIG_NUTTX_LINKER_IMAGE_CFG
is selected the configuration is selected by
CONFIG_NUTTX_LINKER_IMAGE_CFG_ID.
A example is added for the nucleo-f411re board.
Signed-off-by: Laczen JMS <[email protected]>
---
Kconfig | 17 ++++++++++
boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld | 40 +++++++++++++++++++++--
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/Kconfig b/Kconfig
index ddd6c9e552c..72a07803089 100644
--- a/Kconfig
+++ b/Kconfig
@@ -428,6 +428,23 @@ config NUTTX_USERSPACE
expect to find and instance of struct userspace_s at this
location.
endif # Build 2-pass
+
+config NUTTX_LINKER_IMAGE_CFG
+ bool "Use linker defined image configuration"
+ ---help---
+ Enables the selection of image configurations defined in the
linker
+ file (when provided).
+
+if NUTTX_LINKER_IMAGE_CFG
+
+config NUTTX_LINKER_IMAGE_CFG_ID
+ int "Linker image identifier"
+ default 0
+ ---help---
+ Selects the linker image configuration.
+
+endif
+
endmenu # Build Setup
menu "Binary Output Formats"
diff --git a/boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld
b/boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld
index 2a160e7bbfc..6fdd8d556f4 100644
--- a/boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld
+++ b/boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld
@@ -25,12 +25,48 @@
* FLASH memory is aliased to address 0x0000:0000 where the code expects to
* begin execution by jumping to the entry point in the 0x0800:0000 address
* range.
+ *
+ * Several image configurations are provided for customizing the location
+ * and allowable size of flash and ram. These image configurations can be
+ * selected by passing extra flags at build time, e.g.:
+ * make EXTRAFLAGS="-DIMAGE_CFG=2"
*/
+#include <nuttx/config.h>
+
+#ifndef CONFIG_NUTTX_LINKER_IMAGE_CFG
+#define FLASH_START 0x08000000
+#define FLASH_SIZE 512K
+#define RAM_START 0x20000000
+#define RAM_SIZE 128K
+#elif CONFIG_NUTTX_LINKER_IMAGE_CFG_ID == 0 /* Same as above */
+#define FLASH_START 0x08000000
+#define FLASH_SIZE 512K
+#define RAM_START 0x20000000
+#define RAM_SIZE 128K
+#elif CONFIG_NUTTX_LINKER_IMAGE_CFG_ID == 1 /* Bootloader image */
+#define FLASH_START 0x08000000
+#define FLASH_SIZE 16K
+#define RAM_START 0x20000000 - 16K
+#define RAM_SIZE 16K
+#elif CONFIG_NUTTX_LINKER_IMAGE_CFG_ID == 2 /* Image for 64kB flash block */
+#define FLASH_START 0x08000000 + 64K
+#define FLASH_SIZE 64K
+#define RAM_START 0x20000000
+#define RAM_SIZE 128K
+#elif CONFIG_NUTTX_LINKER_IMAGE_CFG_ID == 2 /* Image for 128kB flash blocks
*/
+#define FLASH_START 0x08000000 + 128K
+#define FLASH_SIZE 512K - 128K
+#define RAM_START 0x20000000
+#define RAM_SIZE 128K
+#else
+#error "Unsupported image configuration"
+#endif
+
MEMORY
{
- flash (rx) : ORIGIN = 0x08000000, LENGTH = 512K
- sram (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
+ flash (rx) : ORIGIN = FLASH_START, LENGTH = FLASH_SIZE
+ sram (rwx) : ORIGIN = RAM_START, LENGTH = RAM_SIZE
}
OUTPUT_ARCH(arm)