⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at https://www.dialog-semiconductor.com/support . We’ll be fixing bugs / optimising the searching and tagging over the coming days.
14 posts / 0 new
Last post
Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
RetRAM0 overflow

Hello,

I am using the DA14683 device on the eval-board with the actual SDK and tools.

It seem that I have a problem with the memory layout, that the compiler tells me to run out of memory, when requiring more then 32 KByte RAM. The following will be show:
App.elf section `RETENTION_RAM0' will not fit in region `RetRAM0'
RetRAM0' overflowed by 32 bytes

The following is my actual configuration (from custom_config_qspi.h)

#define dg_configOPTIMAL_RETRAM                    (0)
#define dg_configMEM_RETENTION_MODE                (0x1F)
#define dg_configQSPI_CACHED_RAM_SIZE_AE           ( 61 * 1024)
#define dg_configQSPI_CACHED_RETRAM_0_SIZE_AE      ( 67 * 1024)
#define dg_configQSPI_CACHED_RAM_SIZE_BB           ( 62 * 1024)
#define dg_configQSPI_CACHED_RETRAM_0_SIZE_BB      ( 66 * 1024)

I used this from an example an I would expect to have at least about 64 KByte RAM.

Even if playing around with the numbers, I could not solve the problem.

What do I have to configure to get the max. RAM size in a BLE application running in QSPI cached mode? I want to have the complete RAM retentioned.

By the way, is it correct to use the following configuration in the project settings:
 

dg_configBLACK_ORCA_IC_REV=BLACK_ORCA_IC_REV_B
dg_configBLACK_ORCA_IC_STEP=BLACK_ORCA_IC_STEP_B

Best regards
Dieter

Keywords: 
Device: 
Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Hello,

Hello,

I just recognized, that it is related to the adjustment of the FreeRTOS Heap

/*************************************************************************************************\
 * FreeRTOS specific config
 */
#define OS_FREERTOS                              /* Define this to use FreeRTOS */
#define configTOTAL_HEAP_SIZE                    16384   /* This is the FreeRTOS Total Heap Size */

So when I increas this number, then I get this problem.

It does not happen, when I increas some other buffer e.g. the Segger RTT (just for testing):

#define BUFFER_SIZE_UP                            (45000)   // Size of the buffer for terminal output of target, up to host (Default: 1k)

Then the compiler / linker output seems to be OK:

Invoking: Cross ARM GNU Create Flash Image
Invoking: Cross ARM GNU Print Size
   text	   data	    bss	    dec	    hex	filename
 187380	    216	  75556	 263152	  403f0	

Does this help to answer my question?

Best regards

Dieter

bobspam@free.fr
Offline
Last seen: 1 year 4 months ago
Joined: 2018-06-20 08:07
Hello

Hello

Memory map of the DA14683 is quite complex.

Please find a small awk script I use on the map file that is being produced by the compiler to locate various sections

 

{
    started = 0;
    again = 1;
    total_size = 0;
    first_address = (2^32) - 1;
    last_address = 0;
    printf("section;start;size;end;size;\n");
    do{
        if($0 ~ /memory map/)
            started = 1;
        if($0 ~ /^OUTPUT/)
            again = 0;
        if(started == 1 && $0 ~ /^[[:alnum:]\.]/){
        address = strtonum($2);
        size = strtonum($3);
        # if(address != 0 && size != 0){
        if(size != 0){
                if(address < first_address)
                    first_address = address;
                if(address > last_address)
                    last_address = address;
            printf("%s;0x%X;0x%X;0x%X;%u;\n", $1, address, size, address + size, size);
            total_size += size;
            }
        }
        if (getline <= 0)
            again = 0;
    } while(again > 0);
    printf("sum;;0x%X;;%u;\n", total_size, total_size);
    printf("range;0x%X;0x%X;0x%X;%u;\n", first_address, last_address - first_address, last_address, last_address - first_address);
    exit;
}

write this into a script.awk file and then run

#gawk -f script.awk yoursoftware.map

 

Purpose is to analyse the overall structure of the binary file to identify which section takes too much space and shall be reduced.

Then next step is to identify which heap/stack is where so you have a chance to set adjust sizes of each of them.

On my side I use the following configuration in the custom_config_qspi.h file

#define dg_configRAM_RETRAM_0_SIZE_BB           (64 * 1024)                    // retention ram blocks are 8k, 24k or 32k. contains os_heap
#define dg_configRAM_RAM_SIZE_BB                (64 * 1024)                    // sum of .bss, .heap, .stack
#define __HEAP_SIZE                             (24 * 1024)
#define __STACK_SIZE                            (16 * 1024)

and

#define configTOTAL_HEAP_SIZE                   (48* 1024)                     /* This is the FreeRTOS Total Heap Size */

Keep in mind that the physical RAM size is 144k among which retention ram is 64k.

About Flash sections, firmware partition is 0x7F000 size (~500kB) so your binary shall not exceed this.

 

Good luck (it took me hours to fit the software into the memory !)

Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Hello, and thank you very

Hello, and thank you very much for this detailed answer.

I will try your script as soon as possible.

Meanwhile, could you please tell me in which section the freeRTOS heap will go?

Another question is about the RAM sections:

- Is it correct that 64 KByte is the max. retentioned

- What would be the best strategy to use the residual RAM space for?

Best regards

Dieter

PM_Dialog
Offline
Last seen: 4 months 1 day ago
Staff
Joined: 2018-02-08 11:03
Hi Dieter Falk,

Hi Dieter Falk,

My apologies for my late response. Can you please indicate if the issue is solved after increasing the heap? Which was the error that you are getting? Did you run it in debug mode?

Thanks, PM_Dialog

Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Hello,

Hello,

my current memory configuration is like that:

/*************************************************************************************************\
 * Memory layout specific config
 */
#define dg_configOPTIMAL_RETRAM                    (0)
#define dg_configMEM_RETENTION_MODE                (0x1F)
#define dg_configQSPI_RETRAM_0_SIZE_BB             ( 64 * 1024)
#define dg_configQSPI_CACHED_OPTIMAL_RETRAM_0_SIZE ( 64 * 1024)
#define dg_configQSPI_RAM_SIZE_BB                  ( 64 * 1024)
#define __HEAP_SIZE                                (  1 * 1024)
#define __STACK_SIZE                               ( 16 * 1024)


/*************************************************************************************************\
 * FreeRTOS specific config
 */
#define OS_FREERTOS                              /* Define this to use FreeRTOS */
#define configTOTAL_HEAP_SIZE                    (15 * 1024)  /* This is the FreeRTOS Total Heap Size */

This works, and my linker output is:

Invoking: Cross ARM GNU Create Flash Image
Invoking: Cross ARM GNU Print Size
   text	   data	    bss	    dec	    hex	filename
 178900	    212	  32680	 211792	  33b50

When I increase configTOTAL_HEAP_SIZE  to (16 * 1024) then the linker fails I I get the folling output:

Invoking: Cross ARM C++ Linker
c:/dialogsemi/smartsnippetsstudio2.0.10/gcc/4_9-2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: firmware.elf section `RETENTION_RAM0' will not fit in region `RetRAM0'
c:/dialogsemi/smartsnippetsstudio2.0.10/gcc/4_9-2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region `RetRAM0' overflowed by 224 bytes
collect2.exe: error: ld returned 1 exit status

The same issue happens in DEBUG and RELEASE build (DA14683-00-Debug_QSPI, DA14683-00-Release_QSPI)

Best regards

Dieter

bobspam@free.fr
Offline
Last seen: 1 year 4 months ago
Joined: 2018-06-20 08:07
Hello

Hello

 

small erratum with the dg_config I now use (for custom_config_qspi.h)

 

#define dg_configQSPI_CACHED_RETRAM_0_SIZE    ( 96 * 1024)                   // contains ucHeap[] aka .os_heap aka FreeRTOS Heap.
#define dg_configQSPI_CACHED_RETRAM_1_SIZE    (  0 * 1024)                   // no data in that section.
#define dg_configQSPI_CACHED_RAM_SIZE            ( 32 * 1024)                   // sum of .bss, .heap, .stack. (128k - RETRAM0 - BLERET)
#define configTOTAL_HEAP_SIZE                   ( 47 * 1024)                   // This is the FreeRTOS Total Heap Size, ucHeap[] in .os_heap section. See xMinimumEverFreeBytesRemaining symbol to know how much memory has never been used.
#define __HEAP_SIZE                             ( 15 * 1024)                   // 15ko see heapend symbol in debug tool - __HeapBase in .map file. use port heap overflow verification to check size. required for newlib (printf, strtok are high consumers)
#define __STACK_SIZE                            (  1 * 1024)                   // 1ko : __StackTop in .map file - MSP register of Cortex-M0. only used at boot time must not be null.

I also use

#define dg_configSHUFFLING_MODE                 (0x0)                          // 0x0 natural order. Retention ram blocks are 8k, 24k or 32k.
#define dg_configMEM_RETENTION_MODE             (0x1F)                         // all memory blocks retained

to avoid memory switch off during execution.

 

In your case I would suggest to

- raise up RETRAM_0_SIZE

- raise down RAM_SIZE by the same amont

- invert sizes of HEAP and STACK because the stack is only used at boot time and then FreeRTOS sets dedicated stacks for each tasks. heap is used by "not freertos" code like newlib so you should keep some ~15kB if you use printf or strtok. I am assuming that you use heap_4.c allocation strategy of FreeRTOS. You could use heap_6.c from latest versions of FreeRTOS to withdraw os_heap and share .heap with newlib.

 

Best Regards

 

PM_Dialog
Offline
Last seen: 4 months 1 day ago
Staff
Joined: 2018-02-08 11:03
Hi Dieter Falk,

Hi Dieter Falk,

Are you running any of our SDK projects? Can you please help me to replicate it in my side? Is your issue solved after setting BUFFER_SIZE_UP macro to 45000?

Thanks, PM_Dialog

Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Hello,

Hello,

I tried to config the "pxp_reporter" in the  "custom_config_qspi_suota.h" and changed there :
#define configTOTAL_HEAP_SIZE   16800

And get the following error:

... pxp_reporter.elf section `RETENTION_RAM0' will not fit in region `RetRAM0'
... `RetRAM0' overflowed by 256 bytes

I also put the BUFFER_SIZE_UP macro in it, but this does not change anything.

It would be great if you can rerpoduce this on your side and provide a solution for this issue. Thank you!

Best regards

Dieter

PM_Dialog
Offline
Last seen: 4 months 1 day ago
Staff
Joined: 2018-02-08 11:03
Hi Dieter Falk,

Hi Dieter Falk,

Would it be possible to share the custom_config_qspi_suota.h file that you are using in your setup?

Additionally, what is the configuration that is working and which that is not working?

Have you done any other modifications in the pxp_reporter project?

In your initial post, I saw that you are using non-optimal configuration.  During this configuration, the freeRTOS heap will be placed in RETRAM_0 and when utilizing RETRAM_1, will be placed here.

If you increase the total heap size (configTOTAL_HEAP_SIZE) to 22000, does this have any effect?

Thanks, PM_Dialog

Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Hello,

Hello,

regarding the "pxp_reporter" project, I just checked that I I use the original project from "DA1468x_DA15xxx_SDK_1.0.14.1081".

The only thing you have to change (to get the error) is to increase the line of the
#define configTOTAL_HEAP_SIZE

and put 16800 instead of the original definition behind it.

I put my adapted custom_config_qspi_suota.h  file to this reply, so normally you should be able to reproduce this on your site.  I am looking forward on your results.

Best regards
Dieter

PM_Dialog
Offline
Last seen: 4 months 1 day ago
Staff
Joined: 2018-02-08 11:03
Hi Detier,

Hi Detier,

I used the same custom_config_qspi_suota.h header file in the pxp_reporter example of the SDk but I am not able to replicate this error. Additionally, I built the project for SUOTA configuration, Should I do any other steps in order to replicate this error except from your own custom_config_qspi_suota.h?

Thanks, PM_Dialog

Dieter Falk
Offline
Last seen: 1 year 6 months ago
Joined: 2019-10-12 10:33
Could you please provide

Could you please provide which SmartSnippet Version, and which SDK you have used for this test?

I have no idea what could be different, if using exactly the same developing environment and original example.

I could try to do an installation on another computer and check again on my side. Also for this action I need your feedback on which versions you are using.

Best regards 

Dieter

PM_Dialog
Offline
Last seen: 4 months 1 day ago
Staff
Joined: 2018-02-08 11:03
Hi Dieter Falk,

Hi Dieter Falk,

I am using the SDK_1.0.14 and the SmartSnippets Studio v.1.6.3.  This version is available on the DA14682/683 product page under “Development Tools” section.

https://www.dialog-semiconductor.com/products/connectivity/bluetooth-low-energy/smartbond-da14682-and-da14683

Could you please try it in a new SDK directory?

Thanks, PM_Dialog