Skip to content

Conversation

@ArcaneNibble
Copy link
Collaborator

@ArcaneNibble ArcaneNibble commented Jul 16, 2025

Implements both resetting as well as booting into firmware update mode.

Note that the ev3dev documentation is incorrect. The correct magic flag address is 0xFFFF1FFC and not 0xFFFF1FFA. This issue has been corrected in the ev3dev documentation.

@coveralls
Copy link

coveralls commented Jul 16, 2025

Coverage Status

coverage: 57.254%. remained the same
when pulling e6d35a2 on ArcaneNibble:reset
into aa0e305 on pybricks:master.

Copy link
Member

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also plan on creating a watchdog driver for EV3 to implement pbdrv_watchdog_update()?

@ArcaneNibble
Copy link
Collaborator Author

I actually didn't realize there was also a watchdog framework. I'll revisit this to take that into account.

@ArcaneNibble ArcaneNibble changed the title [EV3] pbio/drv/reset/reset_ev3: Implement reset via watchdog timer [EV3] Implement reset via watchdog timer Jul 17, 2025
// if it has already been configured. If it has *not* been configured,
// that means we are crashing in early boot, and we let the jump back
// to the reset vector take care of rebooting the system.
HWREG(SOC_TMR_1_REGS + TMR_WDTCR) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a new pbdrv_reset_reason_t for panic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need one? It currently reports as a watchdog reset

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it is worth it or not. That is why I ask. 😄

There is a slight difference in that the true watchdog reset only happens if the event loops stops running while a panic is a different mode of failure. So could be potentially useful for getting info on the cause of a crash. But would anyone ever actually do that? Maybe not very likely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem too likely, since right now crash dumps aren't saved anywhere and you need to have the debug console connected to see them.

Perhaps we can change "watchdog" to a generic "fatal error"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, we'll leave it the way it is. I would prefer to stick with calling it watchdog and add a new reason if we need to differentiate.

This helps detect if the system locks up and stops running the idle loop.
If the system locks up for more than 3 seconds, the system will reset.
The watchdog is the only way to reset *everything* on the AM1808.
It performs the same function as a power-on reset.
This helps determine whether the system was soft-rebooted,
booted from cold, or reset due to a crash.
Currently contains a compiler memory barrier and fall-through marker.
These operations will be needed throughout the driver layer.
@dlech
Copy link
Member

dlech commented Jul 19, 2025

I rebased this and fixed the conflicts.

@dlech dlech merged commit 613202a into pybricks:master Jul 19, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants