public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained
@ 2021-12-09 16:32 Michael Opdenacker
  2021-12-09 16:43 ` Quentin Schulz
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Opdenacker @ 2021-12-09 16:32 UTC (permalink / raw)
  To: u-boot@lists.denx.de

Greetings,

Documenting the issue and a workaround here in case other people
encounter it, but if you have tips for fixing the issue in U-Boot, I'm
interested of course!

I noticed that the SAMA5D3 Xplained board didn't have the watchdog timer
enabled in the Linux DTS.
I submitted a patch to fix this: https://lkml.org/lkml/2021/12/9/740

However, applying this patch isn't sufficient to make the watchdog
available on Linux:
at91_wdt fffffe40.watchdog: watchdog is disabled
at91_wdt: probe of fffffe40.watchdog failed with error -22

As explained on
https://elixir.bootlin.com/linux/latest/source/drivers/watchdog/at91sam9_wdt.c#L10,
this happens because the bootloader or bootstrap code already disables
the watchdog. The trouble is, unlike on SAMA5D2 and SAMAD4 (if I
understood correctly),"The Watchdog Timer Mode Register can be only
written to once".

However, I haven't managed to disable this behavior in U-Boot (including
the SPL). I have no watchdog related option turned on anywhere, and by
adding puts() messages in the code, I believe that the wdt_stop()
function doesn't get called either. Maybe the corresponding watchdog
register is written to by the code initializing the SoC, but I couldn't
find where.

A workaround is to use at91bootstrap instead of U-Boot SPL, which has a
configuration parameter to disable to watchdog:
git clone https://github.com/linux4sam/at91bootstrap.git
export CROSS_COMPILE=arm-linux- (whatever your cross-compiler is)
make sama5d3_xplainedsd_uboot_defconfig
make menuconfig (Disable CONFIG_DISABLE_WATCHDOG)
make
Copy boot.bin (under build/...) and u-boot.bin (from U-Boot sources) to
the SD card.

At least, this proves that the culprit is U-Boot SPL!

So, any advice for making it possible prevent the SPL from disabling the
watchdog on SAMA5D3 (Xplained at least)?

Cheers
Michael.

-- 
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained
  2021-12-09 16:32 ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained Michael Opdenacker
@ 2021-12-09 16:43 ` Quentin Schulz
  2021-12-10  8:32   ` Michael Opdenacker
  0 siblings, 1 reply; 3+ messages in thread
From: Quentin Schulz @ 2021-12-09 16:43 UTC (permalink / raw)
  To: Michael Opdenacker; +Cc: u-boot@lists.denx.de

Hi Michael,

On Thu, Dec 09, 2021 at 05:32:51PM +0100, Michael Opdenacker wrote:
> Greetings,
> 
> Documenting the issue and a workaround here in case other people
> encounter it, but if you have tips for fixing the issue in U-Boot, I'm
> interested of course!
> 
> I noticed that the SAMA5D3 Xplained board didn't have the watchdog timer
> enabled in the Linux DTS.
> I submitted a patch to fix this: https://urldefense.proofpoint.com/v2/url?u=https-3A__lkml.org_lkml_2021_12_9_740&d=DwICaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=ww7r5Dth1BLSjxhXLNnKoVNj8AucfGYrLPGtUzXCBMy77x7a-3DLDOwjZKD8McYR&s=X6oYLC_VTp7nG3HQ_bQVw4itYlKXIggXztE74rQ8LC4&e= 
> 
> However, applying this patch isn't sufficient to make the watchdog
> available on Linux:
> at91_wdt fffffe40.watchdog: watchdog is disabled
> at91_wdt: probe of fffffe40.watchdog failed with error -22
> 
> As explained on
> https://urldefense.proofpoint.com/v2/url?u=https-3A__elixir.bootlin.com_linux_latest_source_drivers_watchdog_at91sam9-5Fwdt.c-23L10&d=DwICaQ&c=_sEr5x9kUWhuk4_nFwjJtA&r=LYjLexDn7rXIzVmkNPvw5ymA1XTSqHGq8yBP6m6qZZ4njZguQhZhkI_-172IIy1t&m=ww7r5Dth1BLSjxhXLNnKoVNj8AucfGYrLPGtUzXCBMy77x7a-3DLDOwjZKD8McYR&s=Uj9vfn_1ctVt4xWcswqYgujwVVDW2-YXnfgRJN33tHc&e= ,
> this happens because the bootloader or bootstrap code already disables
> the watchdog. The trouble is, unlike on SAMA5D2 and SAMAD4 (if I
> understood correctly),"The Watchdog Timer Mode Register can be only
> written to once".
> 
> However, I haven't managed to disable this behavior in U-Boot (including
> the SPL). I have no watchdog related option turned on anywhere, and by
> adding puts() messages in the code, I believe that the wdt_stop()
> function doesn't get called either. Maybe the corresponding watchdog
> register is written to by the code initializing the SoC, but I couldn't
> find where.
> 

From a quick look at the code, you need to enable CONFIG_WDT_AT91 and
the watchdog won't be disabled anymore by the SPL.

See:
https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-at91/spl_atmel.c#L121
and
https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-at91/spl.c#L16

Cheers,
Quentin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained
  2021-12-09 16:43 ` Quentin Schulz
@ 2021-12-10  8:32   ` Michael Opdenacker
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Opdenacker @ 2021-12-10  8:32 UTC (permalink / raw)
  To: Quentin Schulz; +Cc: u-boot@lists.denx.de

Hi Quentin,

On 12/9/21 5:43 PM, Quentin Schulz wrote:
> From a quick look at the code, you need to enable CONFIG_WDT_AT91 and
> the watchdog won't be disabled anymore by the SPL.
>
> See:
> https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-at91/spl_atmel.c#L121
> and
> https://elixir.bootlin.com/u-boot/latest/source/arch/arm/mach-at91/spl.c#L16


Good catch, thanks!
Indeed setting CONFIG_WDT_AT91=y did the trick.

I didn't consider enabling the watchdog driver to avoid disabling the
watchdog timer!
Thanks again,
Michael.

-- 
Michael Opdenacker, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-10  8:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-09 16:32 ARM: mach-at91: how to stop U-Boot/SPL from disabling the watchdog timer on SAMAD3 Xplained Michael Opdenacker
2021-12-09 16:43 ` Quentin Schulz
2021-12-10  8:32   ` Michael Opdenacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox