Change Note 2025-05-17
lib/v2.1, run-time error recovery
Overview
- Initiate
lib/v2.1, with a first focus on run-time error recovery. - See [Error Recovery]({{< relref "/concepts/architecture/recovery" >}}).
- Example program [Recovery]({{<relref "/docs/examples/v2/recovery">}}).
Framework
General
- The run-time error handling uses watchdog scratch register 0 to keep restart data across system restarts. This can be configured.
- The currently unused CPU register
r12is used to contain the kernel status, currently only the id of the current coroutine, which corresponds to the current thread's id. Yes, registerr12is "reserved" by Astrobe, but it's a pity to leave such a valuable resource unused. Should a future version of Astrobe make use ofr12, another solution will be found. Usingr12makes the data easily accessible from low-level error handlers, and does not mandate the use of the kernel for the recovery mechanism, which is implemented in an independent module.
Module RuntimeErrors
- Rewrite module according to [Error Recovery]({{< relref "/concepts/architecture/recovery" >}}).
New Module Stacktrace
- Create stack traces and read error exception-stacked registers, as formerly implemented in
RuntimeErrors. - This module may be renamed and extended going forward to add more programmer's tools.
Module RuntimeErrorsOut
- Rewrite module according to [Error Recovery]({{< relref "/concepts/architecture/recovery" >}}).
- Remove the dependency on module
Memory.
New Module Recovery
- First jab at autonomous error recovery.
- See example program
Recovery.
Module Kernel
- Thread timing period is now defined as number of ticks, not milliseconds. This avoids possible misalignment between the system tick and thus scheduler period, and the thread timing.
SetPeriodandSetPrioare now in-process APIs, to be called from the thread's init code.- Former in-process
ChangePeriodandChangePrioare removed. - The objective here to make each thread self-contained, so it can be reset and restarted without running the whole program initialisation code, which sets up the threads.
Module Coroutines
Initputs theCoroutinerecord pointer on initial stack.Transferstores current coroutine ID in register r12.
Module Watchdog
- Add procedure
GetScratchReg.
Module Errors
- Adjust
GetErrorMsgandGetErrorTypeaccording to changes inRuntimeErrors. GetErrorMsgreplacesGetExceptionMsg,GetErrorTypereplacesGetExceptionType.
Module StartUp
- New procedure
ReleaseResets.ReleaseReset(singular) is deprecated. - Fix
SetWatchdogBootVector(RP2040, RP2350) andSetPowmanBootVector(RS2350). - Rename some procedures for better consistency.
Module Main
- Adjust default ("print and halt") run-time error reporting for changes in
RuntimeErrorsandRuntimeErrorsOut.
Module LEDext
- Add CONST that addresses all eight LEDs.
Module MCU2
- Add values for watchdog restart causes.
Other Modules
- Small changes due to changed modules as outlined above.
Config Files
- Extend config files for
lib/v2.0for Astrobe v10. - Add config files for
lib/v2.1for Astrobe v10.
Example Programs
Recovery
- Recover from run-time errors and watchdog timeouts.
- Use new module
Recovery. - Description: [Recovery]({{< relref "/docs/examples/v2/recovery" >}})
RestartEval
- Evaluate different kinds of restarts, and the use of the watchdog boot functionality.
Other
- Port a first set of example programs to
lib/v2.1, mainly for the changes inKernelas outlined above.
Last updated: 18 May 2025