Skip to content

Csolution template for STM32 CubeMX: Linker Scatter File - Missing Conditional Compilation and Duplicate Stack Definition #458

@W-MINE

Description

@W-MINE

Type: Bug Report

Describe the bug

  • OS and Version:Windows 11
  • VS Code Version:1.107.1
  • Extension Version:1.64.1
  • Target Device:STM32F4 Series

Create new solution with "CubeMX Basic solution" Template, The Default Generated Linker Scatter File, Missing Conditional Compilation and Duplicate Stack Definition.

ac6_linker_script.sct.src

#if __HEAP_SIZE > 0
  ARM_LIB_HEAP  (AlignExpr(+0, 8)) EMPTY __HEAP_SIZE  {   ; Reserve empty region for heap
  }
#endif

  ARM_LIB_STACK (__RAM0_BASE + __RAM0_SIZE - __STACKSEAL_SIZE) EMPTY -__STACK_SIZE {   ; Reserve empty region for stack
  }

Regions Header File

// <h> Stack / Heap Configuration
//   <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
//   <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
#define __STACK_SIZE 0x00000200
#define __HEAP_SIZE 0x00000C00
// </h>

Expected behavior

Because CubeMX automatically generates assembler startup file, the stack and heap definition should be disabled in the Regions Header File by setting __STACK_SIZE and __HEAP_SIZE to 0

ac6_linker_script.sct.src

#if __HEAP_SIZE > 0
  ARM_LIB_HEAP  (AlignExpr(+0, 8)) EMPTY __HEAP_SIZE  {   ; Reserve empty region for heap
  }
#endif

#if __STACK_SIZE > 0
  ARM_LIB_STACK (__RAM0_BASE + __RAM0_SIZE - __STACKSEAL_SIZE) EMPTY -__STACK_SIZE {   ; Reserve empty region for stack
  }
#endif

Regions Header File

// <h> Stack / Heap Configuration
//   <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
//   <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
#define __STACK_SIZE 0x00000000
#define __HEAP_SIZE 0x00000000
// </h>

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions