Flash driver#73
Open
xarantolus wants to merge 9 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a DT-driven flash partition/region abstraction spanning device-tree codegen, ARM Cortex-M HAL primitives (STM32L4), and kernel-facing driver + uapi plumbing, with typed flash address newtypes to reduce misuse.
Changes:
- Extend
dtgento emit a flash partition registry + lookup helpers (by_compatible,by_label,by_address) andFLASH_BASE/FLASH_TOTAL_SIZEconstants. - Introduce
hal_api::flash_addrnewtypes (FlashAddress/FlashOffset/FlashPageStart) and integrate them into a new Cortex-M flash HAL (native + host stub). - Add a kernel driver-layer
drivers::flash::Region(read/erase/program/write with timeouts + DT read-only enforcement) and expose it viauapi::flash.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| xtasks/crates/dtgen/src/codegen.rs | Generates flash partition registry/constants and query API from DT. |
| src/uapi/flash.rs | New UAPI entry point for opening flash regions and re-exporting flash types. |
| src/uapi.rs | Exposes the new uapi::flash module. |
| src/drivers/flash.rs | Implements driver-layer Region read/erase/program/write over HAL flash primitives. |
| src/drivers.rs | Exposes the new drivers::flash module. |
| machine/cortex-m/st/stm32l4/interface/flash.c | Adds STM32L4 flash C primitives (busy/size/page ops/unlock/erase/program). |
| machine/cortex-m/st/stm32l4/interface/export.h | Exports flash constants and function prototypes for bindgen. |
| machine/cortex-m/src/stub/flash.rs | Host stub implementation for flash API/types. |
| machine/cortex-m/src/stub.rs | Wires the stub flash module into the stub HAL. |
| machine/cortex-m/src/native/flash.rs | Native Cortex-M flash HAL: bindings mapping + DT-backed Region. |
| machine/cortex-m/src/native.rs | Wires the native flash module into the native HAL. |
| machine/cortex-m/Cargo.toml | Adds build deps for bindgen macro filtering. |
| machine/cortex-m/build.rs | Updates bindgen generation to allowlist macros via // bindgen-export: markers and adds SoC defines. |
| machine/api/src/lib.rs | Exposes the new flash_addr module from hal-api. |
| machine/api/src/flash_addr.rs | Adds the flash address/offset/page-start newtypes + utilities. |
| Cargo.lock | Records added build dependencies. |
| boards/nucleo_l4r5zi.dts | Updates board DT to define a flash partition under flash0. |
💡 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.
Adds a somewhat generic flash driver, based on device tree definitions.