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

linker _user_heap definition may conflict with Arduino IDE RAM calculation #8

Closed
fpistm opened this issue Jun 2, 2017 · 1 comment
Labels
question ❓ Usually converted as a discussion

Comments

@fpistm
Copy link
Member

fpistm commented Jun 2, 2017

From @rogerclarkmelbourne on November 20, 2016 21:52

See http://stm32duino.com/viewtopic.php?f=48&t=1564&p=20198#p20198

@RickKimball posted

The way the arduino IDE calculates RAM usage and the way the linker script attempts to warn you about the low memory usage are in conflict. There are really 1536 bytes of RAM that the linker "allocates" to the heap and the stack. However, the linker's approach doesn't really reflect how much heap or RAM is used. The arduino IDE knows how much RAM a board/chip has and will report low memory issues with a warning about stability. However, neither approach is accurate.

You could probably change the linker script part here from:

 ._user_heap_stack :
   {
     . = ALIGN(4);
     PROVIDE ( end = . );
     PROVIDE ( _end = . );
     . = . + _Min_Heap_Size;
     . = . + _Min_Stack_Size;
     . = ALIGN(4);
   } >RAM

to:

 ._user_heap_stack :
  {
  . = ALIGN(4);
 PROVIDE ( end = . );
 PROVIDE ( _end = . );
 } >RAM

This would stop the reporting of a bogus RAM memory usage and in our case, the arduino IDE will start complaining if you are getting too close to the edge.

Copied from original issue: fpistm/Arduino_Core_STM32L4#6

@fpistm
Copy link
Member Author

fpistm commented Jan 29, 2018

Closed as no question/issue raised linked to this

@fpistm fpistm closed this as completed Jan 29, 2018
fpistm referenced this issue in fpistm/Arduino_Core_STM32 Feb 14, 2018
Linker script defined ._user_heap_stack section to check that there
is enough RAM left.
Arduino should not report this but only the real one used.

Example for a BluePill:
.user_heap_stack section is equal to 1536 (_Min_Heap_Size+_Min_Stack_Size)
If used to compute RAM usage of blink sketch, Arduino reports: 2456 bytes
While it is not computed, it reports 916 bytes (=2456-1536-4(align))

Linker always ensures there is enough space defined thanks .user_heap_stack
Arduino will report real size and will warn if sketch use more than the
default RAM usage (build.warn_data_percentage=75)

See #8

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
fpistm added a commit that referenced this issue Mar 6, 2018
Linker script defined ._user_heap_stack section to check that there
is enough RAM left.
Arduino should not report this but only the real one used.

Example for a BluePill:
.user_heap_stack section is equal to 1536 (_Min_Heap_Size+_Min_Stack_Size)
If used to compute RAM usage of blink sketch, Arduino reports: 2456 bytes
While it is not computed, it reports 916 bytes (=2456-1536-4(align))

Linker always ensures there is enough space defined thanks .user_heap_stack
Arduino will report real size and will warn if sketch use more than the
default RAM usage (build.warn_data_percentage=75)

See #8

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
@rayozzie rayozzie mentioned this issue Aug 20, 2018
benwaffle pushed a commit to benwaffle/Arduino_Core_STM32 that referenced this issue Apr 10, 2019
Linker script defined ._user_heap_stack section to check that there
is enough RAM left.
Arduino should not report this but only the real one used.

Example for a BluePill:
.user_heap_stack section is equal to 1536 (_Min_Heap_Size+_Min_Stack_Size)
If used to compute RAM usage of blink sketch, Arduino reports: 2456 bytes
While it is not computed, it reports 916 bytes (=2456-1536-4(align))

Linker always ensures there is enough space defined thanks .user_heap_stack
Arduino will report real size and will warn if sketch use more than the
default RAM usage (build.warn_data_percentage=75)

See stm32duino#8

Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
fpistm pushed a commit that referenced this issue Aug 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❓ Usually converted as a discussion
Projects
None yet
Development

No branches or pull requests

1 participant