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.

66AK2G12: EVMK2G12

Part Number: 66AK2G12


Hi, 

I am trying to run SPI basic ARM example in Bare metal . when I am trying to build the example I am getting the below error's .

But the same code works fine for BIOS . when i am trying to change it for Bare metal using #define BARE_METAL 1 I am getting these errors. I tried the same procedure for UART example its working fine without any errors for both BIOS and Bare metal. Can any one help me to solve this issue.

Note : I am using ccs version 9.3  and Imported PDK example as per the procedure given in this document.

Thanks in advance.

  • Hi,

    I tried to build this example for bare-metal use case. The build failed too, but I got different errors:

     undefined first referenced                                                                                                                         
      symbol       in file                                                                                                                              
     --------- ----------------                                                                                                                         
     spi_test  C:\ti\pdk_k2g_1_0_16\packages\MyExampleProjects\SPI_BasicExample_evmK2G_c66xExampleProject\Debug\configPkg\package\cfg\spi_test_pe66.oe66
     
    error #10234-D: unresolved symbols remain
    error #10010: errors encountered during linking; "SPI_BasicExample_evmK2G_c66xExampleProject.out" not built
    

    This error happens because function spi_test() is not defined for bare-metal but used in spi_test.cfg. I fixed this error by defining spi_test() for both use cases. Please see attached C code as a reference.

    /**
     *  \file   main_spi_flash_read_example.c
     *
     *  \brief  Example application main file. This application will read
     *          the data from flash through spi interface.
     *
     */
    
    /*
     * Copyright (C) 2015 - 2018 Texas Instruments Incorporated - http://www.ti.com/
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * Redistributions of source code must retain the above copyright
     * notice, this list of conditions and the following disclaimer.
     *
     * Redistributions in binary form must reproduce the above copyright
     * notice, this list of conditions and the following disclaimer in the
     * documentation and/or other materials provided with the
     * distribution.
     *
     * Neither the name of Texas Instruments Incorporated nor the names of
     * its contributors may be used to endorse or promote products derived
     * from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    #define BARE_METAL
    
    #ifndef BARE_METAL
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/System.h>
    #include <stdio.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #endif
    
    /* SPI Header files */
    #include <ti/drv/spi/SPI.h>
    #if defined(SOC_K2H) || defined(SOC_K2K) || defined(SOC_K2E) || defined(SOC_K2L) || defined(SOC_K2G) || defined(SOC_C6678) || defined(SOC_C6657) || defined(SOC_OMAPL137) || defined(SOC_OMAPL138)
    #include <ti/drv/spi/src/v0/SPI_v0.h>
    #endif
    #include <ti/drv/spi/soc/SPI_soc.h>
    #include <ti/drv/spi/test/src/SPI_log.h>
    #include <ti/drv/spi/test/src/SPI_test.h>
    
    /* Board Header files */
    #include <ti/board/board.h>
    #include <ti/board/src/flash/include/board_flash.h>
    
    /**********************************************************************
     ************************** Macros ************************************
     **********************************************************************/
    
    /**********************************************************************
     ************************** Internal functions ************************
     **********************************************************************/
    
    /**********************************************************************
     ************************** Global Variables **************************
     **********************************************************************/
    
    /* Buffer containing the received data */
    uint8_t rxBuf[TEST_TX_LENGTH];
    
    /* transfer length */
    uint32_t transferLength;
    
    /*
     *  ======== Board_initSPI ========
     */
    void Board_initSPI(void)
    {
        Board_initCfg boardCfg;
    #if defined(SOC_K2H) || defined(SOC_K2K) || defined(SOC_K2E) || defined(SOC_K2L) || defined(SOC_K2G) || defined(SOC_C6678) || defined(SOC_C6657) || defined(SOC_OMAPL137) || defined(SOC_OMAPL138)
        SPI_v0_HWAttrs spi_cfg;
        Board_SoCInfo socInfo;
    
        /* Get the default SPI init configurations */
        SPI_socGetInitCfg(TEST_SPI_PORT, &spi_cfg);
    
        /* Update the SPI functional clock based on CPU clock*/
        Board_getSoCInfo(&socInfo);
        if(socInfo.sysClock != BOARD_SYS_CLK_DEFAULT)
        {
            spi_cfg.inputClkFreq = socInfo.sysClock/SPI_MODULE_CLOCK_DIVIDER;
        }
    
        /* Set the default SPI init configurations */
        SPI_socSetInitCfg(TEST_SPI_PORT, &spi_cfg);
    #endif
    
    #if defined(evmK2E) || defined(evmC6678)
        boardCfg = BOARD_INIT_MODULE_CLOCK |
            BOARD_INIT_UART_STDIO;
    #else
        boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK |
            BOARD_INIT_UART_STDIO;
    #endif
        Board_init(boardCfg);
    }
    
    
    /*
     *  ======== test function ========
     */
    void spi_test()
    {
        Board_flashHandle  boardHandle;
        Board_FlashInfo   *flashInfo;
        uint32_t           blockNum, pageNum;
        SPI_Params       spiParams;                        /* SPI params structure */
        bool               testPassed = true;
    
    #ifdef BARE_METAL
        /* Call board init functions */
        Board_initSPI();
    #endif
    
        /* Open the Board flash NOR device with the test SPI port
           and use the default SPI configurations */
        SPI_Params_init(&spiParams);
        spiParams.frameFormat  = SPI_POL0_PHA1;
        boardHandle = Board_flashOpen(TEST_NOR_DEV_ID,
                                      TEST_SPI_PORT,
                                      (void *)(&spiParams));
        if (!boardHandle)
        {
            SPI_log("\n Board_flashOpen failed. \n");
            goto err;
        }
        else
        {
            flashInfo = (Board_FlashInfo *)boardHandle;
            SPI_log("\n SPI NOR device ID: 0x%x, manufacturer ID: 0x%x \n",
                    flashInfo->device_id, flashInfo->manufacturer_id);
        }
    
        if (Board_flashOffsetToBlkPage(boardHandle, TEST_NOR_ADDR,
                                       &blockNum, &pageNum))
        {
            SPI_log("\n Board_flashOffsetToBlkPage failed. \n");
            testPassed = false;
            goto err;
        }
    
        /* Set the transfer length in number of 32 bit words */
        transferLength = TEST_TX_LENGTH;
    
        /* Read data from flash */
        if (Board_flashRead(boardHandle, TEST_NOR_ADDR, (uint8_t *)&rxBuf[0],
                            TEST_TX_LENGTH, NULL))
        {
            SPI_log("\n Board_flashRead failed. \n");
            testPassed = false;
            goto err;
        }
    
        Board_flashClose(boardHandle);
    
    err:
        if(true == testPassed)
        {
            SPI_log("\n All tests have passed. \n");
        }
        else
        {
            SPI_log("\n Some tests have failed. \n");
        }
    
        while(1);
    }
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
    #ifndef BARE_METAL
        /* Call board init functions */
        Board_initSPI();
    
        /* Start BIOS */
        BIOS_start();
    #else
        spi_test();
    #endif
        return (0);
    }
    
    
    Please try it out and see if it fixes your problem.

    Thanks,

    Jianzhong

  • Hi,

    Thanks for reply. I tried to build the code given by you , and it was built without any error . But when I am trying to debug it , it automatically moves to the exit.c file without entering into the main function. I have attached the snap shop for your reference.

    Can you please help me to resolve this issue. Thanks in advance.

  • Hi,

    This seems to be related to TI-RTOS (BIOS). Since you're making a bare-metal application, I would recommend you to create a new project from scratch without adding any BIOS or XDC related stuff.

    Regards,

    Jianzhong

  • Hi, 

    I today  tried creating a new project from scratch for SPI Baremetal application. But I have got the following errors.

    I have included all the header files that are needed for this application.

    The CCS studio is also able to detect those header files while I'm trying to do open declaration.

    can you please help me to resolve this issue.

  • Hi,

    You missed header files from a few PDK drivers, for example:

    #include <ti/board/board.h>
    #include <ti/drv/uart/UART.h>
    #include <ti/drv/uart/UART_stdio.h>

    You can search the undefined functions and figure out which driver provides them and then add header include path to compiler options and add linker include paths to linker options.

    Regards,

    Jianzhong

  • Hi,

    I have added all the header files as u said . I have also included the file search path in linker .Even then I'm getting the same error.

    can you please help to sort out this issue .

    Thanks in advance.

  • Hi,

    I'm a little confused here. It seems you clicked the "This resolved my issue" button. Are you still having difficulties building the project?

    Thanks,

    Jianzhong

  • Hi,

    Sorry i was in off for past few days . 

    Yes I'm still facing the same issue when i try to build the project . Even after including all the header files in include directory and also in file search path.

  • Can you attach your CCS project so that I can take a look?

  • 3326.spi.rar

    I have attached the Project file.

  • I looked at your project. You missed libraries in linker settings. The example CCS project you tried earlier has XDC .cfg file so you don't have specify each individual library. Now you're working on baremetal project without using XDC, you'll have to specify each library from the PDK that you use. For example, below picture shows how to add SPI lib.

  • Hello jianzhongxu,

    I tried adding all the dependent library files even then I'm facing the same error.

    Our requirement is to run the 66ak2g DSP and ARM in BARE-METAL .

    Below is my question

    1. Is there any example project for BARE-METAL that are tested with EVMK2G board? if yes, can you please share that.

    2. If i need to create a Bare-metal code from scratch how to approach with register's ? is there any API's available ?

    can you please help me in this issue .

  • 1. Is there any example project for BARE-METAL that are tested with EVMK2G board? if yes, can you please share that.

    There are bare-metal DSP examples in processor_sdk_rtos_k2g_6_03_00_106\demos\audio-benchmark-starterkit. You can create the projects by:

    C:\ti\processor_sdk_rtos_k2g_6_03_00_106>setupenv.bat
    C:\ti\processor_sdk_rtos_k2g_6_03_00_106>cd demos\audio-benchmark-starterkit
    C:\ti\processor_sdk_rtos_k2g_6_03_00_106\demos\audio-benchmark-starterkit>BenchmarkProjectCreate.bat
    

    You can find more information at https://software-dl.ti.com/processor-sdk-rtos/esd/docs/06_03_00_106/rtos/index_examples_demos.html#audio-benchmark-starterkit.

    2. If i need to create a Bare-metal code from scratch how to approach with register's ? is there any API's available ?

    You'll need to use the CSL (chip-support-library): pdk_k2g_1_0_16\packages\ti\csl

  • Hi, 

    I tried creating a new BARE-METAL project from scratch using csl api's . But i got errors like "undefined reference" . I have attached the snapshot of the error , also i have attached the project file for your reference.

    gpio_csl.rar

    Also i have another doubt when i gone through CSL example folder make file and source file I came to know that API's are only available for AM65xx_evm , j721e_evm . But in my case i need for K2G , is there any separate API's available for K2G ? 

  • I tried creating a new BARE-METAL project from scratch using csl api's . But i got errors like "undefined reference" . I have attached the snapshot of the error , also i have attached the project file for your reference.

    This error happens because you don't have the CSL library in your linker library search path. Please refer to my earlier post.

    Also i have another doubt when i gone through CSL example folder make file and source file I came to know that API's are only available for AM65xx_evm , j721e_evm . But in my case i need for K2G , is there any separate API's available for K2G ?

    Can you be more specific here? I don't know what you meant. If you downloaded K2G SDK, the CSL in PDK should have support for K2G. You may find specific code for other devices, but K2G CSL will definitely be there. The API should be the same for all devices.