This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL-CC2640R2: Error #10099-d program will not fit into available memory

Part Number: LAUNCHXL-CC2640R2


Tool/software: Code Composer Studio

Hello,

I would like to first mention that my knowledge of CCS is still quite new, however I am currenty trying to implement the main function from an example code named nvsexternal.c from the TI Resource Explorer into the a modified version of the code also from the resource explorer named "simple_broadcaster" that reads, writes, and erases the external memory on a TI-CC2640 using the SPI. I was successfully able to run both programs seperately beforehand, but now upon inserting this SPI function into my main code, I am recieving this error:


"program will not fit into available memory.  placement with alignment fails for section ".TI.bound:NV_FLASH" size 0x1000 , overlaps with ".TI.bound:flashBuf$9", size 0x4000 (page 0) null: program will not fit into available memory.  placement with alignment fails for section ".TI.bound:NV_FLASH" size 0x1000 , overlaps with ".TI.bound:flashBuf$9", size 0x4000 (page 0) "

Here is the main function for the spi:

/******************************************************************
 * Defines (nvsexternal.c)
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
/* Driver Header files */
#include <ti/display/Display.h>
#include <ti/drivers/NVS.h>
/* Example/Board Header files */
#include "Board.h"
#define FOOTER "=================================================="
/* Buffer placed in RAM to hold bytes read from non-volatile storage. */
static char buffer[16];
static const char signature[] =
{"SimpleLinktest..."};
/*********************************************************************

void nvs_func(void)
{
    NVS_Handle nvsHandle;
    NVS_Attrs regionAttrs;
    NVS_Params nvsParams;
    Display_Handle displayHandle;
    /*
     * Wake up external flash on LaunchPads. It is powered off by default
     * but can be turned on by toggling the SPI chip select pin.
     */
    #ifdef Board_wakeUpExtFlash
    Board_wakeUpExtFlash();
    #endif
    Display_init();
    NVS_init();
    displayHandle = Display_open(Display_Type_UART, NULL);
    if (displayHandle == NULL) {
        /* Display_open() failed */
        while (1);
    }
    NVS_Params_init(&nvsParams);
    nvsHandle = NVS_open(Board_NVSEXTERNAL, &nvsParams);
    if (nvsHandle == NULL) {
        Display_printf(displayHandle, 0, 0, "NVS_open() failed.");
        return;
    }
    Display_printf(displayHandle, 0, 0, "\n");
      /*
     * This will populate a NVS_Attrs structure with properties specific
     * to a NVS_Handle such as region base address, region size,
     * and sector size.
     */
    NVS_getAttrs(nvsHandle, &regionAttrs);

    /* Display the NVS region attributes. */
    Display_printf(displayHandle, 0, 0, "Sector Size: 0x%x",
            regionAttrs.sectorSize);
    Display_printf(displayHandle, 0, 0, "Region Size: 0x%x\n",
            regionAttrs.regionSize);
    /*
     * Copy "sizeof(signature)" bytes from the NVS region base address into
     * buffer.
     */
    NVS_read(nvsHandle, 0, (void *) buffer, sizeof(signature));
    /*
     * Determine if the NVS region contains the signature string.
     * Compare the string with the contents copied into buffer.
     */
    if (strcmp((char *) buffer, (char *) signature) == 0) {
        /* Write buffer copied from flash to the console. */
        Display_printf(displayHandle, 0, 0, "%s", buffer);
        Display_printf(displayHandle, 0, 0, "Erasing SPI flash sector...");
        /* Erase the entire flash sector. */
        NVS_erase(nvsHandle, 0, regionAttrs.sectorSize);
    }
    else {
        /* The signature was not found in the NVS region. */
        Display_printf(displayHandle, 0, 0, "Writing signature to SPI flash...");
        /*
         * Write signature to memory. The flash sector is erased prior
         * to performing the write operation. This is specified by
         * NVS_WRITE_ERASE.
         */
        NVS_write(nvsHandle, 0, (void *) signature, sizeof(signature),
            NVS_WRITE_ERASE | NVS_WRITE_POST_VERIFY);
    }
    Display_printf(displayHandle, 0, 0, "Reset the device.");
    Display_printf(displayHandle, 0, 0, FOOTER);
    return;
}
/****************************************************************************

Here is also the memory allocation from the simple_broadcaster.c file:

I had previously tried reducing the size of my code overall, and removing the display_print functions with the thought of it being simply too large of a program, but as of now I am not sure where to begin with fixing this problem. Any guidance towards this issue would be greatly appreciated.

If there is anything else I can provide to help, I can do so gladly :)

 

Thanks!

-Steven

  • Upon further research, I found that my problem lies somewhere within my board file where I am allocating the data for my NVS functions. If it is any help here is what I have for the NVS section of my board file:

    * =============================== NVS ===============================
    */
    #include <ti/drivers/NVS.h>
    #include <ti/drivers/nvs/NVSSPI25X.h>
    #include <ti/drivers/nvs/NVSCC26XX.h>

    #define NVS_REGIONS_BASE 0x16000
    #define SECTORSIZE 0x1000
    #define REGIONSIZE (SECTORSIZE * 2)

    #ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH

    /*
    * Reserve flash sectors for NVS driver use by placing an uninitialized byte
    * array at the desired flash address.
    */
    #if defined(__TI_COMPILER_VERSION__)

    /*
    * Place uninitialized array at NVS_REGIONS_BASE
    */
    #pragma LOCATION(flashBuf, NVS_REGIONS_BASE);
    #pragma NOINIT(flashBuf);
    static char flashBuf[REGIONSIZE];

    #elif defined(__IAR_SYSTEMS_ICC__)

    /*
    * Place uninitialized array at NVS_REGIONS_BASE
    */
    static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;

    #elif defined(__GNUC__)

    /*
    * Place the flash buffers in the .nvs section created in the gcc linker file.
    * The .nvs section enforces alignment on a sector boundary but may
    * be placed anywhere in flash memory. If desired the .nvs section can be set
    * to a fixed address by changing the following in the gcc linker file:
    *
    * .nvs (FIXED_FLASH_ADDR) (NOLOAD) : AT (FIXED_FLASH_ADDR) {
    * *(.nvs)
    * } > REGION_TEXT
    */
    __attribute__ ((section (".nvs")))
    static char flashBuf[REGIONSIZE];

    #endif

    /* Allocate objects for NVS and NVS SPI */
    NVSCC26XX_Object nvsCC26xxObjects[1];

    /* Hardware attributes for NVS */
    const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {
    {
    .regionBase = (void *)flashBuf,
    .regionSize = REGIONSIZE,
    },
    };

    #endif /* Board_EXCLUDE_NVS_INTERNAL_FLASH */

    #ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH

    #define SPISECTORSIZE 0x1000
    #define SPIREGIONSIZE (SPISECTORSIZE * 32)
    #define VERIFYBUFSIZE 64

    static uint8_t verifyBuf[VERIFYBUFSIZE];

    /* Allocate objects for NVS External Regions */
    NVSSPI25X_Object nvsSPI25XObjects[1];

    /* Hardware attributes for NVS External Regions */
    const NVSSPI25X_HWAttrs nvsSPI25XHWAttrs[1] = {
    {
    .regionBaseOffset = 0,
    .regionSize = SPIREGIONSIZE,
    .sectorSize = SPISECTORSIZE,
    .verifyBuf = verifyBuf,
    .verifyBufSize = VERIFYBUFSIZE,
    .spiHandle = NULL,
    .spiIndex = 0,
    .spiBitRate = 4000000,
    .spiCsnGpioIndex = CC2640R2_LAUNCHXL_GPIO_SPI_FLASH_CS,
    .statusPollDelayUs = 100,
    },
    };

    #endif /* Board_EXCLUDE_NVS_EXTERNAL_FLASH */

    /* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */
    const NVS_Config NVS_config[CC2640R2_LAUNCHXL_NVSCOUNT] = {
    #ifndef Board_EXCLUDE_NVS_INTERNAL_FLASH
    {
    .fxnTablePtr = &NVSCC26XX_fxnTable,
    .object = &nvsCC26xxObjects[0],
    .hwAttrs = &nvsCC26xxHWAttrs[0],
    },
    #endif
    #ifndef Board_EXCLUDE_NVS_EXTERNAL_FLASH
    {
    .fxnTablePtr = &NVSSPI25X_fxnTable,
    .object = &nvsSPI25XObjects[0],
    .hwAttrs = &nvsSPI25XHWAttrs[0],
    },
    #endif
    };

    const uint_least8_t NVS_count = CC2640R2_LAUNCHXL_NVSCOUNT;

    /*
  • For those interested, I found my solution by changing the var NVS_REGIONS_BASE to 0x18000and keeping REGIONSIZE at (SECTORSIZE*2)


    #define NVS_REGIONS_BASE 0x18000
    #define SECTORSIZE 0x1000
    #define REGIONSIZE (SECTORSIZE * 2)
  • Hi Steven,

    Glad you where able to resolve this!

    Riz