Given the following code:-
#include "mbed.h"
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
char bufA[6000] __attribute__((section("AHBSRAM1")));
char bufB[6000] __attribute__((section("AHBSRAM1")));
int main() {
pc.baud(115200);
pc.printf("BufA @ %p\n", bufA);
pc.printf("BufB @ %p\n", bufB);
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Output fropm above wrote:
BufA @ 20080000
BufB @ 20081770
Now, all well and good. This is what I expected. However, if I adjust the size of the arrays so that more memory is requested in the given section than is available I noticed the following:-
#include "mbed.h"
Serial pc(USBTX, USBRX);
DigitalOut myled(LED1);
char bufA[10000] __attribute__((section("AHBSRAM1")));
char bufB[10000] __attribute__((section("AHBSRAM1")));
int main() {
pc.baud(115200);
pc.printf("BufA @ %p\n", bufA);
pc.printf("BufB @ %p\n", bufB);
while(1) {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}
}
Output fropm above wrote:
BufA @ 100000f0
BufB @ 10002800
The first thing I notice is the compiler neither produces and error on compile or at least a warning that the requested memory allocation has failed to meet the users expectation.
The second thing I notice is that, having determined the request failed, it just sticks in in main memory (again, no warning from the compiler that it did this).
The third thing I notice is that the two buffers together are too big to go into the ram bank. However, it could have got one in and placed the other in main memory. But having overflowed the ram bank it gives up and places everything into main memory leaving ram bank1 totally unused.
It would be great if the compiler
- Produced an error or at a minimum a warning
- Having the linker's map file available to look at after a build would be very useful
Is there some method to get what I want now with say an #pragma to force the compiler/linker to respect my section attribute requests and tell me if I failed to get it right rather than stuff the extra into main ram?
Given the following code:-
Output fropm above wrote:
BufA @ 20080000
BufB @ 20081770
Now, all well and good. This is what I expected. However, if I adjust the size of the arrays so that more memory is requested in the given section than is available I noticed the following:-
Output fropm above wrote:
BufA @ 100000f0
BufB @ 10002800
The first thing I notice is the compiler neither produces and error on compile or at least a warning that the requested memory allocation has failed to meet the users expectation.
The second thing I notice is that, having determined the request failed, it just sticks in in main memory (again, no warning from the compiler that it did this).
The third thing I notice is that the two buffers together are too big to go into the ram bank. However, it could have got one in and placed the other in main memory. But having overflowed the ram bank it gives up and places everything into main memory leaving ram bank1 totally unused.
It would be great if the compiler
Is there some method to get what I want now with say an #pragma to force the compiler/linker to respect my section attribute requests and tell me if I failed to get it right rather than stuff the extra into main ram?