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.

CC2650: ZNP compilation error when adding SPI driver

Part Number: CC2650
Other Parts Discussed in Thread: SYSBIOS, TIMAC,

Hi,

  When I add the SPI driver support and compiling ZNP stack in zstack_home_1_02_02a_44539 its throwing below error. If I comment SPIhandle = SPI_open(Board_SPI,&params); then its fine. What could be the reason for the below error. Any quick response will be greatly appreciated.

ZDApp.c ZDConfig.c ZDNwkMgr.c ZDObject.c ZDProfile.c ZDSecMgr.c   
zmac.c   
zmac_cb.c   
znpapp_task.c   
Linking  
Error[Lp011]: section placement failed  
          unable to allocate space for sections/blocks with a total estimated minimum size of 0x46bc bytes (max align 0x8) in <[0x200000c8-0x2000042f],   
[0x20000450-0x200004ff], [0x20000520-0x20004a13]> (total uncommitted space 0x4608).  
          Uncommitted:  
            [0x200000c8-0x2000042f]:  0x368  
            [0x20000200-0x2000042f]:  0x22c  
            [0x20000450-0x200004ff]:   0xb0  
            [0x20000520-0x20004a13]: 0x42f4  
Error[Lp011]: section placement failed  
          unable to allocate space for sections/blocks with a total estimated minimum size of 0x4c6c bytes (max align 0x4) in <[0x00000000-0x0001cfff]> (total   
uncommitted space 0x4bf8).  
          Uncommitted:  
            [0x00000000-0x000000ff]:    0x8  
            [0x00000510-0x00000513]:    0x2  
            [0x0000058c-0x0000058f]:    0x3  
            [0x000005e8-0x0001cfff]: 0x4bf0  
Error[Lp017]: the address of "ti_sysbios_knl_Task_Module_State_0_readyQ__A" was needed when computing compressed initializers for section   
.data_ti_sysbios_knl_Task_Module__state__V (app_prm3.orm3 #606), but that address hasn't been set yet, since the size of the compressed initializers are   
needed in order to set it  
Error[Lp017]: the address of "ti_sysbios_family_arm_m3_Hwi_Module_State_0_excActive__A" was needed when computing compressed initializers for   
section .data_ti_sysbios_family_arm_m3_Hwi_Module__state__V (app_prm3.orm3 #207), but that address hasn't been set yet, since the size of the   
compressed initializers are needed in order to set it  
Error[Lp017]: the address of "ti_sysbios_family_arm_cc26xx_Timer_Object__table__V" was needed when computing compressed initializers for section   
.data_ti_sysbios_knl_Clock_Module__state__V (app_prm3.orm3 #397), but that address hasn't been set yet, since the size of the compressed initializers are   
needed in order to set it  
Error[Lp017]: the address of "ti_sysbios_gates_GateMutex_Object__table__V" was needed when computing compressed initializers for section   
.data_ti_sysbios_BIOS_Module__state__V (app_prm3.orm3 #67), but that address hasn't been set yet, since the size of the compressed initializers are   
needed in order to set it  
Error[Lp017]: the address of "ti_sysbios_knl_Swi_Module_State_0_readyQ__A" was needed when computing compressed initializers for section   
.data_ti_sysbios_knl_Swi_Module__state__V (app_prm3.orm3 #571), but that address hasn't been set yet, since the size of the compressed initializers are   
needed in order to set it  
Error[Lp017]: the address of "ti_sysbios_family_arm_cc26xx_Timer_Object__table__V" was needed when computing compressed initializers for section   
.data_ti_sysbios_family_arm_cc26xx_Timer_Module__state__V (app_prm3.orm3 #154), but that address hasn't been set yet, since the size of the   
compressed initializers are needed in order to set it  
Error while running Linker  
 
Total number of errors: 8  
Total number of warnings: 0

  • It seems that you run out of Flash size. Do you add lots of custom codes to ZNP?

  • Hi YK Chen,
    Thanks for the quick reply. I haven't add any other custom code. I have included "ti/drivers/SPI.h" and added SPI_open for SPI0,then itself I am getting the error. How can I optimize to find some space for this?
  • Try to comment out the following MT_SAPI Interface in znp.cfg to build again.

    -DMT_SAPI_FUNC
    -DMT_SAPI_CB_FUNC

  • Hi YK Chen,
    That doesn't help. Is there any other way to optimise this. Or can we implement SPI driver in my code itself by directly configuring the registers instead of using heavy SPI driver from RTOS. Do you have any reference for that?
  • If you comment out the followings defines in znp.cfg, does it work?

    /* MT_ZDO interface */
    -DMT_ZDO_CB_FUNC
    -DMT_ZDO_FUNC
    -DMT_ZDO_MGMT
    -DMT_ZDO_EXTENSIONS
  • Hi YK Chen,
    That also doesn't work.
  • What is current error?
  • Hi YK Chen,
    Error comes down to 1. But still its placement failure. Please see the below error message


    zmac.c
    zmac_cb.c
    znpapp_task.c
    Linking
    Error[Lp015]: section placement failure: overcommitted content in [0x20000520-0x20004a13]
    Error while running Linker

    Total number of errors: 1
    Total number of warnings: 0
  • If you build original ZNP project, does it work?
  • Yes, original ZNP project works fine. Even if in my custom project I just comment out SPI_open, it works.
  • Can you attach your modified source file so I can check in my desktop?
  • Please see the attached bellow main.c. Just replace your main.c with this

    //******************************************************************************
    //! \file           main.c
    //! \brief          main entry of the ZNP application
    //
    //   Revised        $Date: 2015-01-27 17:10:29 -0800 (Tue, 27 Jan 2015) $
    //   Revision:      $Revision: 42069 $
    //
    //  Copyright 2015 Texas Instruments Incorporated. All rights reserved.
    //
    // IMPORTANT: Your use of this Software is limited to those specific rights
    // granted under the terms of a software license agreement between the user
    // who downloaded the software, his/her employer (which must be your employer)
    // and Texas Instruments Incorporated (the "License").  You may not use this
    // Software unless you agree to abide by the terms of the License. The License
    // limits your use, and you acknowledge, that the Software may not be modified,
    // copied or distributed unless used solely and exclusively in conjunction with
    // a Texas Instruments radio frequency device, which is integrated into
    // your product.  Other than for the foregoing purpose, you may not use,
    // reproduce, copy, prepare derivative works of, modify, distribute, perform,
    // display or sell this Software and/or its documentation for any purpose.
    //
    //  YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
    //  PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
    //  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
    //  NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
    //  TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
    //  NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
    //  LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
    //  INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
    //  OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
    //  OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
    //  (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    //
    //  Should you have any questions regarding your right to use this Software,
    //  contact Texas Instruments Incorporated at www.TI.com.
    //******************************************************************************
     
    // ****************************************************************************
    // includes
    // ****************************************************************************
    #include <xdc/std.h>
    #include <string.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
     
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/hal/Hwi.h>
     
    #include <ioc.h>
     
    #include "ICall.h"
    #include "Board.h"
    #include "TIMACBoard.h"
    #include "CryptoBoard.h"
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <ti/drivers/crypto/CryptoCC26XX.h>
     
    /* Header files required for the temporary idle task function */
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
    #include <aon_rtc.h>
    #include <prcm.h>
     
    /* Header files required to enable instruction fetch cache */
    #include <vims.h>
    #include <hw_memmap.h>
     
    #include "cpu.h"
    #include "znpapp_task.h"
    #include "inc/npi_task.h"
    #include "pwrmon.h"
     
    #include <ti/drivers/SPI.h>
    SPI_Handle      SPIhandle;
    SPI_Transaction spiTransaction;
    SPI_Params      params;
    #define Board_SPI                0
    #define SPI_FREQUENCY            160000         // 160KHz
     
    // ****************************************************************************
    // defines
    // ****************************************************************************
     
    #define MY_TASK_STACK_SIZE 600
     
    #define RFC_MODE_BLE                 PRCM_RFCMODESEL_CURR_MODE1
    #define RFC_MODE_IEEE                PRCM_RFCMODESEL_CURR_MODE2
    #define RFC_MODE_ANT                 PRCM_RFCMODESEL_CURR_MODE4
    #define RFC_MODE_EVERYTHING_BUT_ANT  PRCM_RFCMODESEL_CURR_MODE5
    #define RFC_MODE_EVERYTHING          PRCM_RFCMODESEL_CURR_MODE6
     
    #define SET_RFC_MODE(mode) HWREG(PRCM_BASE + PRCM_O_RFCMODESEL) = (mode)
     
    // Minimum voltage level need to run
    #if !defined (MIN_VDD_RUN)
    #define MIN_VDD_RUN         MIN_VDD_POLL
    #endif
     
    // ****************************************************************************
    // typedefs
    // ****************************************************************************
     
    // ****************************************************************************
    // globals
    // ****************************************************************************
     
    static Task_Struct myTask;
    static Char myTaskStack[MY_TASK_STACK_SIZE];
     
     
    //*****************************************************************************
    // function prototypes
    //*****************************************************************************
     
    // -----------------------------------------------------------------------------
    //! \brief      Entry function passed to TIRTOS
    //!
    //! \param[in]  a0    
    //! \param[in]  a1    
    //!
    //! \return     Void
    // -----------------------------------------------------------------------------
    Void taskFxn(UArg a0, UArg a1)
    {
         
       SPI_Params_init(&params);
        
       params.bitRate       = SPI_FREQUENCY;
       params.transferMode  = SPI_MODE_BLOCKING;
       params.frameFormat   = SPI_POL1_PHA1;
       params.dataSize      = 8;
        
       SPIhandle = SPI_open(Board_SPI,&params);
        
        /* Disallow shutting down JTAG, VIMS, SYSBUS during idle state
        * since TIMAC requires SYSBUS during idle. */
        Power_setConstraint(Power_IDLE_PD_DISALLOW);
         
        /* Initialize the Power Monitor */
        PWRMON_init();
         
        // Make sure the voltage level is high enough to operate
        while ( PWRMON_check( MIN_VDD_RUN ) == false )
        {
          // Add your own code to do something here, flash LED, sleep, something
          // For now, we will loop and wait for power comes up to the
          // MIN_VDD_RUN level.
        }
     
        /* Initialize ICall module */
        ICall_init();
         
        {
            CryptoCC26XX_Params CryptoCC26XXParams;
            extern CryptoCC26XX_Handle CryptoCC26XXHandle;
             
            CryptoCC26XX_init();
            CryptoCC26XX_Params_init(&CryptoCC26XXParams);
            CryptoCC26XXHandle = CryptoCC26XX_open(Board_CRYPTO, false, &CryptoCC26XXParams);
            if (!CryptoCC26XXHandle)
            {
                Task_exit();
            }
            Crypto_init();
        }
         
         
        /* Kick off ZNP threads */
        ZNPAppTask_task();
         
    }
     
    // -----------------------------------------------------------------------------
    //! \brief      TIRTOS exception handler
    //!
    //! \return     void
    // -----------------------------------------------------------------------------
    void exceptionHandler()
    {
        while(1) {}
    }
     
    // -----------------------------------------------------------------------------
    //! \brief      THE main function
    //!
    //! \return     void
    // -----------------------------------------------------------------------------
    Void main()
    {
        Task_Params taskParams;
         
        memset(&myTaskStack, 0xDD, sizeof(myTaskStack));
         
        // set RFC mode to support IEEE802.15.4
        // Note: This must be done before the RF Core is released from reset!
        SET_RFC_MODE(RFC_MODE_IEEE);
         
        // enable iCache prefetching
        VIMSConfigure(VIMS_BASE, TRUE, TRUE);
         
        // Enable cache
        VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
         
        /* Initialization for board related stuff such as LEDs
        * following TI-RTOS convention */
        PIN_init(BoardGpioInitTable);
         
        // Configure task.
        Task_Params_init(&taskParams);
        taskParams.stack = myTaskStack;
        taskParams.stackSize = MY_TASK_STACK_SIZE;
        taskParams.priority = 1;
        Task_construct(&myTask, taskFxn, &taskParams, NULL);
         
        BIOS_start();   /* enable interrupts and start SYS/BIOS */
    }
     
     
    // -----------------------------------------------------------------------------
    //! \brief      Error handler to be hooked into TI-RTOS
    //!
    //! \param[in]  eb   Error_Block
    //!
    //! \return     Void
    // -----------------------------------------------------------------------------
    Void smallErrorHook(Error_Block *eb)
    {
        while(1) {}
    }

  • Can you attach your main.c instead of paste it on E2E forum?
  • //******************************************************************************
    //! \file           main.c
    //! \brief          main entry of the ZNP application
    //
    //   Revised        $Date: 2015-01-27 17:10:29 -0800 (Tue, 27 Jan 2015) $
    //   Revision:      $Revision: 42069 $
    //
    //  Copyright 2015 Texas Instruments Incorporated. All rights reserved.
    //
    // IMPORTANT: Your use of this Software is limited to those specific rights
    // granted under the terms of a software license agreement between the user
    // who downloaded the software, his/her employer (which must be your employer)
    // and Texas Instruments Incorporated (the "License").  You may not use this
    // Software unless you agree to abide by the terms of the License. The License
    // limits your use, and you acknowledge, that the Software may not be modified,
    // copied or distributed unless used solely and exclusively in conjunction with
    // a Texas Instruments radio frequency device, which is integrated into
    // your product.  Other than for the foregoing purpose, you may not use,
    // reproduce, copy, prepare derivative works of, modify, distribute, perform,
    // display or sell this Software and/or its documentation for any purpose.
    //
    //  YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
    //  PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,l
    //  INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
    //  NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
    //  TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
    //  NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
    //  LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
    //  INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
    //  OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
    //  OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
    //  (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    //
    //  Should you have any questions regarding your right to use this Software,
    //  contact Texas Instruments Incorporated at www.TI.com.
    //******************************************************************************
    
    // ****************************************************************************
    // includes
    // ****************************************************************************
    #include <xdc/std.h>
    #include <string.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/hal/Hwi.h>
    
    #include <ioc.h>
    
    #include "ICall.h"
    #include "Board.h"
    #include "TIMACBoard.h"
    #include "CryptoBoard.h"
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <ti/drivers/crypto/CryptoCC26XX.h>
    
    /* Header files required for the temporary idle task function */
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <ti/sysbios/family/arm/cc26xx/PowerCC2650.h>
    #include <aon_rtc.h>
    #include <prcm.h>
    
    /* Header files required to enable instruction fetch cache */
    #include <vims.h>
    #include <hw_memmap.h>
    
    #include "cpu.h"
    #include "znpapp_task.h"
    #include "inc/npi_task.h"
    #include "pwrmon.h"
    
    #include <ti/drivers/SPI.h>
    SPI_Handle      SPIhandle;
    SPI_Transaction spiTransaction;
    SPI_Params      params;
    #define Board_SPI                0
    #define SPI_FREQUENCY            160000         // 160KHz
    
    // ****************************************************************************
    // defines
    // ****************************************************************************
    
    #define MY_TASK_STACK_SIZE 600
    
    #define RFC_MODE_BLE                 PRCM_RFCMODESEL_CURR_MODE1
    #define RFC_MODE_IEEE                PRCM_RFCMODESEL_CURR_MODE2
    #define RFC_MODE_ANT                 PRCM_RFCMODESEL_CURR_MODE4
    #define RFC_MODE_EVERYTHING_BUT_ANT  PRCM_RFCMODESEL_CURR_MODE5
    #define RFC_MODE_EVERYTHING          PRCM_RFCMODESEL_CURR_MODE6
    
    #define SET_RFC_MODE(mode) HWREG(PRCM_BASE + PRCM_O_RFCMODESEL) = (mode)
    
    // Minimum voltage level need to run
    #if !defined (MIN_VDD_RUN)
    #define MIN_VDD_RUN         MIN_VDD_POLL
    #endif
    
    // ****************************************************************************
    // typedefs
    // ****************************************************************************
    
    // ****************************************************************************
    // globals
    // ****************************************************************************
    
    static Task_Struct myTask;
    static Char myTaskStack[MY_TASK_STACK_SIZE];
    
    
    //*****************************************************************************
    // function prototypes
    //*****************************************************************************
    
    // -----------------------------------------------------------------------------
    //! \brief      Entry function passed to TIRTOS
    //!
    //! \param[in]  a0   
    //! \param[in]  a1   
    //!
    //! \return     Void
    // -----------------------------------------------------------------------------
    Void taskFxn(UArg a0, UArg a1)
    {
        
       SPI_Params_init(&params);
       
       params.bitRate       = SPI_FREQUENCY;
       params.transferMode  = SPI_MODE_BLOCKING;
       params.frameFormat   = SPI_POL1_PHA1;
       params.dataSize      = 8;
       
       SPIhandle = SPI_open(Board_SPI,&params);
       
        /* Disallow shutting down JTAG, VIMS, SYSBUS during idle state
        * since TIMAC requires SYSBUS during idle. */
        Power_setConstraint(Power_IDLE_PD_DISALLOW);
        
        /* Initialize the Power Monitor */
        PWRMON_init();
        
        // Make sure the voltage level is high enough to operate
        while ( PWRMON_check( MIN_VDD_RUN ) == false )
        {
          // Add your own code to do something here, flash LED, sleep, something
          // For now, we will loop and wait for power comes up to the
          // MIN_VDD_RUN level.
        }
    
        /* Initialize ICall module */
        ICall_init();
        
        {
            CryptoCC26XX_Params CryptoCC26XXParams;
            extern CryptoCC26XX_Handle CryptoCC26XXHandle;
            
            CryptoCC26XX_init();
            CryptoCC26XX_Params_init(&CryptoCC26XXParams);
            CryptoCC26XXHandle = CryptoCC26XX_open(Board_CRYPTO, false, &CryptoCC26XXParams);
            if (!CryptoCC26XXHandle)
            {
                Task_exit();
            }
            Crypto_init();
        }
        
        
        /* Kick off ZNP threads */
        ZNPAppTask_task();
        
    }
    
    // -----------------------------------------------------------------------------
    //! \brief      TIRTOS exception handler
    //!
    //! \return     void
    // -----------------------------------------------------------------------------
    void exceptionHandler()
    {
        while(1) {}
    }
    
    // -----------------------------------------------------------------------------
    //! \brief      THE main function
    //!
    //! \return     void
    // -----------------------------------------------------------------------------
    Void main()
    {
        Task_Params taskParams;
        
        memset(&myTaskStack, 0xDD, sizeof(myTaskStack));
        
        // set RFC mode to support IEEE802.15.4
        // Note: This must be done before the RF Core is released from reset!
        SET_RFC_MODE(RFC_MODE_IEEE);
        
        // enable iCache prefetching
        VIMSConfigure(VIMS_BASE, TRUE, TRUE);
        
        // Enable cache
        VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
        
        /* Initialization for board related stuff such as LEDs
        * following TI-RTOS convention */
        PIN_init(BoardGpioInitTable);
        
        // Configure task.
        Task_Params_init(&taskParams);
        taskParams.stack = myTaskStack;
        taskParams.stackSize = MY_TASK_STACK_SIZE;
        taskParams.priority = 1;
        Task_construct(&myTask, taskFxn, &taskParams, NULL);
        
        BIOS_start();   /* enable interrupts and start SYS/BIOS */
    }
    
    
    // -----------------------------------------------------------------------------
    //! \brief      Error handler to be hooked into TI-RTOS
    //!
    //! \param[in]  eb   Error_Block
    //!
    //! \return     Void
    // -----------------------------------------------------------------------------
    Void smallErrorHook(Error_Block *eb)
    {
        while(1) {}
    }
    
    Please see the attached

  • Hi Bibin,

    The thing to understand about the CC2650 ZNP is that you are extremely limited on flash and RAM space.  As seen from the icf file, 0x1D000/118784 of flash is available for readonly memory (0x1000 reserved and 0x2000 for SVN) and 0x4A13/18963 of RAM is allowed for readwrite memory.  Then looking at the default map file, you can see that 117k and 18.5k are already occupied in the flash/RAM, respectively. Therefore you will have to make some sacrifices to the size and configuration of your mesh network. Here are some variables that can be changed:

    NWK_MAX_DEVICE_LIST in nwk_globals.h and MAX_RTG_ENTRIES in znp_f8wConfig.cfg affects the RAM
    TC_LINKKEY_JOIN and DSECMGR_TC_DEVICE_MAX in C/C++ Compiler -> Preprocessor affects the flash

    For example, by changing to the Pro Secure build (no Link Keys) or removing the number of reserved pages to zero I got rid of the flash error, and by reducing my NWK_MAX_DEVICE_LIST to 16 and MAX_RTG_ENTRIES to 30 I was able to build the project without RAM issues.  Your SPI implementation currently adds 2.5k of flash and 408 bytes of RAM, both of which will only increase as you add functionality.

    Regards,
    Ryan