cancel
Showing results for 
Search instead for 
Did you mean: 

heap allocation - the size of the RAM is smaller than expected.

Thain.1
Associate II

Hello,

I’m currently developping an image software on a nucleo h743zi2 with mbed.

I have to deal with 10b VGA images coming from the DMA & DCMI interface. to store it, I need a RAM bigger than 640 x 480 x 2 bytes = 614.400 bytes.

After looking at th specs of the boad here : i read " Up to 1 Mbyte of RAM: 192 Kbytes of TCM RAM (inc. 64 Kbytes of ITCM RAM + 128 Kbytes of DTCM RAM for time critical routines), Up to 864 Kbytes of user SRAM, and 4 Kbytes of SRAM in Backup domain".

In theory, it is thus ok to store a picture in the user SRAM, with 200kB of extra room for other stuffs.

The issue appears when i try to allocate via a malloc enough space, it crashes.

after some investigation of the memory as mentionned here, it appears that mmy heap is too small (only 497148 bytes).

the issue is still there even when i create a very small program that only print the stack and heap sizes.

it gives me this:

Thread: 0x24004168, Stack size: 516 / 4096

Thread: 0x240041AC, Stack size: 592 / 768

Thread: 0x240041F0, Stack size: 96 / 768

Heap size: 64 / 503316 bytes

The question is thus where are my 300kB of SRAM going ?? 

Thanks

5 REPLIES 5
Thain.1
Associate II

I found the answer:

MEMORY

 FLASH (rx)   : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE

 DTCMRAM (rwx) : ORIGIN = 0x20000298, LENGTH = 128K-0x298

 RAM (xrw)   : ORIGIN = 0x24000000, LENGTH = 512K

 RAM_D2 (xrw)  : ORIGIN = 0x30000000, LENGTH = 288K

 RAM_D3 (xrw)  : ORIGIN = 0x38000000, LENGTH = 64K

 ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K

}

The board has 3 separate RAM On different bus and power domains. My program only uses the first one (512k that's why i see +/- 505k of heap in a light program).

As they are not continuous, it is not easily possible to store item larger than 512K... Thus i need another board or smaller frames...

You likely want a board with external SDRAM

https://openmv.io/products/openmv-cam-h7-plus

https://www.waveshare.com/product/mcu-tools/core-boards-compact-boards/stm32-core/coreh743i.htm

The heap allocator probably also needs improvement on ST GNU platforms, it has historically been a bit simplistic/sloppy. And where you have different memory classes perhaps an allocation scheme where you pull from an appropriate pool.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Thain.1
Associate II

Thanks i will have a look.

I also found a bigger nucleo with a H7A3ZI. it contains a bank of 1MB RAM (continous this time) but it is not mbed compatible :\

I never understood why ST doesn't add a external RAM on the big nucleo. Such a big processor with no memory is a bit useless in my opinion...

thanks for the help,

Pavel A.
Evangelist III

> I never understood why ST doesn't add a external RAM on the big nucleo.

Nucleos are simple small and cheap (and external memory bus consumes a lot of pins). Consider Discovery boards.

-- pa

PMath.4
Senior III