Various improvements in all parts#78
Merged
Merged
Conversation
Member
thomasw04
commented
May 12, 2026
- I2C and SPI error handling.
- Scheduler fixes
- and more
xarantolus
approved these changes
May 12, 2026
Contributor
xarantolus
left a comment
There was a problem hiding this comment.
Mostly looked at CAN, seems fine
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refines several kernel and HAL subsystems, primarily standardizing device-driver error handling around POSIX errno values and adjusting scheduler real-time semantics (deadlines/budget handling).
Changes:
- Standardize SPI/I2C/CAN HAL interfaces to return
-PosixError_*and update Rust wrappers to convert C return codes viaok_or_err. - Add I2C transfer timeouts and bus recovery support end-to-end (C interface → Rust HAL → kernel driver API).
- Update RT scheduling to use relative deadlines and new replenishment behavior; add a default thread finalizer when none is supplied.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/uapi/spi.rs | Removes unused import in SPI uAPI wrapper. |
| src/uapi/i2c.rs | Removes unused import in I2C uAPI wrapper. |
| src/uapi/sched.rs | Tightens RT attribute validation (deadline vs budget/period). |
| src/types/queue.rs | Switches queue APIs to kernel Result/kerr! errno-style errors and updates tests. |
| src/types.rs | Exposes the queue module from types. |
| src/syscalls/sched.rs | Validates RT attributes in the syscall boundary before creating threads. |
| src/sched/thread.rs | Adds relative deadlines and changes RT server budget/deadline accounting. |
| src/sched/task.rs | Adds a default thread finalizer when no finalizer is provided. |
| src/sched/rt.rs | Changes EDF enqueue/put/pick behavior to align with new RT server fields. |
| src/sched.rs | Adds thread_finalizer used as the default thread finalizer. |
| src/lib.rs | Re-exports HAL API error module items at crate root. |
| src/error.rs | Updates WARN macros to use kprintln! and keeps errno/error helpers. |
| src/drivers/spi.rs | Makes SPI bus list push fallible via expect, and minor logging tweak. |
| src/drivers/i2c.rs | Adds timeouts + bus recovery API to I2C driver; changes bus list push to expect. |
| src/drivers/can.rs | Switches CAN driver error type to PosixError and adjusts exports. |
| machine/cortex-m/st/stm32l4/interface/spi.c | Adds errno-mapped SPI error handling, busy-wait timeout, and better validation/timeout calc. |
| machine/cortex-m/st/stm32l4/interface/i2c.c | Adds errno-mapped I2C errors, per-transfer timeout, and bus recovery helpers. |
| machine/cortex-m/st/stm32l4/interface/gpio.h | Declares new open-drain output GPIO init helper. |
| machine/cortex-m/st/stm32l4/interface/gpio.c | Implements gpio_init_output_od. |
| machine/cortex-m/st/stm32l4/interface/export.h | Extends I2C transfer struct with timeout + new recovery function declarations. |
| machine/cortex-m/st/stm32l4/interface/can.c | Converts CAN interface to POSIX errno returns with improved validation/mapping. |
| machine/cortex-m/src/stub/i2c.rs | Updates stub signatures for timeouts and adds stub bus recovery APIs. |
| machine/cortex-m/src/stub/can.rs | Converts stub CAN errors to PosixError. |
| machine/cortex-m/src/native/spi.rs | Uses ok_or_err to map SPI C return codes into PosixError. |
| machine/cortex-m/src/native/sched.rs | Cleans up unused Range import. |
| machine/cortex-m/src/native/i2c.rs | Adds timeout field plumbing + bus recovery wrappers; uses ok_or_err. |
| machine/cortex-m/src/native/can.rs | Uses ok_or_err and maps CAN C return codes into PosixError. |
| machine/cortex-m/build.rs | Generates a C header (hal_api.h) for PosixError via cbindgen and includes it in HAL builds. |
| machine/api/src/lib.rs | Moves POSIX error definitions into a dedicated error module and re-exports them. |
| machine/api/src/error.rs | New module containing PosixError, Result, and helper conversion functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.