0

I think i got to a point where i can't do much. But maybe there is still hope and someone could help me out.

I'm quite sure the problem is that i am having several big global Arrays. (Sadly they have to be global and that big. I know that would have been the easiest solution) Searching for a other solution i found this article:

Region ram overflowed and section .text will not fit region ram

Where he increases the ram size in the flash.Id file. However as i am quite new to Microchip Studios, i'am not really sure it that is not making it even worse. So does it work? Or has anyone a other idea?

MEMORY
{
    rom (rx)  : ORIGIN = 0x00400000, LENGTH = 0x00100000 /* flash, 1024K */
    ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000 /* sram, 128K */
}

should i maybe post my full linkerScript? Is there anything helpfull?

greetings, Dominik

Dominik
  • 23
  • 5
  • You could get rid of the diagnostic message, sure. But can you add RAM to your device? If not, you need another solution, if there is any. The linker script is just a _description_ of your system. – the busybee Sep 26 '22 at 12:28
  • Are the arrays constant? Will they and their contents need to be modified? If not, then mark them as `const` and make sure they end up in the flash memory together with all other constant data (including code and string literals). – Some programmer dude Sep 26 '22 at 12:29
  • @Someprogrammerdude They need to be modified. – Dominik Sep 26 '22 at 12:38
  • 1
    Your MCU only got 128k. You can't create more physical memory through linker scripts... data cannot be stored in thin air. – Lundin Sep 26 '22 at 12:43
  • I repeat: Can you add RAM to your device? A quick look into the data sheet shows an external memory interface. – the busybee Sep 26 '22 at 12:44
  • @thebusybee Well, i was quite dumb. Youre right, i can't add additional RAM Space just like that. Can't think of another solution either. But anyway, thanks for the eye-opening advice :) – Dominik Sep 26 '22 at 12:45
  • @Dominik the busybee speaks of external memory over some manner of bus. Though you'll need to change the hardware then as well. – Lundin Sep 26 '22 at 12:47
  • 1
    So your only option is to reduce the amount of needed RAM. Do you really need all these arrays, all the time, and in their sizes? Can you use smaller data types, less elements, ...? Without knowing your requirements and algorithms, we cannot really help. – the busybee Sep 26 '22 at 12:48
  • Btw the linker script just specifies total RAM. Your arrays will be in `.data`/`.bss`, but so will other variables. And then there's the stack also in RAM. Maybe if you are lucky there's a `.heap` which you can get rid of and get memory "for free". – Lundin Sep 26 '22 at 12:50
  • @Lundin,@thebusybee I'm sorry i am quite new to this. I was not looking at the second comment from busybee. After a look in the Datasheet, it seems that it is possible to add external RAM. – Dominik Sep 26 '22 at 12:54
  • 1
    What problem is your program supposed to solve? Why does it need those large arrays? Could the actual problem perhaps be solved without the arrays, or possibly with smaller arrays (using only a small window of the data at a time)? Can the algorithms you use be modified? Perhaps it's time to rethink the requirements, their analysis and the design of the system? – Some programmer dude Sep 26 '22 at 12:56
  • @Lundin Do you know how i can store a Array in the External Ram? I've found some information at https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/Atmel-11100-32-bitCortex-M4-Microcontroller-SAM4S_Datasheet.pdf on page number 71. But i'm can't see how i can store Data there. – Dominik Sep 26 '22 at 13:06
  • 1
    Nope and I wouldn't even consider it personally, since external memories is such a pain in the neck. Apart from extra complexity, they increase BoM and open up EMC vulnerabilities. Most people got fed up with 'em some 20 years back or so. So maybe consider migrating to another ATSAM instead. Or you know, optimize your code... – Lundin Sep 26 '22 at 13:14
  • I hardly believe you really need those big arrays. Maybe an x-y problem? What should they contain? – linuxfan says Reinstate Monica Sep 26 '22 at 13:30

0 Answers0