arduino / arduino/ArduinoCore-renesas

Upload fails when sketch uses WDT

Open
#553 0 comments 0 reactions 0 assignees View on GitHub
type: imperfection
Dominant language
C
Stars
193
Forks
112
PR merge metrics
No merged PRs in 30d

Description

### Describe the problem

The platform provides a bundled [WDT library](https://github.com/arduino/ArduinoCore-renesas/tree/main/libraries/WDT), which facilitates the use of the watchdog timer.

🐛 Uploads fail when the sketch uses the watchdog timer

### To reproduce

#### Equipment

One of the following boards:

- Nano R4
- Portenta C33
- UNO R4 Minima

#### Steps

1. Upload the following sketch to the board:
```cpp
#include

void setup() {
WDT.begin(1000);
}

void loop() {
WDT.refresh();
}
```
1. Wait for the upload to complete successfully.
1. Upload any sketch to the board.

🐛 The upload fails:

```text
"C:\Users\per\AppData\Local\Arduino15\packages\arduino\tools\dfu-util\0.11.0-arduino5/dfu-util" --device 0x2341:0x0069,:0x0369 -D "C:\Users\per\AppData\Local\arduino\sketches\51228882FA98DB3BB78D6DF0B03D47C3/sketch_aug12b.ino.bin" -a0 -Q
dfu-util 0.11-arduino4

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Opening DFU capable USB device...
Device ID 2341:0069
Run-Time device DFU version 0101
Claiming USB DFU (Run-Time) Interface...
Setting Alternate Interface zero...
Determining device status...
DFU state(0) = appIDLE, status(0) = No error condition is present
Device really in Run-Time Mode, send DFU detach request...
Device will detach and reattach...
Lost device after RESET?
Failed uploading: uploading error: exit status 74
```

#### Clean Up

Recover the board from the state produced by the instructions above by the following procedure:

1. Create a new sketch. (e.g., by selecting **File > New Sketch** from the Arduino IDE menus).
1. Press and release the reset button on the board.
The built-in LED on the board will begin pulsing.
1. Upload the new sketch to the board.

The upload will finish successfully. You will now be able to go back to uploading sketches to the board without needing to first manually reset the board.

### Expected behavior

Upload can be accomplished via the standard procedure.

**-OR-**

The special upload procedure is clearly documented.

### arduino/ArduinoCore-renesas version

1.6.0 / 424e86eff92d37f72123c2b641dd8bbf06a38b47

### Operating system

- Windows

### Operating system version

- Windows 11

### Additional context

The fault does not occur with the UNO R4 WiFi.

---

I notice the board goes into the DFU mode after only a single press of the reset button under these conditions. Under normal conditions, a double reset is required to manually put the board into DFU mode.

---

Originally reported at https://forum.arduino.cc/t/watch-dog-example-r4-nano/1455577

#### Workaround

1. Press and release the reset button on the board.
The built-in LED on the board will begin pulsing.
1. Upload a sketch to the board.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the bundled libraries/WDT sketch on a Nano R4, Portenta C33, or UNO R4 Minima, then compare the dfu-util upload output with the UNO R4 WiFi behavior. Start with the WDT library and the reported DFU command; done means a standard upload succeeds after the watchdog sketch, or the required reset procedure is clearly documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.