rust-embedded / rust-embedded/cortex-m
Pull out reusable semihosting code into its own crate
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 202
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 2
Description
or refactor common code into another crate to make it easier to port to other architectures
basically the only thing that needs to change to make this semihosting library work on other architectures is the assembly used to make the semihosting "system call". On Thumb-only ARM the syscall is BKPT 0xAB; on ARM-state ARM it's SVC 0x123456; on RISC-V it's a set of 3 instructions; etc.
I have tested a port of this library (just changed the syscall function) on real RISC-V hardware with OpenOCD and it works. I would it to work on any OpenOCD setup since the host-side of semihosting is implemented in OpenOCD.
Similarly, this library (with syscall changed) works on a QEMU-lated Cortex-A core and I would expect it to work on any architecture that QEMU supports.
The thing that's not straightforward to port is h(e)println!, who's implementation is unsound (#49) in multi-core machines. I would simply leave that API out for other architectures.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the semihosting library and its syscall function, then identify the reusable code that can move into a separate crate while leaving architecture-specific assembly replaceable. Compare the existing ARM behavior with the described RISC-V and QEMU ports. Done means other architectures can reuse the crate, while h(e)println! remains excluded where its multicore implementation is unsound.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100