Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: mark some segments as READONLY #2490

Merged
merged 2 commits into from
Sep 4, 2024
Merged

Conversation

fpistm
Copy link
Member

@fpistm fpistm commented Aug 20, 2024

This PR reverts 794945c then update all linker scripts to mark some segments as READONLY.

Prevent LOAD segment with RWX permissions warning.
The READONLY keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier.

Fixes #2475.

@fpistm fpistm added the enhancement New feature or request label Aug 20, 2024
@fpistm fpistm added this to the 2.9.0 milestone Aug 20, 2024
@fpistm fpistm removed this from the 2.9.0 milestone Aug 21, 2024
@fpistm
Copy link
Member Author

fpistm commented Aug 21, 2024

This PR fixed all warnings for standard application.
Anyway, if a Flash operation (write) is performedclosed to the code segment warning can be raised.
Main example is when the EEPROM emulation is used as it uses last flash page, mainly for mcu with small flash size.

I've reproduced easily with a Blink example on a STM32L4 target by adding:

  FLASH_EraseInitTypeDef EraseInitStruct;
  uint32_t pageError = 0;

  HAL_FLASHEx_Erase(&EraseInitStruct, &pageError);
  HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, 0x0800F000, 10);

Prevent LOAD segment with RWX permissions warning.
The "READONLY" keyword is only supported in GCC11 and later,
remove it if using GCC10 or earlier.

Fixes stm32duino#2475.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
Ignore it also when only overflow detected.

Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
@fpistm
Copy link
Member Author

fpistm commented Sep 4, 2024

To go further, warning is reached due to the usage of at least one RAM function:
#define __RAM_FUNC __attribute__((section(".RamFunc")))

Example with HAL FLASH API:

static __RAM_FUNC void FLASH_Program_Fast(uint32_t Address, uint32_t DataAddress)

So, I kept the warning disabled, but new linker script should use the READONLY attribute to prevent warning.

@fpistm fpistm marked this pull request as ready for review September 4, 2024 12:39
@fpistm fpistm merged commit 1a44f9c into stm32duino:main Sep 4, 2024
23 checks passed
@fpistm fpistm deleted the ldscript branch September 4, 2024 13:11
@fpistm fpistm added this to the 2.9.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

LOAD segment with RWX permissions during stm32f411ceu6 flashing on arduinoststm32 @ 4.20801.240802 (2.8.1)
1 participant