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.

How to enable a TIMER or Watchdog to prevent USB boot lockup?

Expert 1960 points
Other Parts Discussed in Thread: CONTROLSUITE

Hello Folks,

We're using USB boot to load and update our application code into flash. We just called the built-in USB_Boot() function in boot ROM.  But sometimes the MCU got lock up because the host sends a bad image, or something. I tried to start a timer before calling USB_boot() and let it reset MCU after certain time. The timer ISR code works well and tested, but it does not work after calling USB_boot(). It seems that somewhere in boot ROM the interrupts are all disabled so that the timer stops counting.  Apparently we cannot change the code in boot ROM but is there anyway to enable timer so that the USB boot process can be monitored and reset after certain time? I'd greatly appreciate any suggestions and advises. Thanks!

  • Hi Shef,

    Yes, USB_boot() function disables all the PIE interrupts so if you are using TIMER0 interrupt then it'll not work. Could you try using TIMER1 or TIMER2 interrupts instead and see if that helps.

    Regards,

    Vivek Singh 

  • Hi Vivek,
    Thank you for your reply. I just tried all 3 timers (0, 1 & 2). All of them work fine until I add/uncommented the line to call USB_boot(). I used watch window to see the counts incrementing or not. Apparently all PIE interrupts are disabled during the call of USB_Boot(). is there any work-around for this? I really need to have a timer ISR to monitor the progress if usb boot, since we cannot afford to have it locked up. Many thanks!
  • Shef,

    Have you tried enabling watchdog timer to reset the device in such hang condition?

    Regards,

    Vivek Singh
  • Shef,
    I believe this is for F2837X devices? the ROM source code is released in control Suite (C:\ti\controlSUITE\libs\utilities\boot_rom\F2837x_revb\revb_rom_sources\F2837x_bootROM\cpu01-bootROM\source). You should be able to add symbols and choose ROM COFF file after you load your application and step through USB BOOT API and debug this further. Also see if you can use WDOG as Vivek Singh suggests.


    Best Regards
    Santosh Athuru
  • Hi Shef, Did you get the watchdog timer working?

    Vivek Singh
  • Hi Vivek, Santosh,

    Thanks for getting back to me again. It seems that WDT is only for short period of time, in millisecond or so. I don't know how to get watchdog to work for our long timeout (e.g. 30 seconds). Please advise how if I'm wrong.

    On the other hand, I've made progress in debugging and porting some USB boot code to my flash application, so that I could insert timer-enable code inside USB_boot(). I've got it working now, after putting USB_init() code into RAM. This seems to be necessary to get USB working, otherwise it won't. I don't know why and have not seen it mentioned anywhere in document.

    I'd appreciate any further info regarding above questions. Thanks!
  • Hi Shef,

    If you are looking for such a long delay for time-out then you are right. WDT will not provide such long time-out..

    Good to know you were able to implement your own USB Boot loader.

    Regarding your question on USB_init(), are you referring to USB_Boot_Init() function? If yes then this function is needed because this is setting up the system PLL and AUX PLL which is needed for USB. 

    Not sure if that answers your question? If not then we'll have our USB expert look into this.

    Regards,

    Vivek Singh

  • Hi Vivek,

    Yes that's the function I was referring to. I add it into my project and run the code from flash. I did not work until I made this function to run this function from RAM (using #pragma CODE_SECTION for "ramfuncs".). I was wondering why I have to do this. I understand that code calling FlashAPI needs to be in RAM but not sure why USB_Boot_init also have to run from RAM. The code in boot ROM seems to run fine without having this function in ramfuncs although ROM is also in flash memory. I'd appreciate if you have some good explanation. Thanks!
  • Hi Shef,

    Have you made any changes to this function code? If yes then please post the modified code here.

    Also is the InitFlash(); function called before executing this function?

    Regards,

    Vivek Singh

  • Hi Vivek,

    I did not make any change to the code, as I just want to set up USB. It works fine after I put it to run from RAM, otherwise USB won't work (if I removed the #pragma stuff.

    InitFlash() is called at the beginning as part of InitSysCtrl(), way before this function.
  • Shef,

    When this function is running from Flash, can you step through this function till end and see if there is any issue with any of the step? Also once you step through this function check if USB works fine.

    Regards,

    Vivek Singh 

  • Hi Shef, were you able to step through the code?

    Regards,
    Vivek Singh
  • Hi Vivek,

    Thanks for following-up on this issue. Yes I did try to step through the code in CCS and found that it ended up in ILLEGAL_ISR after executing the following lines in USB_Init(), if I ran the function from flash (by commenting out the line of #pragma CODE_SECTION(USB_Init, "ramfuncs"):

    //Clear active interrupts
    USBREG16(USB_O_TXIS);
    USBREG16(USB_O_RXIS);

    If I put the line #pragma CODE_SECTION(USB_Init, "ramfuncs")" back, i.e. running the function from RAM, it would work fine. It's not a big deal to run this from RAM, but it'd be helpful to understand why it has to be running from RAM instead of flash. Thanks!
  • Hi Shef, we are not seeing the same issue. It would be great if you can attach your CCS project here.

    Regards

    Vivek Singh
  • Hi Shef, will you be able to provide the CCS project for this issue ?

    Regards,
    Vivek Singh