2017-11-09 02:14 AM
Hi all,
I have an application when I need to reserve 4Kbytes of memory. This size is fixed during the whole life cycle of my application.
Therefore my first idea was to create a static memory allocation. But I also tried to use the malloc function to reserve 4K memory. I am using C++ and I am calling free function in my Class destructor.
But the problem I am facing is that my application rises a hard fault when i am calling other task (no operating system).
- Task 1 is for memory management function.
- Task 2 is for UART communication.
So I have general question since that is my first time I am working on huge memory allocation is embedded device.
Is with malloc function in STM32F091 we can allocate 4kbytes of memory ?
What is about eh default heap size ? How can I explicitely increase the heap size ?
Thanks for your help.
Regards
2017-11-09 02:35 AM
my first idea was to create a static memory allocation
So why don't you just do that?
Is with malloc function in STM32F091 we can allocate 4kbytes of memory ?
What is about eh default heap size ? How can I explicitely increase the heap size ?
These have nothing specifically to do with the chip - they depend on the particular toolchain you are using.
So - what
toolchainyou are using? Have you checked its documentation?2017-11-09 02:38 AM
The chip has 32K RAM. So 4K is not exactly 'huge' - though not insignificant ...
2017-11-09 02:58 AM
Hello Andrew,
Thanks for your reply.
Yes the chip has 32K RAM and I double check in the linker script (defined addresses OK).
Even if I use static allocation, I have the same issue.
SCENARIO 1 : Error in execution
static const uint16_t SECTOR_LENGTH = 4096
//static uint8_t ptrSectorRAMSpace[SECTOR_LENGTH]; // Methode 1 static
uint8_t* ptrSectorRAMSpace = (uint8_t*)malloc(SECTOR_LENGTH); // Methode 2 dynamic
SCENARIO 2 : Error in excution
static const uint16_t SECTOR_LENGTH = 3840
//static uint8_t ptrSectorRAMSpace[SECTOR_LENGTH]; // Methode 1 static
uint8_t* ptrSectorRAMSpace = (uint8_t*)malloc(SECTOR_LENGTH); // Methode 2 dynamic
SCENARIO 3 : NO ERROR
static const uint16_t SECTOR_LENGTH = 3548
//static uint8_t ptrSectorRAMSpace[SECTOR_LENGTH]; // Methode 1 static
uint8_t* ptrSectorRAMSpace = (uint8_t*)malloc(SECTOR_LENGTH); // Methode 2 dynamic
TOOLCHAIN:
I am developing under TrueStudio using arm-atollic-eabi-g++ compiler.
2017-11-09 04:04 AM
Youssouf Coulibaly wrote:
Even if I use static allocation, I have the same issue.
So the issue is not to do with the dynamic allocation, then - is it?
Review standard techniques for debugging a Hard Fault; eg,
https://community.arm.com/iot/embedded/f/discussions/3257/debugging-a-cortex-m0-hard-fault
etc, ...