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
ChibiOS/RT and external RAM
Moderator: RoccoMarco
- 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
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
~ Tectu
- 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
Okay, this seems to be straight forward. I hope that I can still ask in case of I don't get it working 
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
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
Re: ChibiOS/RT and external RAM
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
~ Tectu
- 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
The OS simply does not care about the RAM type and organization, only performance could be affected.
Giovanni
Giovanni
Re: ChibiOS/RT and external RAM
Okay, finally found time to catch this and now I already need some more help, of course 
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:
Am I doing it right?
~ Tectu
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?
~ Tectu
- 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
No, you are passing the address of ext_heap_base.
static struct memory_heap ext_heap
chHeapInit(&ext_heap, (void*)0x60000000, 10240);
Giovanni
static struct memory_heap ext_heap
chHeapInit(&ext_heap, (void*)0x60000000, 10240);
Giovanni
Re: ChibiOS/RT and external RAM
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