Embedded Rust on RISC-V Part 1
Embedded Rust on RISC-V Part 1
Published 11/2024
Created by Benix Samuel Vincent Theogaraj
MP4 | Video: h264, 1280x720 | Audio: AAC, 44.1 KHz, 2 Ch
Genre: eLearning | Language: English | Duration: 18 Lectures ( 2h 43m ) | Size: 1 GB
Bootstrap RISC-V target
What you'll learn
How to create a rust workspace ?
How to configure the rust toolchain for RISC-V?
How to mix RISC-V assembly with rust?
Code to bootstrap RISC-V target into embedded rust
Requirements
Knowledge on computer architecture and programming language
Description
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: IntroductionIntroductionPreambleWhat is covered & what isn'tResources & expectationSection 2: Cargo WorkspaceCreate Cargo workspaceCreate a binary crate to build an executableCreate library crate to keep reusable codeCreate Cargo.toml to manage dependenciesThen this course jumps into the Embedded-rust & Cargo settings. Section 3: Embedded-rust and Cargo settings for RISC-V Embedded Rust targetWhat are attributes in Rust?What is Embedded Rust?Provide custom panic handler and entry functionThe difference between Cargo toml file vs config fileHow 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 ELFRUSTFLAGS in rust to tweak compiler behaviourHow to add custom linker file with RUSTFLAGSWith 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 timeSet the stack pointer to valid locationHow 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 RustSection 6: UART Driver in Rust (Library Crate)Structs and Impls in RustUart driver functionsBuild an executable with boot code in RISC-V asm and UART driver in Rust.Connect to Hifive1-RevB board with OpenOCD & GDB serverLoad the executable into Hifive1-RevBRead messages from serial out with serial toolsNOTE: This section uses a OpenOCD script but don't discuss about the script content. However, the script is shared as downloadable resource.
Who this course is for
Beginner embedded rust developers interested to run rust on RISC-V