Loading...
 

SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32


Cannot debug application that uses FLASH for parameter storage

I’m experiencing some difficulty trying to use the SW4STM32 debugger with an application that allocates a portion of the internal FLASH memory for non-volatile parameter storage.

I’ve worked out all the details on how to set up the GCC linker (via the LinkerScript) to reserve a portion of the FLASH for parameter storage, creating a section for variables/objects to be stored in FLASH, using GCC’s __attribute__ ((section ()) directive to designate objects to be stored in the FLASH parameter block, and have successfully created functions to erase and program individual FLASH pages. The project builds, and runs properly if the MCU is programmed outside the SW4STM32 environment and run in standalone mode.

My problem comes when I attempt to run/debug the application within SW4STM32. OpenOCD issues the following error:

Info : Padding image section 0 with 253592 bytes
Error: flash write algorithm aborted by target
Error: flash write failed at address 0x800200a
Error: flash memory not erased before writing
Error: error writing to flash at address 0x08000000 at offset 0x00000000

This problem occurs if the code attempts to reference any variable placed in the .param_flash section (see below).

Note that objects placed in the .param_flash section (P_FLASH region, see linker script below) will be located in the 2K region of FLASH starting at 0x0803F800 (the last 2K of FLASH on a STM32F091RC).

What changes, if any, should I make to the run/debug configuration and/or the OpenOCD configuration script to get it to ignore the last 2K (or any other page-sized region) of FLASH when it writes the application code to the MCU?

The linker script file (LinkerScript.ld) contains the following modifications (not shown in its entirety, just the relevant changes/additions):

/* Memories definition - STM32F091RC */

MEMORY
{
  RAM (rwx)    : ORIGIN = 0x20000000, LENGTH = 32K
  ROM (rx)     : ORIGIN = 0x08000000, LENGTH = 254K
  P_FLASH (rw) : ORIGIN = 0x0803F800, LENGTH = 2K     /* Reserve last page for NVM parameters */
}

/* Sections */

...

  /* Non-volatile parameter data in FLASH */

  .param_flash :
  {
    . = ALIGN(0x800);
    __param_flash_start = .;
    *(.param_flash)
    *(.param_flash*)
    . = ALIGN(4);
    __param_flash_end = .;
  } >P_FLASH

...

An example of a variable definition in the .param_flash section:

param_t param_flash __attribute__ ((section (".param_flash"),used));

The OpenOCD error shown above occurs only if the param_flash variable, or any other variable placed in the .param_flash section, is referenced somewhere in the code.

set NOLOAD atribbute for param_flash section like for bss section...