Skip to main content
Jnevi.1
Associate III
September 16, 2021
Question

startup_stm32f407xx.s ARMCLANG 6.x problem

  • September 16, 2021
  • 3 replies
  • 1412 views

Hi,

i'm using Keil with the ARMClang 6.x compiler, an STM32f407 and CubeMX to configure my project.

I was playing arround with dynamic memory allocation and was wondering why

uint8_t* b_;
b_ = static_cast<uint8_t*>(std::calloc(100, sizeof(uint8_t)));

works but

b_ = static_cast<uint8_t*>(std::calloc(512, sizeof(uint8_t)));

always was returning 0x0000000.

After reading on the ARM/Keil website i came to the conclusion that

IMPORT __use_two_region_memory

in the startup_stm32f407xx.s seems to be the reason for this fault(?)

I'm not exactly sure if this is a fault or to be excpected and i'm overseeing sth. But after comenting out this line i get a valid pointer when i try to allocate 512 byte (or more)

Why is it working i if allocate a smaller memory area?

And can i fix this somehow so that not everytime i generate the project again my startup file is overwritten? Or is this something which should be fixed in this startup file by ST?

Thanks for help.

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
September 16, 2021

>>Why is it working i if allocate a smaller memory area?

How much HEAP have you specified?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Jnevi.1
Jnevi.1Author
Associate III
September 16, 2021

Btw: i'm using c++ so i cannot use the microlib which seems to have an impact on this (some lines before it is taken care of)

​

I did not change the standard 0x200 defined in this file.

I​ tried to allocate 500byte(did not work), 256byte did work.

When i comment out the __use_two_region_memory line it is always working (1kb is no problem)

​

But at the moment i'm asking myself why i can allocate 1kb when i define only 0x200 Byte of heapspace. I did not Touch this low level stuff before so i think i have to get more knowlledge

​

Jnevi.1
Jnevi.1Author
Associate III
September 16, 2021

And i use rtx5. I hope it does not configure sth in the back which has impact on this behaviour