Embedded Rust on RISC-V Part 1
Bootstrap RISC-V target

Embedded Rust on RISC-V Part 1 free download
Bootstrap RISC-V target
First and foremost, this course don't cover toolchain installation This course starts with building blocks needed to bootstrap RISC-V processor into rust and finishes by booting Hifive1-Rev B board into Embedded Rust. Regarding the code management, there are many ways to manage code in rust; this course adopts Cargo workspace.
Section 1: Introduction
Introduction
Preamble
What is covered & what isn't
Resources & expectation
Section 2: Cargo Workspace
Create Cargo workspace
Create a binary crate to build an executable
Create library crate to keep reusable code
Create Cargo.toml to manage dependencies
Then this course jumps into the Embedded-rust & Cargo settings.
Section 3: Embedded-rust and Cargo settings for RISC-V Embedded Rust target
What are attributes in Rust?
What is Embedded Rust?
Provide custom panic handler and entry function
The difference between Cargo toml file vs config file
How to configure Cargo Workspace to build for RISC-V instead of host?
How to pass additional flags to Rust compiler?
How to pass custom linker file for target (Hifive1-RevB board)?
NOTE: This course don't cover how to write linker file. However, the linker file is shared as downloadable resource.
Section 4: Commands to dissect ELF and RUSTFLAGS
Commands to extract information from ELF
RUSTFLAGS in rust to tweak compiler behaviour
How to add custom linker file with RUSTFLAGS
With workspace & code management taken care, next is to add RISC-V boot up code in RISC-V assembly.
Section 5: Simple RISC-V boot code (Binary Crate)
How to add a assembly (.S) file?
Disable interrupts at boot time
Set the stack pointer to valid location
How to jump from RISC-V assembly to Embedded Rust entry function?
Build an executable with boot code in RISC-V assembly with entry & panic handler in Rust
Section 6: UART Driver in Rust (Library Crate)
Structs and Impls in Rust
Uart driver functions
Build an executable with boot code in RISC-V asm and UART driver in Rust.
Connect to Hifive1-RevB board with OpenOCD & GDB server
Load the executable into Hifive1-RevB
Read messages from serial out with serial tools
NOTE: This section uses a OpenOCD script but don't discuss about the script content. However, the script is shared as downloadable resource.
Update on Dec 5, 2024: Attached boot.S file on Section #5