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/TDA2E: Start NDK task from application instead of creating using config

Part Number: TDA2E

Tool/software: TI-RTOS

Hello,

My application needs to do some initial set up before NDK can run. Currently NDK is configured through XDC config and NDK task creation is handled through config only. Because of this as soon as system comes up NDK task starts running parallel to my application without waiting for board config done.

I tried using different hook functions(net open hook, ip address hook) but that doesnt serve my purpose. 

Is there any way to start NDK from application?

  • Hi Prasad,

    Unfortunately what you want isn't directly supported.

    Prasad Jondhale said:
    I tried using different hook functions(net open hook, ip address hook) but that doesnt serve my purpose.

    Have you tried pending on a semaphore in one of the early NDK hook functions (i.e Global.stackBeginHook)?  This would allow you to block within the NDK task thread.  You could then post the semaphore once your board config is complete, allowing the stack to carry on at that point.

    -----

    If the above does not work for you, one idea I have is to use the following setting to get what you want:

    Global.stackThreadUser = '&myStackThread';  // i.e. gives you control of the definition of the stack thread function


    You could define the stack thead that's created automatically from the NDK code to either block or just exit the fist time around.  For example:

    boardConfigDone = 0;
    myTaskThread()
    {
        if (boardConfigDone == 1) {
            // board config complete.  Start the stack:
            // <insert content of NDK stack thread here>
        }
        // else just let the task exit ... create it later once board config done
    }

    So you could do something like:

    1. Global.stackThreadUser = '&myStackThread';

    2. define stack thread user as above (or make it block on a semaphore)

    3. NDK will start up and run myTaskThread() as the main stack thread and just exit (or block).

    4. let your board config complete

    5. once complete, set boardConfigDone = 1 (or post the semaphore)

    6. create the task thread yourself with appropriate stack size and fxn myTaskThread(), etc.

    7. Now when the Task thread runs, it will run the NDK stack code b/c the if statement will be true this time.

    Note that if you decide to use the stackThreadUser option, you must create the NDK heartbeat clock yourself.  From the documentation on stackThreadUser:

        /*!
         *  Allows user to define their own implementation of the NDK stack thread
         *
         *  If set, the user is responsible for defining the NDK stack
         *  thread, which has no return value and has two parameters of type UArg.
         *
         *  For example (C code):
         *
         *      Void MYMODULE_stackThreadUser(UArg arg0, UArg arg1);
         *
         *  And in the configuration file:
         *
         *      Global.stackThreadUser = '&MYMODULE_stackThreadUser';
         *
         *  The user is also responsible for creating the SYS/BIOS Clock
         *  instance for the NDK 100ms heartbeat, calling appropriate NC_* APIs,
         *  and adding the appropriate C run time configuration code that matches
         *  the settings of the BIOS config file in the function. (e.g. if
         *  configuring the Ip module, the stack thread must call NC_SystemOpen(),
         *  'ti_ndk_config_ip_init(hCfg)', etc.).
         */
        config ndkHookFxn stackThreadUser = null;

    Steve

  • Hello Steven,

    Thanks for very detailed answer.

    As there is lot of complexities involved using stack user thread I would prefer using ndk stack init hook function as of now to unblock us quickly.

    Just had one doubt about using user thread. In your example above you have mentioned when board init is done call ndk thread from that thread. Does this mean similar to XDC config autogenerated code i have to create ti_ndk_config_Global_stackThread from here? What about different config options like tcp/udp buffer sizes etc?
  • Prasad,

    Prasad Jondhale said:
    As there is lot of complexities involved using stack user thread I would prefer using ndk stack init hook function as of now to unblock us quickly.

    If this method works for you, you should stick to this one.  This is better.

    Prasad Jondhale said:
    Just had one doubt about using user thread. In your example above you have mentioned when board init is done call ndk thread from that thread.

    What I meant was you can "re-create" the stack thread by calling TaskCreate (or Task_create) once the board init is complete.  I didn't mean you should call the NDK thread from the NDK thread itself (or maybe that's not what you mean, I could be misunderstanding you on this part)

    Prasad Jondhale said:
    Does this mean similar to XDC config autogenerated code i have to create ti_ndk_config_Global_stackThread from here?

    Yes, by calling TaskCreate/Task_create with the NDK stack thread function and the flag boardConfigDone == 1, this would allow the NDK to actually start up this second time around.

    Prasad Jondhale said:
    What about different config options like tcp/udp buffer sizes etc?

    You would need to ensure that the functions that run the config code for these settings are called from myStackThread() [e.g. ti_ndk_config_Ip_init(), ti_ndk_config_Tcp_init(), etc.]

    Steve

  • Hello Steven,

    Thanks for reply.

    For config options, NDK task create etc., can I use earlier auto generated code from ConfigPkg?(for my application it is in client_pa15fg.c)

    Basically I will enable auto code generation for NDK and then use created code in my thread to initialize my NDK task.

  • Prasad,

    Yes, this is a great way to "create your own stack thread."

    Like you said, first, use the config to generate the code of the stack thread (normal case).

    Then copy/paste it an use it as the "stack thread user" one.

    Steve