ChibiOS/RT and external RAM

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

ChibiOS/RT and external RAM

Post by Tectu »

Morning folks,

I'd need some external RAM in a project at some point. How does ChibiOS/RT work with external RAM?

Using an STM32, I'd add it to the Bank 1 of the FSMC interface. I guess I'd have to add a new section in the linker script then, or how does this work in cooperation with ChibiOS/RT? Will it be possible to use chHeapAlloc() and it will also use the external memory or do I always have to read and write to the external memory manually by myself?


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/RT and external RAM

Post by Giovanni »

You may create another heap in the extra RAM.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/RT and external RAM

Post by Tectu »

Is there a documentation showing how one does that or may you give a quick step-by-step guide? When I got my external RAM working, I'll create some tutorial in the community section of the wiki.


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/RT and external RAM

Post by Giovanni »

It is the documentation of the function chHeapInit().

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/RT and external RAM

Post by Tectu »

Okay, this seems to be straight forward. I hope that I can still ask in case of I don't get it working :P
By the way, is it possible to make a contious pool from the internal and the external memory so you always work with the default heap? If it's possible, I guess it's still not a good idea because of performance and latency issues?


~ Tectu
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/RT and external RAM

Post by Tectu »

One more question: When using external SDRAM, you always have to work with pages. I guess this is no problem at all since the OS will abstract this, right?


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/RT and external RAM

Post by Giovanni »

The OS simply does not care about the RAM type and organization, only performance could be affected.

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/RT and external RAM

Post by Tectu »

Okay, finally found time to catch this and now I already need some more help, of course :P

The reference manual of the STM32F407 says that the FSMC segment for external SRAM starts at 0x6000 0000 (yes, the RAM is connected to the first bank (NE1)). However, I'm a bit confused by the second argument of the chHeapInit() routine. As far as I understand, the second parameter is a pointer to the base address of where the memory beginns, no? Why is this a void pointer?
I tried like this:

Code: Select all

static struct memory_heap *ext_heap;       // this will be our heap pointer
static int ext_heap_base = 0x60000000;    // this is the base address
static size_t ext_heap_size = 10240;        // this is the size of the new heap

chHeapInit(ext_heap, (void*)&ext_heap_base, ext_heap_size);   /* 10k heap on external RAM */ 



Am I doing it right? :P

~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/RT and external RAM

Post by Giovanni »

No, you are passing the address of ext_heap_base.

static struct memory_heap ext_heap
chHeapInit(&ext_heap, (void*)0x60000000, 10240);

Giovanni
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: ChibiOS/RT and external RAM

Post by Tectu »

Giovanni wrote:static struct memory_heap ext_heap
chHeapInit(&ext_heap, (void*)0x60000000, 10240);

Are you sure that this is the way to go (first argument) ?

Code: Select all

main.c:36:2: error: incompatible type for argument 1 of 'chHeapAlloc'
/home/tectu/projects/resources/chibios/os/kernel/include/chheap.h:82:9: note: expected 'struct MemoryHeap *' but argument is of type 'struct memory_heap'

That error looks somehow odd... When I use MemoryMap instead of memory_map, it complaints about incomplete type.


~ Tectu
Post Reply