Skip to main content
Scott Dev
Senior
June 8, 2022
Solved

Issue with memory allocation updating on its own.

  • June 8, 2022
  • 9 replies
  • 2815 views

Hi

I am using Atolic TrueStudio and have some global variables. For some reason one variable is simply updating every time I step through the code with the debugger. I am using a STM32L433 processor and have 56k ram free. The variable is a character and located at 0x20001165 . As soon as the the debugger runs it goes into the below code within startup_stml433xx.s . I have the variable in the expressions so I can see its value, and also looked at the memory location. Every time I step through the below (and any part of the program) the variable just increases by 1. I know no other part of the application is being called. I tried increasing the stack, heap just in case. Also, moved the variable to a different memory location, and even changed its name, but still it increases. Anyone any ideas?

FillZerobss:

   movs   r3, #0

   str   r3, [r2], #4

LoopFillZerobss:

   ldr   r3, = _ebss

   cmp   r2, r3

   bcc   FillZerobss

Many Thanks

Scott

This topic has been closed for replies.

9 replies

Danish1
Lead III
June 9, 2022

The C language states that global variables are, unless otherwise specified, initialised to zero at startup.

The code you show looks to be doing the work of zeroing global variables. Are you saying this executes every time you start a debugging session (which I expect) or every time you do a single-step in the debugger?

Scott Dev
Scott DevAuthor
Senior
June 9, 2022

Hi

Yes, when I single step through it (or any part of the app) it increases. As this is one of the first thing that is carried out, I dont understand why this is happening..

Scott

Tesla DeLorean
Guru
June 9, 2022

Is this the primary/only code in the system?

Or is there a loader or some other code that is run first, before this application?

Add "CPSID I" instruction as first thing it does in Reset_Handler

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Scott Dev
Scott DevAuthor
Senior
June 9, 2022

Hi

Yes, its the only code in the system, no loader is ran. I have never done assember on the STM32, only 68000 processors. Where would I add this line, and what exactly does this do?

Scott

Tesla DeLorean
Guru
June 9, 2022

startup.s0693W00000NrXelQAF.jpgThe only thing I'd expect to cause a memory location increment is a SysTick driven HAL_IncTick()

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
waclawek.jan
waclawek.janBest answer
Super User
June 10, 2022
Scott Dev
Scott DevAuthor
Senior
June 12, 2022

Many thanks, that fixed one of the weirdest things I have saw in programming :)