Conversation
|
We often multi-source parts for the same functionality but with the same binary. Differentiating between the two parts is only possible once the binary starts and hardware markers are read from the board. The hardware driver may differ between the peripherals. How does this proposal handle a scenario like this? |
Great question! The simplest way would be to define everything in the devicetree and then only use certain devices at runtime. So something like let Devicetree { sensor, sensor_alt } = devicetree::devicetree();
match sensor_config {
SensorType::Regular => start_task(sensor),
SensorType::Alt => start_task(sensor_alt)
}I worked on a Zephyr-based project and this is essentially how we handled the situation: everything in the devicetree was being instantiated but only the active devices were ever used in code. The unused devices still took up space in RAM, but the increase in usage wasn't significant. With Rust we can probably do better since we can drop the unused one, while everything had to be defined as |
|
Do you know of any open-source projects that use device tree for the entire platform? For instance, a platform uses a UART between the EC and SOC. Speed/handshake info is needed in the EC, UEFI, and OS environments so worst case scenario is it is duplicated in 3 places. There are ways to help keep things in sync, but I'd like to investigate how feasible it is using a single reference for all config top to bottom. |
|
Will ODP crates still be compatible with projects that do not leverage a device tree for initialization? |
| @@ -0,0 +1,114 @@ | |||
| # RFC: `Use devicetrees for hardware instatiation and configuration` | |||
|
|
|||
| Instantiating drivers for hardware is currently done by creating the corresponding driver struct and connecting any dependencies manually. This approach can be cumbersome, error prone, and inflexible: taking an existing hardware configuration and making small tweaks often requires complete duplication. Drivers may also require additional variables for internal state or channels to allow for communication between components. This boilerplate is required for drivers to function but is another tedious part of using hardware. This RFC proposes using devicetrees for hardware instantiaton and configuration. | |||
There was a problem hiding this comment.
Is the only thing we're trying to improve here board_init/setup phase? Or is this planning to scale into other things like driver APIs, service interfaces, etc.?
There was a problem hiding this comment.
Correct, the only real restriction on APIs would be that traits for things like I2C busses, GPIOs, etc have to be shared by everything. The proof-of-concept uses traits from embedded-hal for broad compatibility.
I'm not personally aware of a project that does this, but Zephyr supports |
Yes, this functionality would be purely optional. |
No description provided.