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.

SITARA AM437x IDK & TI RTOS : Software reset

Expert 1700 points

Hi Team,

For the purpose of product testing I would like to add to my motor control firmware support for software reset.

I used the following implementation :

extern void _c_int00();

void SWResetCommand(int s16_axis,int s16_sub_index)
{
System_atexit(SwReset);
Hwi_disable();
BIOS_exit(0);

}


void SwReset(int val)
{
val++; // defeat compiler warning
_c_int00();

}

 


I am using the sitara am437x idk and ehtercat slave example (full) for testing this feature

when the function SWResetCommand is called I can see in terminal that the SW restarts  ( see below terminal log), but SW hangs when the code reaches to the point where the tasks are started.

Do I need to stop all tasks before calling BIOS_exit ? what about interrupts ? or maybe its a different issue ?

Terminal Log :

StarterWare Boot Loader

BOARDInit status [0x0]

SoC : [AM43XX]

Core : [A9]

Board Detected : [IDKEVM]

Base Board Revision : [UNKNOWN]

Daughter Card Revision: [UNKNOWN]

Copying application image from MMC/SD card to RAM

Jumping to StarterWare Application...


Version - EtherCAT Slave 01.00.08.01

Board name : AM43_IDK

Board Revision : 1.4A


EtherCAT Device


SYS/BIOS EtherCAT Internal application 3.3.0

Build Timestamp : Oct 4 2020 10:10:51

Starting Drive...  <<<=== at this tasks setup is done

<<<<<===== SW reset is called here below we can see that sw indeed restarts ===== >>>>>>


Version - EtherCAT Slave 01.00.08.01

Board name : AM43_IDK

Board Revision : 1.4A


EtherCAT Device


SYS/BIOS EtherCAT Internal application 3.3.0

Build Timestamp : Oct 4 2020 10:10:51

<<<<<===== SW hangs ===== >>>>>>

  • Hello,

    Does the issue happen only after running from flash with secondary boot loader? Is it working properly if using CCS?

    If you connect a JTAG emulator, do you see where the SW hangs at? Re-program pinmux may cause glitch, and you may have to do a hardware reset to restart the application.

    Regards,

    Garrett

  • Thanks Garrett,

    How do I bypass the pinmux re-program after the sw reset ?

  • I am not certain if the application would run properly even after pinmux reprogram is bypassed. It would be good to find out where the application is stuck. and as this is only for the purpose of product testing, using a web based power switch with programmable power cycle time to do hard reset would probably be easier.

    Regards,

    Garrett

  • What is the recommended way to do a SW reset than ? OR you want to say that it is not supported ?

  • Inno,

    My recommendation is to make your software reset really more of a "software-initiated hardware reset".  This is much more predictable and repeatable as it will force the entire chip to a known good state.  In fact, if your board is designed such that the nRESETIN_OUT signal is used to reset other devices (PHYs, flash, etc.) then this software-initiated hardware reset can put your entire SYSTEM into a known good state.

    This can be done by writing to the PRCM_PRM_RSTCTRL register at address 0x44DF4000. You have a choice between warm reset (bit 0) and cold reset (bit 1).  I suggest using cold reset to get a total reset of everything. It is as simple as this:

    #define PRCM_PRM_RSTCTRL (*(volatile unsigned int*)0x44df4000)
    PRCM_PRM_RSTCTRL = 2; // cold reset

    Best regards,
    Brad

  • thanks for your answer.

    is the above code should work on the idkam437x board ?

  • That code is device specific (AM437x) and not board specific, so yes, I expect it to work on the AM437x IDK or any other board using AM437x.  I should probably state one underlying assumption which was that the MMU be configured for a 1-to-1 mapping, i.e. virtual address = physical address.  If the MMU is not configured accordingly then the write will not function.

  • tried on idmam437x.

    sw does not seems that it is restarted (ethercat demo ful)

  • I don't have that example handy.  Have you checked to see if the MMU mapping is present to map that register?  Often times the MMU mappings are part of the cfg file, but I'm not certain on that specific example.  If you hit that bit in the register it will reset the chip, so the only possible thing that could be getting in the way is the MMU.  There are no other dependencies.

    Garrett Ding might know more specifically.

  • MMU is configured in the am437x_app.cfg as Brad indicated:

    /* MMU configuration for PRCM - Non Cacheable | Bufferable : Device */
    var peripheralBaseAddr = 0x44D00000;
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr, peripheralBaseAddr, peripheralAttrs);

    "The MMU translation table is 16KB and manages only the first level descriptor table. Each entry in the table defines the properties of memory areas of size 1MB"

    Did you try to use global warm reset? PRCM_PRM_RSTCTRL = 1;

    Regards,

    Garrett

  • Hi

    I appreciate your help

    I tried both options

    but so far this method did not work on the idk - unlike the jump to cint_00 , here it does not seems that sw starts

  • I verified "PRCM_PRM_RSTCTRL = 2;" in the while loop of task1 with CCS, which did reset the device as expected - break the JTAG connection.  

    Does your function look like below?

    void SWResetCommand(int s16_axis,int s16_sub_index)

    {

    PRCM_PRM_RSTCTRL = 2; // cold reset

    }

    You may have to connect a JTAG emulator to find out where the PC register points to.

    Regards,

    Garrett 

  • thanks

    jtag connection is indeed broken , but if I remove the JTAG and just execute the command , the sw does not 'restarts' ....

  • Please do the following:

    • Run your project in CCS
    • Set a breakpoint in that function
    • Open a memory window to the same address
    • Step over that line of code that writes 2 to the register
    • Take a screenshot of the entire CCS window and attach it.