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/TM4C1294NCPDT: What's the correct way to manually link NDK libraries to a project?

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

I'm trying to manually configure my application using C code and Cfg*() functions (as described in spru523k, section 2.1), but I don't know what is the correct way to manually include the NDK libraries in my RTSC project. Before trying to add the libraries, the linker complained about a lot of unresolved symbols, as expected. So I tried to add the libraries in "Properties -> Build -> Linker -> File search path" window and included some *.aem4f files in NDK directories tree. (See screen attached)

After doing that, the unresolved symbols errors are over, but I've got a new failed allocation error. The memory allocation window shows that the .bss sector couldn't be allocated, as it can be seen in the print below:

Is this error occurring because of the way I'm including the ndk libraries? What's the correct way to add these libraries to the project?

Thanks in advance,

Ronan

  • The way you have added the libraries looks to be fine.

    The allocation error is happening because the size of the .bss section for your application is greater than the SRAM memory available. The large section size could be contributed by the libraries or by something in your application itself. You can further isolate which component(s) is contributing to the large section size by taking a look at the linker map file. To do that though you would first need a successful link.

    Open the linker command file in your project (the default one is usually named EK_TM4C1294XL.cmd). Edit the length of the SRAM memory region (from 0x40000 to something much larger, like 0x80000). Note that this is only meant to be a temporary change to allow the link to complete. After a successful link, open the linker map file (.map) generated by the build and scroll into the .bss section under Section Allocation Map details. That should show the breakdown and size of each input section that contributes to the .bss output section. Hopefully that will help you understand where the large sections are coming from so you can try to trim them down if they are coming from your application.  

  • Hi AartiG, thanks for the help!

    I did what you said and it seems that the biggest input section is:

    20000380    0004cb00     stk6.aem4f : pbm_data.oem4f (.bss:NDK_PACKETMEM)

    This can be seen in the memory allocation windows as well:

    Do you know how can I solve this? My code is just trying to initialize the stack and configure IP. Is there anything wrong with it?

    #include <ti/sysbios/knl/Clock.h>
    #include <ti/ndk/inc/netmain.h>
    
    void initIP(void* hCfg);
    void initDHCP(void *hCfg);
    void networkOpen();
    void networkClose();
    void networkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd);
    void serviceReport(uint32_t item, uint32_t status, uint32_t code, HANDLE hCfgEntry);
    
    extern void llTimerTick();
    
    const char *hostName    = "tisoc";
    const char *LocalIPAddr = "192.168.1.14";
    const char *LocalIPMask = "255.255.255.0";
    const char *GatewayIP   = "192.168.1.1";
    const char *DomainName  = "demo.net";
    
    void NDKStackTaskFxn()
    {
        HANDLE hCfg;
        int rc;
        Clock_Params clockParams;
        Clock_Handle ndkClockHandle;
    
        /* Create the NDK heart beat */
        Clock_Params_init(&clockParams);
        clockParams.startFlag = TRUE;
        clockParams.period = 1000;
        ndkClockHandle = Clock_create((Clock_FuncPtr)llTimerTick, clockParams.period,
                                      &clockParams, NULL);
        if (ndkClockHandle == NULL) {
            return;
        }
    
        rc = NC_SystemOpen(NC_PRIORITY_LOW, NC_OPMODE_INTERRUPT);
        if(rc) {
            return;
        }
    
        hCfg = CfgNew();
    
        if(!hCfg) {
            goto final;
        }
    
        initIP(hCfg);
        // initDHCP(void *hCfg);
    
        // Configure low priority task stack size
        rc = 2048;
        CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKLOW, CFG_ADDMODE_UNIQUE,
                    sizeof(uint32_t), (unsigned char *)&rc, NULL);
        // Configure normal priority task stack size
        rc = 2048;
        CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKNORM, CFG_ADDMODE_UNIQUE,
                    sizeof(uint32_t), (unsigned char *)&rc, NULL);
        // Configure high priority task stack size
        rc = 2048;
        CfgAddEntry(hCfg, CFGTAG_OS, CFGITEM_OS_TASKSTKHIGH, CFG_ADDMODE_UNIQUE,
                    sizeof(uint32_t), (unsigned char *)&rc, NULL);
    
        // Boot system
        do {
          rc = NC_NetStart(hCfg, networkOpen, networkClose, networkIPAddr);
        } while(rc > 0);
    
        // Shutting down...
        CfgFree(hCfg);
    
    final:
        NC_SystemClose();
    }
    
    
    
    void initIP(void* hCfg)
    {
        CI_IPNET NA;
        CI_ROUTE RT;
    
        // hostname
        CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
                    strlen(hostName), (unsigned char *)hostName, NULL);
    
        // Ip and mask
        bzero(&NA, sizeof(NA));
        NA.IPAddr  = inet_addr(LocalIPAddr);
        NA.IPMask  = inet_addr(LocalIPMask);
        strcpy(NA.Domain, DomainName);
        NA.NetType = 0;
        CfgAddEntry(hCfg, CFGTAG_IPNET, 1, 0, sizeof(CI_IPNET), (UINT8 *)&NA, 0);
    
        // Gateway
        bzero(&RT, sizeof(RT));
        RT.IPDestAddr = 0;
        RT.IPDestMask = 0;
        RT.IPGateAddr = inet_addr(GatewayIP);
        CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0, sizeof(CI_ROUTE), (UINT8 *)&RT, 0);
    
    
        // DNS
        IPN IPTmp;
        IPTmp = inet_addr("8.8.8.8");
        CfgAddEntry( hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_DOMAINNAMESERVER, 0, sizeof(IPTmp),
                     (unsigned char *)&IPTmp, 0 );
    }
    
    void initDHCP(void *hCfg)
    {
        CI_SERVICE_DHCPC dhcpc;
        unsigned char DHCP_OPTIONS[] = { DHCPOPT_SUBNET_MASK };
    
        // hostname
        CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
                    strlen(hostName), (unsigned char *)hostName, NULL);
    
        // Usa DHCP para obter IP na interface 1
        memset(&dhcpc, 0, sizeof(dhcpc));
          dhcpc.cisargs.Mode = CIS_FLG_IFIDXVALID;
          dhcpc.cisargs.IfIdx = 1;
          dhcpc.cisargs.pCbSrv = &serviceReport;
          dhcpc.param.pOptions = DHCP_OPTIONS;
          dhcpc.param.len = 1;
          CfgAddEntry(hCfg, CFGTAG_SERVICE, CFGITEM_SERVICE_DHCPCLIENT, 0,
                      sizeof(dhcpc), (unsigned char *)&dhcpc, NULL);
    }
    
    void networkOpen()
    {
    
    }
    
    void networkClose()
    {
    
    }
    
    void networkIPAddr(uint32_t IPAddr, uint32_t IfIdx, uint32_t fAdd)
    {
    
    }
    
    void serviceReport(uint32_t item, uint32_t status, uint32_t code, HANDLE hCfgEntry)
    {
        /*
         *  Item:        Item que sofreu alteração
         *  Status:      Novo status após alteração
         *  Code:        Report code (se houver)
         *  hCfgEntry    Ponteiro não referenciado para
         *               a entrada com mudança de status
         */
    }
    

    Thanks in advance,

    Ronan

  • Ronan Largura said:
    Do you know how can I solve this?

    From looking at the TCP Echo example in TI-RTOS for TivaC 2.16.00.08 the size of the .bss:NDK_PACKETMEM section is based upon the value of Global.pktNumFrameBufs in the .cfg file.

    The TCP Echo example has the following in the .cfg file:

    /* ================ NDK configuration ================ */
    var Global    = xdc.useModule('ti.ndk.config.Global');
    Global.pktNumFrameBufs = 10;

    Where the Global.pktNumFrameBufs value of 10 results in the .bss:NDK_PACKETMEM section being 16,120 bytes or 1,612 bytes per packet.

    Does your project contain a .cfg file and if so, what is Global.pktNumFrameBufs is set to?

    Based upon your .bss:NDK_PACKETMEM section being 314,122 bytes the NDK appears to be using a Global.pktNumFrameBufs of 194 packets. Reducing the value of Global.pktNumFrameBufs should reduce the size of the .bss:NDK_PACKETMEM section to allow the program to fit in the 256K SRAM of a TM4C1294NCPDT.