GNAT 2012 Memory Usage Estimation for Bare Boards

I installed GNAT 2012 for Bare Boards and adapted the sfp runtime (ravenscar profile) released for STM32F4XX (Discovery board) to use it for STM32F2XX microcontroller. The modified SFP runtime works and it has been integrated with the application, libraries and some drivers: UART, SPI and DMA written in Ada and also working well.

The only problem is that the compiler started SRAM complaints. In particular, the ".bss" section overflows with "x" 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 card) that the memory usage is almost half of the memory (STM32F2XX: 128 Kb) ... So I was wondering if it's okay for ADA to require a lot of memory to run than C?

Thanks in advance for logging in! :)

+3


source to share


1 answer


I just started working on MCU at the end of 2014, I have 2014 and 2015 releases. AdaCore demo_leds

used about 15kb BSS, of which 10k was the main stack of the main programs, at the s-taskin.adb

configured s-secsta.ads

value Default_Secondary_Stack_Size

.

You need a secondary stack to handle functions that return values ​​of undefined types (for example String

). I think it is very unlikely that you need to do this in your main program, and even more unlikely that you need to.

The main program also has a stack size which is also quite 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 installed _STACK_SIZE

.

Just before this stack declaration, this is the section for interrupt stacks:



__interrupt_stack_start = .;
*(.interrupt_stacks)
. = ALIGN(0x8);
__interrupt_stack_end = .;

      

I don't know how the interrupt blocks are set, I've been working on my ARTS using FreeRTOS, but there might be something to get here.

Each task has its own secondary stack, allocated as part of their primary stack; the proportion is set Sec_Stack_Percentage

to s-parame.ads

, set in the versions I have at 10% (with a misleading comment about 25%!).

The default job stack size is also set to s-parame.ads

, up to 4kb. You can always specify your own using pragma Storage_Size

( ARM J.15.4 ). Though, if they are heap allocated, you will get a runtime error, not a time reference.

The arm-eabi release of GNAT GPL 2015 supports -Og

, which gives good space performance, trying to keep variables available for debugging. Of course, this mainly affects the size of the code, so it is unlikely to help solve the data size problem.

+6


source







All Articles