Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


RAM function not going into RAM?

I’m trying to program the dual-bank flash of the STM32L082 microcontroller, and in order to have decent flash write speed, I need to program in half-page increments. I’m trying to use the half-page program function in HAL.

When I use it, I get a run-time error in the flash program status register FLASH_SR saying that the programming was interrupted by a fetch (bit 17, FWWERR). This is the error that could be explained if the half-page program function is not running from SRAM. When I step through the code with a debugger, I see that the program counter is 0x0800e190, which is in the middle of bank 1 of flash, which makes me think that the HAL “__RAM_FUNC HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer)” isn’t actually getting compiled into RAM. Is there something special I need to do to force the function into RAM?

I searched around a bit and found someone who recommended I change the option in the flash_ramfunc.c file to have “position indpendent code”. I checked that box but I’m still getting program counters in the bank 1 flash range, but now I get about a dozen PC halted console messages for every step.

Anyone have a suggestion for what I need to do to get a function to live in RAM?
Thanks in advance

Bruno from STMicro helpfully replied on another forum on how to make the ram function work.

Here’s a code snippet from the linker script:

/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH

When I added the red text to my linker script in that area, the function was placed correctly in RAM and the half-page programming started working.


 

Newest Forum Posts

  1. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  2. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  3. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  4. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  5. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  6. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  8. Build a project in "release" mode by tang, 2025-02-20 10:36
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35
  10. Fail to debug in Win 11 C/C++ by mortenlund, 2024-12-26 20:27

Last-Modified Blogs