OpenNuvoton / NUC970_U-Boot_v2016.11

U-Boot v2016.11 for NUC970, N9H30, and NUC980
28 stars 45 forks source link

HW Watchdog timeout not handled #12

Closed lightelf76 closed 5 years ago

lightelf76 commented 5 years ago

It seems like u-boot does not handle WDT, if it enabled by power-on strap. Tested with Tomato (rev.B chip) and nuc970_tomato_defconfig. What can be wrong?

yachen commented 5 years ago

Hi,

U-Boot can support WDT. You need to define:

define CONFIG_HW_WATCHDOG

U-Boot will call a macro to reset WDT every now and then.

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago

What I did so far: 1) Placed a line into /include/configs/nuc970_tomato.h

define CONFIG_HW_WATCHDOG 1

2) Placed a line into /configs/nuc970_tomato_defconfig CONFIG_HW_WATCHDOG=y As I can see from compiled binary and map-file - functions hw_watchdog_init/hw_watchdog_reset are compiled and present. But WDT reset still occured when I am in u-boot console.

lightelf76 commented 5 years ago

Fixed at my end. See pull request for details

yachen commented 5 years ago

Hi,

Please add following setting to enable WDT. Thanks. setenv watchdog on

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago

Hi, nuc970_serial_getc wait a new symbol in busy loop and does not service WDT. Patch #13 fixes that issue.

yachen commented 5 years ago

Hi,

Isn’t tstc() called to check data availability before getc()?

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago

Hi, from other drivers (ns16550, lpuart) I see exactly same solution: busy wait with watchdog servicing. So not, tstc() not called

yachen commented 5 years ago

Hi,

This can be verified easily by sending some characters out to UART in NUC970’s tstc() function. I’m pretty sure it’s called repeatedly. U-Boot shell doesn’t block in NUC970’s getc().

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago
  1. If I send characters into UBoot console - WDT does not reset CPU
  2. Proposed change fixes situation.
yachen commented 5 years ago

Hi,

  1. If I send characters into UBoot console - WDT does not reset CPU

Isn't it normal WDT not to reset CPU while everything's working fine?

  1. Proposed change fixes situation.

I'm not seeing the an issue here. Or somehow I miss your point...

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago

The point is: If UART receives symbol, getc() returns and WDT reset did not occur (WDT serviced somewhere in other place). But when UBoot stays in console and no symbols entered, gets() cycles in busy loop and after ~14 seconds WDT resets board. So, getc() must service WDT internally or return error code EAGAIN.

yachen commented 5 years ago

Hi,

Yes, I’m seeing different implementations in serial driver getc(). Simply loop until there’s input (S3C24x0), add WDT reset(NS16550), or return -EAGAIN(STM32). I didn’t merge your pull request so far because me or my colleagues are unable to reproduce this issue (System reset by WDT if no console input).

Are you using NUC970’s default configuration? What hardware are you using, Nuvoton’s DEV board? Can you provide your u-boot.bin for us to verify this issue? Thanks.

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

lightelf76 commented 5 years ago
  1. Board is NK-Tomato (chip NUC976 rev B).
  2. U-Boot built from OpenNuvoton git repository (no any changes)
  3. nuc970_tomato_defconfig changed by one additional line: CONFIG_HW_WATCHDOG=y
  4. Environment variable "watchdog=on" set and saved
  5. No uSD-card installed
  6. SW2.2 set to WDT_OFF - works OK.
  7. SW2.2 set to WDT_ON state After ~14s of no activity at console - board reboots itself.
yachen commented 5 years ago

Hi,

We’re able to reproduce this issue with Tomato board’s config. Somehow the U-Boot behavior is different between two configurations. So WDT reset is working fine in DEV board’s config but not in Tomato board’s config.

I’ve merged your pull request. Thanks a lot for test and submit the patch.

Sincerely,

Yi-An Chen

=========================================================================================== The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.