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.

AM5716: Link error when using "select" function in SBL

Part Number: AM5716

Hello.

I am writing an SBL program for AM5716.
I want to implement the following functions.

-When SBL starts, wait for UART input for 5 seconds.
-When there is any input, the function [A] is executed.
-If a timeout occurs, the function [B] is executed.

Use the UART_scanFmt function to wait for UART input.
Definition -> C:\ti\pdk_am57xx_1_0_15\packages\ti\drv\uart\UART_stdio.h

Use the select function for timeout processing.

However, when I use the select function, I get the following error:
-----
C:/ti/pdk_am57xx_1_0_15/packages/ti/boot/sbl/board/idkAM571x/sbl_main.c:135: undefined reference to `select'
-----

#include <sys/select.h>
Is the above not enough?
Do I need to link any libraries?
How does it link?

Thank you.

  • Hi,

    #include <sys/select.h>
    Is the above not enough?

    You should probably see this - "sys/select.h" is UNIX header. You need to find the Windows equivalent and you can include it without any problems.

    However, for your use case, you can use combination of BoardDiag_AppDelay() and BoardDiag_getUserInput(BOARD_UART_INSTANCE). You can see board/diag/led/ test for reference.

  • Thank you for your reply.

    > You should probably see this - "sys/select.h" is UNIX header.
    > You need to find the Windows equivalent and you can include it without any problems.

    AM5716 is non-OS.
    But do you want to include the Windows header files?

    #include <sys/select.h>
    The result was the same even if the following header file was included instead of the above.
    #include "C:/ti/gcc-arm-none-eabi-6-2017-q1-update/arm-none-eabi/include/sys/select.h"

    > However, for your use case, you can use combination of BoardDiag_AppDelay()
    > and BoardDiag_getUserInput(BOARD_UART_INSTANCE). You can see board/diag/led/ test for reference.

    Thanks for the useful information.
    I searched the header file where BoardDiag_getUserInput is defined.
    The following was found.
    -------------------
    ・board\diag\common\AM65XX\diag_common_cfg.c(388,8) [SJIS]: int8_t BoardDiag_getUserInput(uint8_t instance)
    ・board\diag\common\AM65XX\diag_common_cfg.h(65,8) [SJIS]: int8_t BoardDiag_getUserInput(uint8_t instance);
    ・board\diag\common\j721e\diag_common_cfg.c(206,8) [SJIS]: int8_t BoardDiag_getUserInput(uint8_t instance)
    ・board\diag\common\j721e\diag_common_cfg.h(65,8) [SJIS]: int8_t BoardDiag_getUserInput(uint8_t instance);
    -------------------
    Regarding the development of SBL for AM5716, can I use "BoardDiag_getUserInput" of "AM65XX" and "j721e"?
    Unfortunately, "BoardDiag_getUserInput" was not defined in "board \ diag \ common \ AM571X \ diag_common_cfg.h".

    Thank you.

  • Hi,

    Unfortunately, "BoardDiag_getUserInput" was not defined in "board \ diag \ common \ AM571X \ diag_common_cfg.h".

    Yeah, High level API is not there for AM57x like for other platform. Apologies.

    What you can do for now is instead of waiting for 5 sec, develop a use case like below and make progress with your application:

    >if key1 is pressed call function1

    >if key2 is pressed call function2

    meanwhile, I will check with development team whether similar API exists.

  • Thank you for your polite reply

    > What you can do for now is instead of waiting for 5 sec, develop a use case like below and make progress with your application

    Here are the details of what I want to do:
    ---------------------
    If the key is not pressed, start the app.
    When the key is pressed, the "app update function" is called.
    ---------------------

    This means that:
    When the reboot process is performed by the app, SBL will automatically restart the app.
    (Automatically restarts even if the user does not enter a key)

    Therefore, it is necessary to create a path that can be executed without the user doing anything.
    -> Timeout processing by timer is required.


    > meanwhile, I will check with development team whether similar API exists.

    I have high expectations.
    Thank you.

  • Hi,

    You can see UART drv test example for reference. It is demonstrating all the possible uart usecases that are validated by SDK.

    I found one test similar to your use case(with/without DMA):

    you can build and run either "UART_BasicExample_idkAM571x_armTestproject" or "UART_BasicExample_idkAM571x_DMA_armTestproject" and can modify it to include in SBL.

    note:- this tests are validating so many use cases, therefore while running follow the prints on console.

  • Hi.
    Thank you for the useful information.

    C:\ti\pdk_am57xx_1_0_15\packages\ti\drv\uart\test\src\main_uart_test.c
    I made a function by referring to "UART_test_timeout" in this file.
    However, "UART_read2" will exit immediately.
    The return value is "-1".
    Am I missing something?

    Also, please tell us about questions 1 to 4 in the code.

    Q1: do you need it
    Q2: Is it unnecessary to specify "readCallback"?
    Q3: Is it unnecessary to specify "readMode"?
    Q4: Is the unit millisecond?

    /**
     * @brief       Wait for user input (with timeout).
     * @return      1:With user input. 0:Time out. -1:Error
     */
    int UART_scanf_WithTimeout()
    {
        UART_Handle         uart = NULL;
        UART_Params         uartParams;
        char                scanPrompt[16] = {0};
        UART_Transaction    transaction;
        int32_t             readRet;
    
        /* UART SoC init configuration */
    //  UART_initConfig(false);     /* Q1: do you need it */
    
        /* Initialize the default configuration params. */
        UART_Params_init(&uartParams);
        uartParams.parityType   = 0;
    //  uartParams.readCallback = UART_callback;        /* Q2: Is it unnecessary to specify "readCallback"? */
    //  uartParams.readMode     = UART_MODE_CALLBACK;   /* Q3: Is it unnecessary to specify "readMode"? */
    
        /* UART Open */
        uart = UART_open(0, &uartParams);
        if (uart == NULL)
        {
            UART_printf("\nProcessing result = UART Open Error.\n");
            return -1;
        }
    
        /* UART Read with Timeout */
        UART_transactionInit(&transaction);
        transaction.buf     = (void *)(uintptr_t)&scanPrompt[0];
        transaction.count   = 16U/*UART_TEST_READ_LEN*/;
        transaction.timeout = 5000U/*UART_TEST_TIMEOUT*/;   /* Q4: Is the unit millisecond? */
    
        /* Waiting for user input */
        readRet = UART_read2(uart, &transaction);
    
        /* UART Close */
        UART_close(uart);
    
        /* Processing result */
        if(readRet == UART_SUCCESS)
        {
            if(transaction.status == UART_TRANSFER_STATUS_SUCCESS)
            {
                UART_printf("\nProcessing result = With user input.\n");
                return 1;
            }
            else if(transaction.status == UART_TRANSFER_STATUS_TIMEOUT)
            {
                UART_printf("\nProcessing result = Time out.\n");
                return 0;
            }
        }
    
        UART_printf("\nProcessing result = Error.\n");
        return -1;
    }
    


    Thank you.

  • Hi,

    The above code is having low level APIs for UART driver, thus you have to follow the same sequence as given. However, i am working with development team on high level APIs, therefore the delay in response.  

  • Hi.
    Thank you for your reply.

    > i am working with development team on high level APIs, therefore the delay in response.

    understood.
    I will wait for your reply.
    Thank you.

  • Hi.
    It's been two weeks, how is it?
    When is the next answer?

    I will wait for your reply.
    Thank you.

  • Fukumoto-san,

    Can you please confirm that this issue is still open and that there was no follow up done offline?

    Regards

    Karthik

  • Hello.


    No answer was received from TI on this issue.
    Maybe it was because my question was bad.
    (I'm not good at English)

    I gave up solving this problem.

    thank you.