2012-05-13 09:30 AM
Good day,
I was playing with ST32F103RET6 MCU.I looked in datasheet, my MCU has 64Kb of SRAM, so I could easily create array with 20 kbytes. But I cannot.I use IAR compiler, What can be wrong. I can create only 1800byte array.unsigned char my_array[1800];If I create something like my_array[3000]. My MCU going to reset..Thank you. #ram #linker-error2012-05-13 01:18 PM
Sounds like you need to select the correct CPU target in your GUI, or within your linker script or scatter file. You don't however specify the tool chain, so it's hard to say specifically. Either way the software needs to know the settings which are appropriate for the hardware you are using.
If these are local allocations, you will need to assure that your stack is sufficiently large.2012-05-13 07:38 PM
Hi Clive1,
I have similar problem. I use IAR embedded workbench IDE v6.30, FreeRTOS, ST LINK on windows 7.I use Olimex STM32-P103 board which has STM32F103RBT6 micro. I'm trying to adapt ST firmware provided forhttp://www.st.com/internet/evalboard/product/250367.jsp
board. I get the following linker error:Error[Lp011]: section placement failed: unable to allocate space for sections/blocks with a total estimated minimum size of 0x583c bytes in <[0x20000000-0x20004fff]> (total uncommitted space 0x5000). The microcontroller RAM adress is 0x20000000-0x20004fff.I don't know whats the problem. If I'm facing RAM shortage problem, how to solve this problem without using any external RAM.Thank you
2012-05-13 11:57 PM
Hi,
I choosed the correct CPU, Il give you the message from debugger:The stack pointer for stack 'CSTACK' (currently 0x1FFFF4D8) is outside the stack range (0x200000B0 to 0x200008B0)for harinath:if you use freertos, then try to change this file FreeRTOSConfig.hand this line: Its total allocated ram. good luck 🙂#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 55 * 1024 ) )2012-05-14 10:23 AM
I don't know whats the problem. If I'm facing RAM shortage problem, how to solve this problem without using any external RAM.
The simple answer is to use less of the memory you have. The more complicated answer is to go through the .MAP, or equivalent, file and figure out what static allocations you are doing which are hogging resources. Identify where the memory is going, and why. Can you make certain data ''static const'' so that it stays in ROM? Can you fold a number of buffers, or other allocations, so they share the same memory footprint? This can help if there are no interdependencies, you'll have to examine/understand those. Consider dynamic allocation methods, can you for instance have a pool of different fixed size blocks? A PC allocator probably won't work well due to fragmentation issues. Do you understand your call trees well enough to be able to allocated local storage on a larger stack? You need to have a clear idea of the potential stack depth rather than just experimenting and arbitrarily increasing the size. Use a smaller ring buffer, instead of allocating ten ~1500 byte ethernet buffers, for example. The implementation is more complex, but will use less memory.2012-05-14 10:28 AM
The stack pointer for stack 'CSTACK' (currently 0x1FFFF4D8) is outside the stack range (0x200000B0 to 0x200008B0)
Well that sounds like you have a 2048 byte stack, to which you're stuffing 5080 bytes. For local/auto variables you need to define a stack big enough to meet your needs. If you want if to use non-stack RAM, use the static keyword, or define if globally.
2012-05-14 10:04 PM
Thank you, yes, I tried to change Cstack settings and it worked, till something like 20kbs, then I put static keyword before my array, and it worked, but weird thing is that I need to use some delay before operations if I do not want to have some wrong data like delay_us(2);
So now I can put my resized array of 38400 bytes to memory (160x120x2(16bytes)).2012-05-14 10:13 PM
''Can you make certain data ''static const'' so that it stays in ROM?''
About static const, yes I could some, but the program itself has no so much data, so I do not think that it could make any difference.''Consider dynamic allocation methods, can you for instance have a pool of different fixed size blocks? A PC allocator probably won't work well due to fragmentation issues.''I thinked about that, but do not like dynamic allocations, sometimes you do not know what could happen if somewhere memory is not free'd correctly.Actually everything is nice with static array. You see I have the camera I want to read the image. Original size is 320x240 and 16bit so 320x240x2=153600bytes image. So its not possible to put the image to memory. I thought I will do some resizing. With your help I could but 1/4 of image to memory so its ok, for now its nice, I could do some image processing. Later on, If I want to have full image I need external memory. Have you worked with external memory? Can you give me some advice, which one to buy, I need some fast one, not much something like 400kbytes to store 1-2 images.Thank you,//Nikolaj2012-05-17 02:34 AM
clive1
I initialized my array like this. Sometimes it works, sometimes it is not.static unsigned char image_array[160][120][2];I mean when I do some image editing my array going to be distorted.. Maybe you know why? In some cases delay_us() function helps, but in some do not, I will post some code here which is not working..for(int k = 0; k < 117; k++){for(int j = 0; j < 157; j++){ if((image_array[j][k][1] == 0x7F) && (image_array[j][k][0] == 0xFF)){ if(image_array[j+2][k][0] == 0xFF){ image_array[j+1][k][0]=0xFF; image_array[j+1][k][1]=0x7F; } if(image_array[j][k+2][0] == 0xFF){ image_array[j][k+1][0]=0xFF; image_array[j][k+1][1]=0x7F; }} }}And here is the image:1. Good2012-05-17 06:54 PM
''And like I said in some cases I put delay and it works..''
It' not clear where you put the delay ? When taking data from flash and putting in RAM, there should not be any need for delay. Is your CPU configuration correct ? for image processing, are you trying to change some colour ?