Board, components and peripherals
The board, as shown earlier, is:
The board then, is the whole item. Its main parts are:
- The printed circuit board (PCB): the flat fiberglass sheet underneath it all.
- The components: modules on top of the PCB. They interconnect with traces which are thin copper wires. Examples of components: MCU, USB ports LEDs, Pins.
- The microcontroller or microcontroller unit (MCU): the big square labelled ESP32-C6-WROOM (or some variant). It takes almost half the board. The MCU includes peripherals, CPU and RAM.
- The peripherals are parts of the MCU including: GPIO, UART, I2C, SPI, WiFi, Bluetooth and others.
- The microcontroller or microcontroller unit (MCU): the big square labelled ESP32-C6-WROOM (or some variant). It takes almost half the board. The MCU includes peripherals, CPU and RAM.
A nice explanation of how it all comes together is in the micro:bit v2 book:
Our MCU1 has 73 tiny metal pins sitting right underneath it (it’s a so called aQFN73 chip). These pins are connected to traces, the little “roads” that act as the wires connecting components together on the board. The MCU can dynamically alter the electrical properties of the pins. This works similarly to a light switch, altering how electrical current flows through a circuit. By enabling or disabling electrical current to flow through a specific pin, an LED attached to that pin (via the traces) can be turned on and off.
What is no_std?
This tutorial is “no_std”, but what does it mean? std can refer to:
std: the cratestd: the component, including the cratesstd,core,allocamong others.
This book distinguishes them precisely by adding the words crate and component, respectively.
The microcontroller has no Operative System, but std crate relies on one. Hence, #[no_std] is used in main.rs to indicate that std crate should be excluded.
To be precise alloc is excluded by default but can be added. A comparison is provided by this the table below, copied from the Rust Embedded Guide:
| feature | no_std | std |
|---|---|---|
| heap (dynamic memory) | * | ✓ |
| collections (Vec, BTreeMap, etc) | ** | ✓ |
| stack overflow protection | ✘ | ✓ |
| runs init code before main | ✘ | ✓ |
| libstd available | ✘ | ✓ |
| libcore available | ✓ | ✓ |
| writing firmware, kernel, or bootloader code | ✓ | ✘ |
* Only if you use the alloc crate and use a suitable allocator like esp-alloc.
** Only if you use the collections crate and configure a global default allocator.
** HashMap and HashSet are not available due to a lack of a secure random number generator.
-
Refers to a different MCU than ours but the concept is the same. ↩