nihalpasham / rustBoot

rustBoot is a standalone bootloader written entirely in `Rust`, designed to run on anything from a microcontroller to a system on chip. It can be used to boot into bare-metal firmware or Linux.
MIT License
214 stars 21 forks source link

Where are Peripherals, NVMC object placed ? #5

Closed vietle77 closed 2 years ago

vietle77 commented 2 years ago

Dear Nihal, I am walking through class FlashWriterEraser in nrf52840.rs which should be refer for implementing a HAL of another board I see there are 2 class Peripherals, NVMC (Non Volatile Memory Controller) which are not presented in the source dir. So I guess these classes were generated from nrf52840.svd, right ? if yes, kindly show me: What tool is used to generate these class? Where are generated classes placed ?

Thank you. Viet

nihalpasham commented 2 years ago

So, we're using the [nrf52840-hal](https://crates.io/crates/nrf52840-hal) (i.e. a crate maintained by the embedded rust community). It provides access (i.e. via abstractions) to all available system peripherals. The rust community maintains a number of different crates for different boards such as stm32, microchip-SAM etc.

nrf52840.svd - an .svd file (short for system view description) is actually not important. Its required for debugging i.e. there's a VSCode plugin called cortex-m debug that is used to debug embedded code and it uses .svd files.

fyi - rust isn't exactly objected oriented. So, the concept of classes and instances of classes (i.e. objects) doesn't really exist, instead rust provides types and traits which can be used to write object-oriented code, data-oriented code (i.e. ECS type stuff) or code that conforms to other programming paradigms.