cancel
Showing results for 
Search instead for 
Did you mean: 

How to use SD card memory as Extended RAM

yalamanda dosakayala
Associate II
Posted on January 23, 2018 at 13:24

Hi STM community, Currently we are developing an application with STM32F779I eval board.I am using Cube Mx and System work bench for STM32. We are facing issue with RAM.My application uses FreeRTOS, FatFS and SD Card driver and also CAN driver. Actually when we try to allocate memory using malloc() we are getting Hardfault error.This implies out memory of RAM.

But we thought of using SD Card as Extended RAM. But we are not sure how to implement this.

Can anyone help me how we can use SD Card memory as Extended RAM for resolving memory issue with RAM.

Or

Is there any other we can get rid of RAM issue?

#stm32f7-eval #external-ram
6 REPLIES 6
Posted on January 23, 2018 at 14:01

when we try to allocate memory using malloc() we are getting Hardfault error.This implies out memory of RAM.

No, it doesn't.

You need to investigate further to find the actual cause of the Hardfault.

malloc() should return a null pointer on failure - it should not crash.

http://www.cplusplus.com/reference/cstdlib/malloc/

 

Of course, if you don't check the return from malloc(), that could cause your program to crash...

If malloc() does fail, it could be because you are out of Heap - which is not necessarily the same thing as being out of RAM...

One thing's for sure: using the SD Card for a 'page file' is really not a great idea.

Posted on January 23, 2018 at 14:27

The board has 32MB of SDRAM

http://www.st.com/en/evaluation-tools/stm32f779i-eval.html

 

Should be HAL examples under the Cube trees

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 23, 2018 at 14:18

Hi, Thanks ,I will investigate for Hardfault. Because some one in the community as posted hard fault may come  if you are out of Memory(RAM).

If you an idea about FMC ,Could you please help me how I can use SDRAM/NOR/NAND for Extending RAM.

Posted on January 23, 2018 at 16:35

Hi

Turvey.Clive

‌, Thanks for the reply.I think we have

  • 8Mx32bit SDRAM, 1Mx16bit SRAM and 8Mx16bit NOR Flash
  • 512-Mbit Quad-SPI NOR Flash
  • 2Gx16bit NAND Flash interface to connect NAND Flash module

Can I use 512 -Mbit Quad SPI NOR Flash or 2Gx16bit NAND Flash interface for Extending RAM or these memories can be only used for Extending the flash memory.

If yes, I can use only 8Mx32bit SDRAM, 1Mx16bit SRAM and 8Mx16bit NOR Flash for Extending RAM using FMC.

If I am wrong, Please correct me.

Please guide me how to proceed for extending RAM with best approach.

I am new to this memories concept and extending RAM.

Posted on January 23, 2018 at 16:48

You could use NOR/NAND as a backing memory but it will be very very slow. What exactly is it that you want to achieve, ie end goal

For memory allocated via malloc() from the HEAP use the SDRAM. Consider allocating from two pools, the internal memory is much faster and should be used for STACK and speed sensitive algorithms.

If you want to use very large files, you can read in and process the file in smaller pieces. I would use the microSD card as an easy way to add files to the system. NAND can also be used for storage, but seems overly complicated for your level of experience.

Please seek guidance from your colleagues or teachers, review appropriate comp-sci texts on the subject area.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 23, 2018 at 17:24

yalamanda4c9

‌ -You seem to be making a huge leap to the conclusion that you are out ofRAM!

:(

Before just rushing into extending your RAM, you really need to think about how much you actually need: maybe what you have is actually adequate - you just don't have it partitioned well.

ie, static data vs Stack vs Heap.

Again, Hard Faults can happen for many reasons - not just 'out of memory'.

And, if your Heap is too small, malloc() will fail before you are 'out of memory'...