This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nrF5340 Using all RAM on application processor when compiling with zephyr

Hi,

I have an application that needs 256kB of RAM however when I try to compile the code for the application processor it complains that there is only 64kB available. As if the linker doesn't know what is the available size of the RAM


Linking ‘zephyr_prebuilt.elf’
B 1 MB 1.25%
B 64 KB 128.30%
zephyr\zephyr_prebuilt.elf section `bss' will not fit in region `SRAM'
section .intList VMA [20010000,20010037] overlaps section bss VMA [20000000,20013a2a]
region `SRAM' overflowed by 18544 bytes
ld returned 1 exit status
B 2 KB 2.73%
Build failed

I am using segger IDE for nordic and NCS with zephyr. As a starting point I am using the blinky app from the samples directory with the build_nrf5340_dk_nrf5340_cpuapp selected as target board

Can you please advise what do I need to change get access to the entire 512kB of RAM

Thanks

Dusan

  • Hi Dusan,

    I have the nRF5340-PDK and also tried the blinky app.  I didn't have any problem using 400kB in main.c.   Below is the blinky sample program I used to allocate, fill, and, check the memory.    It looks like we have 448kB to play with, as 64kB is allocated to the secure image.   For memory layout see \ncs\zephyr\boards\arm\nrf5340_dk_nrf5340\nrf5340_dk_nrf5340_cpuapp_partition_conf.dts.   Have you tried a clean install of the tools with ncs v1.2.0?

    /* Default SRAM planning when building for nRF5340 with
     * ARM TrustZone-M support
     * - Lowest 64 kB SRAM allocated to Secure image (sram0_s)
     * - Middle 384 kB allocated to Non-Secure image (sram0_ns)
     * - Upper 64 kB SRAM allocated as Shared memory (sram0_shared)
     *   (see nrf5340_dk_nrf5340_shared_sram_planning_conf.dts)
     */
    &sram0 {
    	reg = <0x20000000 DT_SIZE_K(448)>;
    };
    
    &sram0_s {
    	reg = <0x20000000 0x10000>;
    };
    
    &sram0_ns {
    	reg = <0x20010000 0x60000>;
    };

    /*
     * Copyright (c) 2016 Intel Corporation
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include "zephyr.h"
    #include "device.h"
    #include "drivers/gpio.h"
    
    #define LED_PORT	DT_ALIAS_LED0_GPIOS_CONTROLLER
    #define LED		DT_ALIAS_LED0_GPIOS_PIN
    
    /* 1000 msec = 1 sec */
    #define SLEEP_TIME	1000
    #define SLEEP_TIME_SHORT 100
    
    #define NUM_U32 100000
    u32_t test[NUM_U32];
    
    void main(void)
    {
    
    	struct device *dev;
    
            u32_t cnt = 0;
    	dev = device_get_binding(LED_PORT);
    	/* Set LED pin as output */
    	gpio_pin_configure(dev, LED, GPIO_DIR_OUT);
    
            // set memory
            for (int i = 0; i < NUM_U32; i++)
              test[i]=i;
    
            // check memory
            bool ok = true;
            for (int i = 0; i < NUM_U32; i++)
            {
              if (i != test[i])
                ok = false;
            }
    
    	while (1) {
    		/* Set pin to HIGH/LOW every 1 second, if memory is incorrect, then blink faster */
    		gpio_pin_write(dev, LED, cnt % 2);
    		cnt++;
    		k_sleep(ok ? SLEEP_TIME : SLEEP_TIME_SHORT);
    	}
    }
      

  • Hi,

    Thanks for the info where to find the memory allocation definitions. 

    I had to remove the entire ncs directory, re-download, reconfigure the project and then in worked.

    It seems that something went wrong even though I did a checkout previously. It seems that it needed a fresh download.

    Thanks for your help

    Dusan

Related