Skip to content

arch/Kconfig: add image option - #19831

Closed
Laczen wants to merge 1 commit into
apache:masterfrom
Laczen:improve_bootloader_support
Closed

arch/Kconfig: add image option#19831
Laczen wants to merge 1 commit into
apache:masterfrom
Laczen:improve_bootloader_support

Conversation

@Laczen

@Laczen Laczen commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Add extra boot memory options to enforce the use of boot memory configuration options. This allows linker files to detect if they should prefer the specified boot memory options. This supports using boot memory config without breaking the existing defconfigs.

Add image option to describe the size of an image header when a bootloader would need one.

When using the image header by a bootloader that is in nuttx-apps I would use the PREBUILD mechanism or a equivalent cmake mechanism to set the boot memory configuration and the image header size (using kconfig-tweak).

Impact

None, enabler for improving bootloader support.

Testing

tested on qemu-armv7a:nsh

...
user_main: Exiting
ostest_main: Exiting with status 0
nsh>

@github-actions github-actions Bot added the Size: S The size of the change in this PR is small label Aug 13, 2026
@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Comment thread arch/Kconfig
Set this option to enforce using the boot memory configuration if
supported by the linker script.

config FLASH_HEADER_SIZE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but no nuttx code reference these new macro?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, I wanted the OK to do it like that. I can add an example linker modification if wanted.

@Laczen
Laczen force-pushed the improve_bootloader_support branch from 6667445 to 5eb024d Compare August 13, 2026 15:14
@Laczen
Laczen requested a review from raiden00pl as a code owner August 13, 2026 15:14
Comment thread boards/arm/stm32f4/nucleo-f411re/scripts/flash.ld Outdated
@Laczen

Laczen commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

It might be possible to avoid any additional Kconfig: depending on the meaning of "CONFIG_FLASH_START". If this is considered to be the nuttx FLASH_START it should not care if there is a image header or not. It would be the responsability of the user to take into account a header that is added to the image.

This would be logic, but it might be contradictory to the definition of board_boot_image() which takes a header size as argument.

@xiaoxiang781216, @raiden00pl what do you think is the correct interpretation of CONFIG_FLASH_START?

@acassis acassis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laczen this is a new feature, so to avoid "Another Hidden Feature of NuttX", please document it, i.e. here: https://nuttx.apache.org/docs/latest/implementation/index.html

@Laczen

Laczen commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

@Laczen this is a new feature, so to avoid "Another Hidden Feature of NuttX", please document it, i.e. here: https://nuttx.apache.org/docs/latest/implementation/index.html

Let us first agree on what the current meaning of the properties are in NuttX, it might be that this new feature is not needed anyway.

@Laczen
Laczen force-pushed the improve_bootloader_support branch from 5eb024d to 073ce4c Compare August 15, 2026 14:10
@Laczen Laczen changed the title arch/Kconfig: add boot memory configuration options arch/Kconfig: add image option Aug 15, 2026
@Laczen

Laczen commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

It might be possible to avoid any additional Kconfig: depending on the meaning of "CONFIG_FLASH_START". If this is considered to be the nuttx FLASH_START it should not care if there is a image header or not. It would be the responsability of the user to take into account a header that is added to the image.

This would be logic, but it might be contradictory to the definition of board_boot_image() which takes a header size as argument.

@xiaoxiang781216, @raiden00pl what do you think is the correct interpretation of CONFIG_FLASH_START?

I think the correct understanding of CONFIG_FLASH_START should be that it is the start of the image including the header.

Comment thread arch/Kconfig

menu "Image Options"

config FLASH_HEADER_SIZE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move the near of FLASH_START

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intentionally not done, it a ram load image is generated it could be stored on flash. The ram load part does not need the header, but to describe the image for a bootloader the header could contain e.g. where it needs to be placed in ram.

*/

#include <nuttx/config.h>
#if defined(CONFIG_FLASH_START) && defined(CONFIG_FLASH_SIZE) && \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(CONFIG_FLASH_START) && defined(CONFIG_FLASH_SIZE) && \
#if defined(CONFIG_FLASH_START) && CONFIG_FLASH_START != 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defined() are unnecessary, in theory flash_start could be zero, flash_size != 0 should be the only real condition.

Add image option to describe the size of an image header when a
bootloader would need one.

Add a sample modification for the linker script of nucleo-f411re

Signed-off-by: Laczen JMS <laczenjms@gmail.com>
@Laczen
Laczen force-pushed the improve_bootloader_support branch from 073ce4c to 457cc31 Compare August 15, 2026 17:41
@Laczen

Laczen commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

I think the definition of a header as used by mcuboot and nxboot can be avoided. If after the vector table or at the start of an image a small area is reserved for a magic and a image size a bootloader can find this. The image meta data (including signature) can than be added (and found) after the image.

The small area added avoids the need of defining the image header size in NuttX.

@Laczen Laczen closed this Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: arm Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants