Simplicity Studio compiles the EFM32 Release version "FLASH memory overflowed" problem solution

Recently, in the process of developing EFM32-related projects, it was found that the Flash space of the Debug version was not exceeded, and even a considerable part of the space was reserved. However, when switching to the Release version for compilation, the compiler reported an error "FLASH memory overflowed", ordinarily, After switching to the Release version to remove the debugging information and optimizing the code, the compiled firmware space should be smaller than that of the Debug version.

After exploration, it is found that the problem occurs in Linker Scripts. In the Release version of Settings, Memory Layout cannot be set, but is automatically copied by the system, and necessary modifications are made according to the actual situation. Figure 1.

The Linker Scripts copied by the system are placed in the xxx-Release folder under the project directory, check the *.ld file, and find the place where the error is reported:

  /* Check if FLASH usage exceeds FLASH size */
  ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !")

 There is an assertion here to judge whether the size of the chip Flash space is larger than the code end (__etext) and data segment length (SIZEOF(. ), not 0x00000000, but LENGTH (FLASH) is 0x80000 (the chip with 512KB Flash space I used), and the value of SIZEOF (.data) is greater than 0, so the compilation will definitely report an error.

The reason for the error is that the method of calculating the space occupied by Flash is wrong, and the starting address of the chip Flash is not subtracted. Knowing the cause of the problem, the solution is simple, but here you cannot directly modify the *.ld file in the current directory, because when the compiler is linked, To copy the Linker Scripts template file from the system to this directory every time, the original Linker Scripts file needs to be modified.

Original Linker Scripts file directory:

xxx\SiliconLabs\SimplicityStudio\v5\configuration\org.eclipse.osgi\883\0\.cp\linker_scripts

"xxx" depends on your Simplicity Studio installation path. Modify the last line of "linker_scripts" as follows:

ASSERT( LENGTH(FLASH) >= (__etext - ORIGIN(FLASH) + SIZEOF(.data)), "FLASH memory overflowed !")

Just subtract the Flash start address (ORIGIN(FLASH)).

After modification, the Flash space will not be exceeded when compiling the Release version.

Guess you like

Origin blog.csdn.net/propor/article/details/131127648