I have installed the GNAT 2012 for Bare Boards and adapted the sfp runtime (ravenscar profile) released for STM32F4XX (Discovery board) to use it for a STM32F2XX Microcontroller. The modified SFP runtime works and it's been integrated with an application, libraries and some drivers : UART, SPI and DMA written in Ada as well and it's working fine.
The only issue is that the compiler has started to complaint about the SRAM. More specifically the ".bss" section being overflowed by "x" number of bytes.
To make a fair comparison, we have a similar project (application, libraries and drivers) written in C running on the same Microcontroller and we can see (memory map) that the memory usage is almost half the Memory (STM32F2XX : 128 Kb RAM). So I was wondering if it is normal that ADA requires that much memory to run than C?
Thanks in advance for your input ! :)
I only started on MCUs at the end of 2014, I have the 2014 & 2015 releases. The AdaCore demo_leds used about 15kb BSS, of which 10k was the main program’s secondary stack, in s-taskin.adb, configured in s-secsta.ads by the value of Default_Secondary_Stack_Size.
You need secondary stack to handle functions that return values of indefinite types (for example, String). I think it’s very unlikely that you’d need to do that in your main program, and even more unlikely that you’d need that much.
The main program has a stack size, too, which is also rather large at 4kb, set in the linker script (_DEFAULT_STACK_SIZE):
__stack_start = .;
. += DEFINED (_STACK_SIZE) ? _STACK_SIZE : _DEFAULT_STACK_SIZE;
. = ALIGN(0x8);
__stack_end = .;
I don’t know how you’d set _STACK_SIZE.
Just before this stack declaration, there’s a section for interrupt stacks:
__interrupt_stack_start = .;
*(.interrupt_stacks)
. = ALIGN(0x8);
__interrupt_stack_end = .;
I don’t know how interrupt stacks are set up, I’ve been working on my own ARTS using FreeRTOS, but there may be something to be gained here.
Tasks each have their own secondary stack, allocated as part of their main stack; the proportion is given by Sec_Stack_Percentage in s-parame.ads, set in the versions I have at 10% (with a misleading comment about 25%!).
The task default stack size is also set in s-parame.ads, to 4kb. You can always specify your own, using pragma Storage_Size (ARM J.15.4). Though if these are allocated from the heap you’d get a run-time error rather than a link-time one.
The GNAT GPL 2015 arm-eabi release supports -Og, which gives good space performance while trying to keep variables accessible for debug. Of course, this mainly affects code size, so unlikely to help with your data size problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With