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.

RTOS/AM3359: Task definition

Part Number: AM3359

Tool/software: TI-RTOS

Hi TI,

   beaglebone black, processor SDK RTOS 4.2.0.9, ccs 7.4

I am working on SPI data transfer with TI-RTOS on BBB board, and seeing the following codes in the example project main() function.

    Task_Handle task;
    Error_Block eb;

    Error_init(&eb);

    task = Task_create(spi_test, NULL, &eb);
    if (task == NULL) {
        UART_printf("Task_create() failed!\n");
        BIOS_exit(0);
    }

I expect the above codes are equivalent to the definition of task0 in app.cfg (ref the attached screen-shot below), and I commented out the above codes in the main() function. Obviously they are different. The compile error message did not reveal too much useful information (also shown on the screen-shot).

 

Please advise, thanks in advance,


  • The RTOS team have been notified. They will respond here.
  • Please copy complete build log from your console and attach it as a text file for us to analyze the error. If may also help if you attach the .cfg file after you added the task using XGCONF tool.

    Regards,
    Rahul
  • **** Build of configuration Debug for project zzmcspi ****
    
    /opt/ti/ccsv7/utils/bin/gmake -k -j 4 all -O 
     
    making ../src/sysbios/sysbios.aa8fg ...
    Building file: "../app.cfg"
    Invoking: XDCtools
    "/opt/ti/xdctools_3_50_04_43_core/xs" --xdcpath="/opt/ti/RTOS/bios_6_52_00_12/packages;/opt/ti/RTOS/edma3_lld_2_12_05_30B/packages;/opt/ti/RTOS/ndk_2_26_00_08/packages;/opt/ti/RTOS/pdk_am335x_1_0_9/packages;/opt/ti/ccsv7/ccs_base;" xdc.tools.configuro -o configPkg -t gnu.targets.arm.A8F -p ti.platforms.beaglebone -r release -b "/opt/ti/RTOS/pdk_am335x_1_0_9/packages/ti/build/am335x/config_am335x_a8.bld" -c "/opt/ti/ccsv7/tools/compiler/gcc-arm-none-eabi-6-2017-q1-update" -DBOARD=evmAM335x "../app.cfg"
    gmake[1]: Nothing to be done for 'all'.
    configuring app.xa8fg from package/cfg/app_pa8fg.cfg ...
    generating custom ti.sysbios library makefile ... 
    	Linking with library ti.drv.uart:./lib/am335x/a8/release/ti.drv.uart.aa8fg
    	Linking with library ti.board:./lib/bbbAM335x/a8/release/ti.board.aa8fg
    	Linking with library ti.drv.i2c:./lib/am335x/a8/release/ti.drv.i2c.aa8fg
    	Linking with library ti.drv.spi:./lib/am335x/a8/release/ti.drv.spi.aa8fg
    	Linking with library ti.csl:./lib/am335x/a8/release/ti.csl.aa8fg
    	Linking with library ti.osal:./lib/tirtos/a8/release/ti.osal.aa8fg
    Starting build of library sources ...
    making /home/michael/Desktop/rtosgpib/zzmcspi/src/sysbios/sysbios.aa8fg ...
    gmake[1]: Entering directory `/home/michael/Desktop/rtosgpib/zzmcspi/src/sysbios'
    gmake[1]: Nothing to be done for `all'.
    gmake[1]: Leaving directory `/home/michael/Desktop/rtosgpib/zzmcspi/src/sysbios'
    Build of libraries done.
    cla8fg package/cfg/app_pa8fg.c ...
    Finished building: "../app.cfg"
     
    making ../src/sysbios/sysbios.aa8fg ...
    gmake[2]: Nothing to be done for 'all'.
    Building target: "zzmcspi.out"
    Invoking: GNU Linker
    "/opt/ti/ccsv7/tools/compiler/gcc-arm-none-eabi-6-2017-q1-update/bin/arm-none-eabi-gcc" -mtune=cortex-a8 -marm -Dam3359 -DSOC_AM335x -DbbbAM335x -DMCSPI_MASTER_TASK -g -gdwarf-3 -gstrict-dwarf -Wall -mfloat-abi=hard -Wl,-Map,"zzmcspi.map" -nostartfiles -static -Wl,--gc-sections -L"/opt/ti/RTOS/bios_6_52_00_12/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -L"/opt/ti/RTOS/bios_6_52_00_12/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/hard" -Wl,--defsym,STACKSIZE=0x1C000 -Wl,--defsym,HEAPSIZE=0x400 --specs=nano.specs -o"zzmcspi.out" "./zzspi.o" -Wl,-T"configPkg/linker.cmd" -Wl,--start-group -lrdimon -lgcc -lm -lc -Wl,--end-group 
    makefile:143: recipe for target 'zzmcspi.out' failed
    /opt/ti/RTOS/pdk_am335x_1_0_9/packages/ti/board/lib/bbbAM335x/a8/release/ti.board.aa8fg(bbbAM335x_lld_init.oa8fg): In function `Board_uartStdioInit':
    bbbAM335x_lld_init.c:(.text.Board_uartStdioInit+0x10): undefined reference to `UART_stdioInit'
    collect2: error: ld returned 1 exit status
    gmake[1]: *** [zzmcspi.out] Error 1
    gmake: *** [all] Error 2
    makefile:139: recipe for target 'all' failed
    
    **** Build Finished ****
    
    
    attached the build log, together with app.cfg. Please help to take a look. Also
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    #include "stdint.h"
    
    #include <stdio.h>
    #include <ti/drv/uart/UART.h>
    #include <ti/drv/uart/UART_stdio.h>
    
    #include <ti/csl/example/utils/common/inc/app_utils.h>
    #include <ti/csl/soc.h>
    #include <ti/csl/hw_types.h>
    
    #include <ti/board/board.h>
    
    #include <ti/osal/osal.h>
    
    /* UART Header files */
    #include <ti/drv/uart/UART.h>
    
    /* SPI Header files */
    #include <ti/drv/spi/SPI.h>
    #include <ti/csl/csl_mcspi.h>
    #include <ti/drv/spi/soc/SPI_soc.h>
    
    /* ========================================================================== */
    /*                                 Macros                                     */
    /* ========================================================================== */
    
    #define McSPI_DATA_COUNT            50U // Data Count Transaction
    
    #define MCSPI_INSTANCE              1
    
    /* ========================================================================== */
    /*                            Global Variables                                */
    /* ========================================================================== */
    uint8_t           gRxBuffer[McSPI_DATA_COUNT];
    uint8_t           gTxBuffer[McSPI_DATA_COUNT];
    
    SPI_Handle gSpiHandle;
    
    /* SPI parameters structure Master mode*/
    SPI_Params gSpiParams = {
        SPI_MODE_BLOCKING,      /* transferMode, must within a Task */
        SemaphoreP_NO_WAIT,     // SemaphoreP_WAIT_FOREVER,/* transferTimeout */
        NULL,                   /* CallbackFxn for SPI_MODE_CALLBACK */
        SPI_MASTER,             /* mode */
        5000000,                /* bitRate */
        8,                      /* dataSize */
        SPI_POL0_PHA0,          /* frameFormat */
        NULL                    /* custom */
    };
    
    /* ========================================================================== */
    /*                          Function Declarations                             */
    /* ========================================================================== */
    
    static void McSPIInitializeBuffers(void)
    {
        uint32_t index = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            /* Initialize the gTxBuffer McSPI1 with a known pattern of data */
                gTxBuffer[index] = index;
            /* Initialize the gRxBuffer McSPI1 with 0 */
            gRxBuffer[index] = (uint32_t) 0;
        }
    }
    
    static int32_t McSPIVerifyData(void)
    {
        uint32_t index = 0;
        int32_t retVal = 0;
    
        for (index = 0; index < McSPI_DATA_COUNT; index++)
        {
            if(gRxBuffer[index] !=  gTxBuffer[index])
            {
                retVal = -1;
                break;
            }
        }
    
        return retVal;
    }
    
    
    void spi_initConfig(void)
    {
        SPI_v1_HWAttrs spi_cfg;
    
        /* Get the default SPI initial configurations */
        SPI_socGetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    
        /* Modify the default SPI configurations if necessary */
        spi_cfg.chnCfg[spi_cfg.chNum].dataLineCommMode = MCSPI_DATA_LINE_COMM_MODE_1;
    
        /* Set SPI initial configurations */
        SPI_socSetInitCfg(MCSPI_INSTANCE, &spi_cfg);
    }
    
    
    #define DELAY_VALUE       (0x6FFFFFU)
    
    void AppDelay(unsigned int delayVal)
    {
        while(delayVal)
        {
            delayVal--;
        }
    }
    
    Void spi_test(UArg arg0, UArg arg1)
    {
        int32_t retVal;
        SPI_Transaction transaction;
    
        System_printf("\r\n McSPI Loopback test started\r\n");
    
        /* Modify the default SPI configurations if necessary */
        spi_initConfig();
    
        SPI_init();
    
        /* Open MCSPI instance */
        gSpiHandle = SPI_open(MCSPI_INSTANCE, &gSpiParams);
        if(gSpiHandle == NULL)
        {
            System_printf("\nError opening MCSPI driver\n");
        }
    
        McSPIInitializeBuffers();       // TX data
    
        transaction.count = McSPI_DATA_COUNT;
        transaction.txBuf = gTxBuffer;
        transaction.rxBuf = gRxBuffer;
        SPI_transfer(gSpiHandle, &transaction);
    
        retVal = McSPIVerifyData();
    
        if(retVal != 0)
            System_printf("McSPI Data Transmission is Failed \n\n");
        else
            System_printf("McSPI Data Transmission is successful \n\n");
    
        SPI_close(gSpiHandle);
    }
    
    /* ========================================================================== */
    /*                          Function Definitions                              */
    /* ========================================================================== */
    
    int main(void)
    {
        /* Call board init functions */
        Board_initCfg boardCfg;
    
        boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK |
            BOARD_INIT_UART_STDIO;
    //    /opt/ti/RTOS/pdk_am335x_1_0_9/packages/ti/board/src/bbbAM335x/bbbAM335x.c
        Board_init(boardCfg);
    
    //    Task_Handle task;
    //    Error_Block eb;
    //
    //    Error_init(&eb);
    //
    //    task = Task_create(spi_test, NULL, &eb);
    //    if (task == NULL) {
    //        UART_printf("Task_create() failed!\n");
    //        BIOS_exit(0);
    //    }
    
        /* Start BIOS */
        BIOS_start();
        return (0);
    }
    
    added zzspi source code.

    Mike2772.app.cfg

  • Hi Rahul,

    I solve the puzzle by myself.

    In .cfg file, uart should be defined before loading the board package. Then everything works like a charm.


    /* Load the uart package */
    var socType          = "am335x";
    var Uart              = xdc.loadPackage('ti.drv.uart');
    Uart.Settings.socType = socType;

    /* Load the board package */
    var Board = xdc.loadPackage('ti.board');
    Board.Settings.boardName = "bbbAM335x";

    Thank you for the help


    Mike