Watchdog support for i.MX8QXP MEK under U-Boot

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Watchdog support for i.MX8QXP MEK under U-Boot

4,374 Views
abelal
Contributor II

Hi,

While building U-Boot for the i.MX8QXP MEK platform I enabled the CONFIG_IMX_WATCHDOG for getting watchdog support under U-Boot but the build fails with

 

../drivers/watchdog/imx_watchdog.c: In function 'reset_cpu':
../drivers/watchdog/imx_watchdog.c:45:55: error: 'WDOG1_BASE_ADDR' undeclared (first use in this function); did you mean 'GPT1_BASE_ADDR'?
   45 |  struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
      |                                                       ^~~~~~~~~~~~~~~
      |                                                       GPT1_BASE_ADDR
../drivers/watchdog/imx_watchdog.c:45:55: note: each undeclared identifier is reported only once for each function it appears in
../drivers/watchdog/imx_watchdog.c: In function 'hw_watchdog_reset':
   rm -f drivers/usb/musb-new/built-in.o; aarch64-mel-linux-ar rcs drivers/usb/musb-new/built-in.o
../drivers/watchdog/imx_watchdog.c:89:55: error: 'WDOG1_BASE_ADDR' undeclared (first use in this function); did you mean 'GPT1_BASE_ADDR'?
   89 |  struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
      |                                                       ^~~~~~~~~~~~~~~
      |                                                       GPT1_BASE_ADDR
   rm -f drivers/video/imx/hdmi/built-in.o; aarch64-mel-linux-ar rcs drivers/video/imx/hdmi/built-in.o
../drivers/watchdog/imx_watchdog.c: In function 'hw_watchdog_init':
../drivers/watchdog/imx_watchdog.c:96:55: error: 'WDOG1_BASE_ADDR' undeclared (first use in this function); did you mean 'GPT1_BASE_ADDR'?
   96 |  struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
      |                                                       ^~~~~~~~~~~~~~~
      |                                                       GPT1_BASE_ADDR
../scripts/Makefile.build:278: recipe for target 'drivers/watchdog/imx_watchdog.o' failed
make[3]: *** [drivers/watchdog/imx_watchdog.o] Error 1
../scripts/Makefile.build:432: recipe for target 'drivers/watchdog' failed
make[2]: *** [drivers/watchdog] Error 2

 

If I look through the code, the WDOG1_BASE_ADDR is not defined in arch/arm/include/asm/arch-imx8/imx-regs.h. Any guidance will be appreciated.

0 Kudos
14 Replies

4,049 Views
Gandalf-kern
Contributor IV

From the SCFW for IMX8X

#define WDOG_CS_EN_MASK (0x80U)
#define WDOG_CS_EN_SHIFT (7U)
#define WDOG_CS_EN(x) (((uint32_t)(((uint32_t)(x)) << WDOG_CS_EN_SHIFT)) & WDOG_CS_EN_MASK)

static inline uint32_t WDOG32_GetStatusFlags(WDOG_Type *base)
{
return (base->CS & (WDOG_CS_EN_MASK | WDOG_CS_FLG_MASK));
}

Also see the hardware reference manual sections on watchdog timer for examples of how to enable the watchdog.  I still don't know if the config files will enable the WDT in uboot. Looking at this and also need to find the base address used.

0 Kudos

4,083 Views
Gandalf-kern
Contributor IV

For uboot the following config options are available per the Kconfig.

config WATCHDOG
bool "Enable U-Boot watchdog reset"
depends on !HW_WATCHDOG
help
This option enables U-Boot watchdog support where U-Boot is using
watchdog_reset function to service watchdog device in U-Boot. Enable
this option if you want to service enabled watchdog by U-Boot. Disable
this option if you want U-Boot to start watchdog but never service it.

config WATCHDOG_TIMEOUT_MSECS
int "Watchdog timeout in msec"
default 128000 if ARCH_MX25 || ARCH_MX31 || ARCH_MX5 || ARCH_MX6
default 128000 if ARCH_MX7 || ARCH_VF610
default 30000 if ARCH_SOCFPGA
default 60000
help
Watchdog timeout in msec

config HW_WATCHDOG
bool

config WATCHDOG_RESET_DISABLE
bool "Disable reset watchdog"
help
Disable reset watchdog, which can let WATCHDOG_RESET invalid, so
that the watchdog will not be fed in u-boot.

config IMX_WATCHDOG
bool "Enable Watchdog Timer support for IMX and LSCH2 of NXP"
select HW_WATCHDOG if !WDT
help
Select this to enable the IMX and LSCH2 of Layerscape watchdog
driver.

It's unclear what the HW_WATCHDOG configures if anything for the IMX8X. The HW Watchdog is in the SCFW and enabled by the SCFW, or some external watchdog?

I'm testing with the following in u-boot. The boot retry is to force a command line WDT trigger, otherwise will disable all interrupts to test the WDT in u-boot. 

# CONFIG_SYSRESET_WATCHDOG is not set
CONFIG_WATCHDOG=y
# CONFIG_HW_WATCHDOG is not set
CONFIG_IMX_WATCHDOG=y
CONFIG_WDT=y
CONFIG_BOOT_RETRY_TIME=120
CONFIG_RESET_TO_RETRY=y

0 Kudos

4,083 Views
Gandalf-kern
Contributor IV

For i.MX8X the kernel watchdog is configured and enabled by default and was able to test forcing a reboot. Working on the uboot and found u-boot config options are available, but u-boot configs are not configured by default as they are for the kernel.  Enabled u-boot WDT configs but in the process of testing. If the SCFW configures the kernel WDT for the iMX8X and it is working, then it should also work for u-boot if the code is common. But need to check this.  NXP has not documented the WDT for the IMX8 family and not much from NXP on the forums. Trial and error approach until NXP documents.  Can also check the WDT addresses needed for IMX8X and possibly do a mw to enable the WDT and see if it enables the WDT, but again NXP doesn't document which addresses are needed in the hardware reference manual. Have to work through the NXP IMX wdt uboot driver for the addresses.

0 Kudos

4,350 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

May I ask which uboot version you're using?

Best regards,
Aldo

0 Kudos

4,318 Views
abelal
Contributor II

Any updates here?

0 Kudos

4,339 Views
abelal
Contributor II

Hi Aldo,

It's 2020.04 from the SDK version 2.2.

0 Kudos

4,306 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

unfortunately it seems that CONFIG_IMX_WATCHDOG is not available for i.MX8, even so one can use the SCFW watchdog you may refer to the SCFW porting kit  for this.

Best regards,
Aldo.

0 Kudos

4,279 Views
abelal
Contributor II

Hi Aldo,

Thanks a lot for the reply.

  1. When you say not available for i.MX8 which platforms do you mean exactly? i.MX8 QuadMax, QuadXPlus etc?
  2. Can you please point me to the scfw porting guide? Is the support for this watchdog available under Linux as well as U-Boot?

BR,

Awais

0 Kudos

4,272 Views
AldoG
NXP TechSupport
NXP TechSupport

Hi,

1.- Yes, that is correct, i.MX 8 and i.MX 8X, the software watchdog used in system controller firmware (SCFW)

2.- Yes, please find it here:
Embedded Linux for i.MX Applications Processors

SCFW porting kit includes documentation and the files needed for the SCFW enablement.

If you're using the Linux kernel's watchdog driver "imx8_wdt.c", the SCFW will enable the watchdog for Linux partition, when Linux calls imx8_wdt_ping(), the timer in SCFW for linux partition will be refreshed. And if this watchdog is timeout, the SCFW will reset the Linux partition only.

While if in board.c enable the watchdog in SCFW so when it is timeout, the whole system will reset.

You may also find useful the following community document:
System Controller Firmware 101

Best regards,
Aldo.

0 Kudos

3,825 Views
marcocavallini
Contributor V

Hello,

do you have any update about this topic?

How you can manage watchdog with i.MX 8QuadPlus (i.MX 8QP) ?

U-boot version 2020.04

Thanks

0 Kudos

4,074 Views
Gandalf-kern
Contributor IV

NXP support, what is specifically  needed to enable the watchdog for uboot? You discuss the kernel but not uboot.

0 Kudos

4,225 Views
kergoth
Contributor I

Has anyone at NXP implemented the SCU watchdog support in u-boot and linux at this time, or should we implement it ourselves?

0 Kudos

4,100 Views
Gandalf-kern
Contributor IV

> SCU watchdog support in u-boot and linux

For the Linux kernel there are SCU watchdog configuration options.

CONFIG_IMX2_WDT=y
CONFIG_IMX_SC_WDT=y

CONFIG_HAVE_ARM_SMCCC=y

CONFIG_IMX_SCU=y

CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_CORE=y
# CONFIG_WATCHDOG_NOWAYOUT is not set
CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED=y
CONFIG_WATCHDOG_OPEN_TIMEOUT=0

Did you implement or find a solution for a u-boot Watchdog? 

I have the same question for u-boot. See https://community.nxp.com/t5/Processor-Expert-Software/How-to-configure-the-uboot-watchdog-for-NXP-i...

 

0 Kudos

4,362 Views
abelal
Contributor II

Any hints?