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.

Procedure to shutdown/restart NDK

Hi,

Our application has a scenario in which the whole application has to restart and continue responding to certain messages. To do this, we have registered a function System_atexit(app_exit_handler), and before BIOS_exit is called NC_SystemClose is called. This works fine on certain cases. 

But this fails if we are pinging the device simultaneously during the restart. This happens because as soon as Interrupt_init is called in EmacStart, RX gets triggered resulting in an incomplete EmacStart. On further debugging I noticed that for NC_SystemClose/NC_NetStop EmacStop is NOT being called, and as a result the cpdma is not closed(or the CPSW subsystem is still alive). On commenting restoreInterrupts(cookie) in Interrupt_init, the process works fine. 

Is there a correct procedure to shutdown/restart NDK so that EmacStop gets called by NDK? From http://www.ti.com/lit/ug/spru524h/spru524h.pdf I found that EmacStop is triggered by NIMUUnregister, but I'm afraid a call to that API can't be made from the application? Or if I can, I'm not sure on how to provide NETIF_DEVICE to the API.

Thanks,
Vinesh 

  • Vinesh,

    What TI device are you using?  And what version of the NDK and EMAC driver?

    Dave

  • Dave,

    The NDK version is 2.21.01.38. We ported the driver to to AM335x, and the testing is done on IDK( https://estore.ti.com/TMDXIDK3359-AM3359-Industrial-Development-Kit-IDK-P2728.aspx )

    Vinesh

  • Hi Vinesh,

    We have an example of how to reboot properly in the NDK.

    The NDK telnet console has a reboot command.  Please have a look at the source of the reboot command under ti/ndk/tools/console and follow the code there.

     Steve

  • Hi Steve,

    I tried using NC_NetStop(1) and NC_NetStop(0) as indicated by the lines

        else if( !stricmp( tok[0], "reboot" ) )
               NC_NetStop(1);
        else if( !stricmp( tok[0], "shutdown" ) )
              NC_NetStop(0);

    in console.c . But still couldn't get any callback to EmacStop. By the way, this is my application restart code - 

    void restart_application()
    {

       NC_NetStop(1);

       BIOS_exit(100);
    }

    Might it be that the BIOS gets exit before a chance to execute EmacStop?

    Vinesh

  • Vinesh,

    Vinesh Balan said:

    I tried using NC_NetStop(1) and NC_NetStop(0) as indicated by the lines

        else if( !stricmp( tok[0], "reboot" ) )
               NC_NetStop(1);
        else if( !stricmp( tok[0], "shutdown" ) )
              NC_NetStop(0);

    in console.c . But still couldn't get any callback to EmacStop.

    Is the stack rebooting in this case?

    Vinesh Balan said:
    Might it be that the BIOS gets exit before a chance to execute EmacStop?

    Yes.  NC_NetStop() simply sets a global flag to true.  This flag is checked in the network scheduler - which runs in task - in a while loop.  The flag won't be checked until the net scheduler task runs again.  Since you are calling BIOS_exit, this never happens - the net scheduler will never run again.

    Steve

  • Steve, 

    Yes, that was the reason EmacStop wasn't being called. However, even after proper shutdown of NDK, I see the issue persists with the application. On a bit of debugging, I noticed that in Interrupt_init, as soon as Interrupt_add is called, the interrupt gets "Enabled" and "Pending". Also, irrespective of the value I give for hwi_intSetup.bEnable, hwi_params.enableInt is set to 1 in intmgmt.c(of NDK).

    Vinesh