Skip to content

Commit 37b4d3e

Browse files
committed
Add new section 'Supporting a new SoC'
1 parent 66c663e commit 37b4d3e

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@
1212
---
1313
[A note on compiler support](./compiler-support.md)
1414
[Creating a custom target](./custom-target.md)
15+
[Supporting a new SoC](./soc-support.md)

src/soc-support.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
# Guide for Silicon Vendors to Enable Rust Support for Their SoCs
2+
3+
## Introduction
4+
5+
Rust has emerged as a powerful and safety-focused programming language, gaining
6+
traction among embedded developers. Silicon vendors who wish to enable Rust
7+
support for their System-on-Chip (SoC) products can benefit from this trend by
8+
attracting a growing community of Rust developers.
9+
10+
This guide aims to help silicon vendors enable Rust support, either
11+
independently or by empowering third-party developers. It outlines the
12+
essential resources, tasks, and priorities required to foster a robust Rust
13+
ecosystem around their System-on-Chip (SoC).
14+
15+
**Note:** For assistance with strategy in engaging with the community, we
16+
recommend reaching out to the Embedded Rust Working Group (REWG) leads. They
17+
can provide valuable insights and support to help you navigate the process
18+
effectively.
19+
20+
## Essential Resources
21+
22+
### Documentation
23+
24+
Detailed documentation is essential for effective development and debugging. It
25+
enables developers to comprehend the System-on-Chip (SoC), including its memory
26+
map, peripherals, interrupt handling, low-power modes, etc. Ensure that the
27+
documentation covers all hardware aspects comprehensively, from register-level
28+
details to system-level interactions. The documentation should be publicly
29+
available; in cases where public availability is not feasible, any
30+
non-disclosure agreement (NDA) must permit the publication of open-source code
31+
derived from it.
32+
33+
### Register Description Files
34+
35+
Register description files are used to generate Peripheral Access Crates
36+
(PACs). The most common format for these files is SVD
37+
([System View Description](https://open-cmsis-pack.github.io/svd-spec)). Rust
38+
developers have often encountered issues with SVD files, so it is crucial to
39+
provide clear contact information for reporting any discrepancies or problems.
40+
Up-to-date SVD files ensure that the community can collaborate effectively to
41+
resolve issues and improve the quality of the PACs.
42+
43+
### Flash Algorithms
44+
45+
[Flash Algorithms](https://open-cmsis-pack.github.io/Open-CMSIS-Pack-Spec/main/html/flashAlgorithm.html)
46+
are integrated with debugging tools like `probe-rs`. They facilitate and speed
47+
up firmware programming and debugging, streamlining development workflows.
48+
Providing well-supported FlashAlgos will enhance the integration with these
49+
tools and improve the overall developer experience.
50+
51+
### Vendor Tooling
52+
53+
Some System-on-Chip (SoC) devices require custom tools for generating images or
54+
flashing them onto the device. It is beneficial to provide these tools in an
55+
open-source manner, fostering community contributions and accelerating
56+
ecosystem growth. Open-sourcing vendor tooling enables third-party developers
57+
to extend and enhance the toolchain, ensuring improved compatibility with the
58+
broader Embedded Rust ecosystem.
59+
60+
### Contact Information
61+
62+
Providing contact information is vital for addressing maintainer queries and
63+
issues related to register description files or other resources. The use of a
64+
public issue tracking system (like GitHub Issues) for reporting and tracking
65+
problems might help. Actively engage with the community through forums,
66+
discussions, and updates to build trust and collaboration.
67+
68+
## Maintaining PAC and HAL Crates
69+
70+
Peripheral Access Crates (PACs) and Hardware Abstraction Layer (HAL) crates are
71+
at the core of enabling Rust support.
72+
73+
### Generate and Maintain PACs
74+
75+
Multiple tools such as `svd2rust`, `chiptool`, `raltool`, and `svd2pac`
76+
automate the generation of PACs from register description files. Each tool has
77+
its strengths, and selecting the right one depends on the requirements and the
78+
complexity of the hardware.
79+
80+
### Develop and Maintain HAL Crates
81+
82+
Implement `embedded-hal` and `embedded-hal-async` traits in your HAL crates.
83+
Adhering to these traits ensures compatibility across the Embedded Rust
84+
ecosystem, enhancing interoperability. It is an essential goal that HALs use
85+
Rust code rather than wrapping existing C code. An incremental porting
86+
strategy, where Rust is used for all core functionality, but C with Rust
87+
bindings is used for complex drivers, is acceptable, allowing for gradual
88+
adoption and community contributions.
89+
90+
Start with essential peripherals (clock, timer, GPIO) and expand progressively
91+
(I2C, SPI, UART, etc.) based on community feedback. Release early and often to
92+
engage the community and gather valuable insights for further development.
93+
94+
### Common Recommendations
95+
96+
- Ensure that crates are compatible with `no_std` environments, which are
97+
common in embedded systems without an operating system. Functionality that
98+
needs `alloc` or `std` can be included when gated with Cargo "features."
99+
- Make your crates available on [crates.io](https://crates.io/) to maximize
100+
visibility and ease of use for developers.
101+
- Use semantic versioning to maintain consistency and predictability in your
102+
releases.
103+
- Prefer licenses like Apache 2.0 and MIT for their permissive nature, which
104+
encourages broader adoption and collaboration.
105+
106+
### Issue Tracking
107+
108+
Effective issue tracking is crucial for maintaining a healthy and collaborative
109+
ecosystem. Discuss triaging, labeling, and community involvement in issue
110+
resolution. Implement transparent processes for:
111+
112+
- Triage and prioritize issues based on severity and impact.
113+
- Use labels to categorize issues (e.g., bugs, feature requests).
114+
- Encourage community members to contribute to resolving issues by providing
115+
feedback or submitting pull requests (PRs).
116+
117+
### Facilitate Debugging and Testing
118+
119+
The use of `probe-rs` is prevalent in the Embedded Rust ecosystem for debugging
120+
and testing. Combined with debug-based facilities like `defmt-rtt`, which
121+
offers logging capabilities for embedded systems, the Embedded Rust ecosystem
122+
has developed numerous tools. `probe-rs` supports a wide range of target
123+
architectures, debug interfaces, and debug probe protocols.
124+
125+
Thorough testing ensures hardware-software reliability, and leveraging these
126+
tools can significantly enhance development workflows.
127+
128+
## Nice-to-Have Features for Enhanced Ecosystem Support
129+
130+
### Examples
131+
132+
Including some basic examples as part of the HAL is essential for helping
133+
developers get started. These examples should demonstrate key functionalities,
134+
such as initializing peripherals or handling interrupts. They serve as
135+
practical starting points and learning aids.
136+
137+
### BSP (Board Support Package) Crates
138+
139+
BSP crates are relevant when you need to provide board-specific configurations
140+
and initializations. Unlike HALs, which focus on hardware abstraction, BSPs
141+
handle the integration of multiple components for a specific board. Having both
142+
BSP and HAL crates offers a layered approach, making it easier for developers
143+
to build applications targeting a particular hardware board.
144+
145+
### Project Templates
146+
147+
Project templates are boilerplate code structures that provide a starting point
148+
for new projects. They include prevalent configurations, dependencies, and
149+
setup steps, saving developers time and reducing the learning curve. Examples
150+
of project templates include bare-metal (using the HAL without any framework),
151+
Embassy, RTIC, and others.
152+
153+
### Integration with Popular IDEs and Tools
154+
155+
Offer guides on setting up development environments for Embedded Rust projects
156+
with popular tools such as:
157+
158+
- `rust-analyzer`: for Rust syntax highlighting and error checking.
159+
- `probe-rs`: for flashing and debugging firmware.
160+
- `defmt`: a logging framework optimized for embedded systems.
161+
- `defmt-test`: testing utilities for `defmt`.
162+
163+
Providing setup instructions for these tools will help developers integrate
164+
them into their workflows, enhancing productivity and collaboration.
165+
166+
## Conclusion
167+
168+
Enabling Rust support for your SoC opens the door to a vibrant community of
169+
developers who value safety, performance, and reliability. By providing
170+
essential resources, maintaining high-quality PACs and HAL crates, and
171+
fostering a supportive ecosystem, you empower both internal teams and
172+
third-party developers to unlock the full potential of your hardware.
173+
174+
As the Rust embedded ecosystem continues to grow, embracing these practices
175+
positions your company at the forefront of this movement, attracting developers
176+
passionate about building robust and innovative systems. Encourage ongoing
177+
engagement with the Rust community to stay updated on best practices and tools,
178+
ensuring your System-on-Chip (SoC) remains a preferred choice for Rust
179+
developers.
180+
181+
By following this guide, you can create a comprehensive and supportive
182+
environment that not only enables Rust support but also nurtures a thriving
183+
developer ecosystem around your products.

0 commit comments

Comments
 (0)