diff options
Diffstat (limited to 'docs/pages/getting_started.adoc')
| -rw-r--r-- | docs/pages/getting_started.adoc | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/docs/pages/getting_started.adoc b/docs/pages/getting_started.adoc new file mode 100644 index 000000000..465059922 --- /dev/null +++ b/docs/pages/getting_started.adoc | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | = Getting started | ||
| 2 | |||
| 3 | So you want to try Embassy, great! To get started, there are a few tools you need to install: | ||
| 4 | |||
| 5 | * link:https://rustup.rs/[rustup] - the Rust toolchain is needed to compile Rust code. | ||
| 6 | * link:https://probe.rs/[probe-rs] - to flash the firmware on your device. If you already have other tools like `OpenOCD` setup, you can use that as well. | ||
| 7 | |||
| 8 | If you don't have any supported board, don't worry: you can also run embassy on your PC using the `std` examples. | ||
| 9 | |||
| 10 | == Getting a board with examples | ||
| 11 | |||
| 12 | Embassy supports many microcontroller families, but the quickest way to get started is by using a board which Embassy has existing example code for. | ||
| 13 | |||
| 14 | This list is non-exhaustive. If your board isn’t included here, check the link:https://github.com/embassy-rs/embassy/tree/main/examples[examples folder] to see if example code has been written for it. | ||
| 15 | |||
| 16 | === nRF kits | ||
| 17 | |||
| 18 | * link:https://www.nordicsemi.com/Products/Development-hardware/nrf52-dk[nRF52 DK] | ||
| 19 | * link:https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK[nRF9160 DK] | ||
| 20 | |||
| 21 | === STM32 kits | ||
| 22 | |||
| 23 | * link:https://www.st.com/en/evaluation-tools/nucleo-h743zi.html[STM32 Nucleo-144 development board with STM32H743ZI MCU] | ||
| 24 | * link:https://www.st.com/en/evaluation-tools/nucleo-f429zi.html[STM32 Nucleo-144 development board with STM32F429ZI MCU] | ||
| 25 | * link:https://www.st.com/en/evaluation-tools/b-l4s5i-iot01a.html[STM32L4+ Discovery kit IoT node, low-power wireless, BLE, NFC, WiFi] | ||
| 26 | * link:https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html[STM32L0 Discovery kit LoRa, Sigfox, low-power wireless] | ||
| 27 | * link:https://www.st.com/en/evaluation-tools/nucleo-wl55jc.html[STM32 Nucleo-64 development board with STM32WL55JCI MCU] | ||
| 28 | * link:https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html[Discovery kit for IoT node with STM32U5 series] | ||
| 29 | |||
| 30 | |||
| 31 | === RP2040 kits | ||
| 32 | |||
| 33 | * link:https://www.raspberrypi.com/products/raspberry-pi-pico/[Raspberry Pi Pico] | ||
| 34 | |||
| 35 | === ESP32 | ||
| 36 | |||
| 37 | * link:https://github.com/esp-rs/esp-rust-board[ESP32C3] | ||
| 38 | |||
| 39 | == Running an example | ||
| 40 | |||
| 41 | First you need to clone the link:https://github.com/embassy-rs/embassy[github repository]; | ||
| 42 | |||
| 43 | [source, bash] | ||
| 44 | ---- | ||
| 45 | git clone https://github.com/embassy-rs/embassy.git | ||
| 46 | cd embassy | ||
| 47 | ---- | ||
| 48 | |||
| 49 | Once you have a copy of the repository, find examples folder for your board and, and build an example program. `blinky` is a good choice as all it does is blink an LED – the embedded world’s equivalent of “Hello World”. | ||
| 50 | |||
| 51 | [source, bash] | ||
| 52 | ---- | ||
| 53 | cd examples/nrf52840 | ||
| 54 | cargo build --bin blinky --release | ||
| 55 | ---- | ||
| 56 | |||
| 57 | Once you’ve confirmed you can build the example, connect your computer to your board with a debug probe and run it on hardware: | ||
| 58 | |||
| 59 | [source, bash] | ||
| 60 | ---- | ||
| 61 | cargo run --bin blinky --release | ||
| 62 | ---- | ||
| 63 | |||
| 64 | If everything worked correctly, you should see a blinking LED on your board, and debug output similar to this on your computer: | ||
| 65 | |||
| 66 | [source] | ||
| 67 | ---- | ||
| 68 | Finished dev [unoptimized + debuginfo] target(s) in 1m 56s | ||
| 69 | Running `probe-run --chip STM32F407VGTx target/thumbv7em-none-eabi/debug/blinky` | ||
| 70 | (HOST) INFO flashing program (71.36 KiB) | ||
| 71 | (HOST) INFO success! | ||
| 72 | ──────────────────────────────────────────────────────────────────────────────── | ||
| 73 | 0 INFO Hello World! | ||
| 74 | └─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:18 | ||
| 75 | 1 INFO high | ||
| 76 | └─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:23 | ||
| 77 | 2 INFO low | ||
| 78 | └─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:27 | ||
| 79 | 3 INFO high | ||
| 80 | └─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:23 | ||
| 81 | 4 INFO low | ||
| 82 | └─ blinky::__embassy_main::task::{generator#0} @ src/bin/blinky.rs:27 | ||
| 83 | ---- | ||
| 84 | |||
| 85 | NOTE: How does the `+cargo run+` command know how to connect to our board and program it? In each `examples` folder, there’s a `.cargo/config.toml` file which tells cargo to use link:https://probe.rs/[probe-rs] as the runner for ARM binaries in that folder. probe-rs handles communication with the debug probe and MCU. In order for this to work, probe-rs needs to know which chip it’s programming, so you’ll have to edit this file if you want to run examples on other chips. | ||
| 86 | |||
| 87 | === It didn’t work! | ||
| 88 | |||
| 89 | If you hare having issues when running `+cargo run --release+`, please check the following: | ||
| 90 | |||
| 91 | * You are specifying the correct `+--chip+` on the command line, OR | ||
| 92 | * You have set `+.cargo/config.toml+`’s run line to the correct chip, AND | ||
| 93 | * You have changed `+examples/Cargo.toml+`’s HAL (e.g. embassy-stm32) dependency's feature to use the correct chip (replace the existing stm32xxxx feature) | ||
| 94 | |||
| 95 | At this point the project should run. If you do not see a blinky LED for blinky, for example, be sure to check the code is toggling your board's LED pin. | ||
| 96 | |||
| 97 | If you are trying to run an example with `+cargo run --release+` and you see the following output: | ||
| 98 | [source] | ||
| 99 | ---- | ||
| 100 | 0.000000 INFO Hello World! | ||
| 101 | └─ <invalid location: defmt frame-index: 14> | ||
| 102 | 0.000000 DEBUG rcc: Clocks { sys: Hertz(80000000), apb1: Hertz(80000000), apb1_tim: Hertz(80000000), apb2: Hertz(80000000), apb2_tim: Hertz(80000000), ahb1: Hertz(80000000), ahb2: Hertz(80000000), ahb3: Hertz(80000000) } | ||
| 103 | └─ <invalid location: defmt frame-index: 124> | ||
| 104 | 0.000061 TRACE allocating type=Interrupt mps=8 interval_ms=255, dir=In | ||
| 105 | └─ <invalid location: defmt frame-index: 68> | ||
| 106 | 0.000091 TRACE index=1 | ||
| 107 | └─ <invalid location: defmt frame-index: 72> | ||
| 108 | ---- | ||
| 109 | |||
| 110 | To get rid of the frame-index error add the following to your `Cargo.toml`: | ||
| 111 | |||
| 112 | [source,toml] | ||
| 113 | ---- | ||
| 114 | [profile.release] | ||
| 115 | debug = 2 | ||
| 116 | ---- | ||
| 117 | |||
| 118 | If you’re getting an extremely long error message containing something like the following: | ||
| 119 | |||
| 120 | [source] | ||
| 121 | ---- | ||
| 122 | error[E0463]: can't find crate for `std` | ||
| 123 | | | ||
| 124 | = note: the `thumbv6m-none-eabi` target may not support the standard library | ||
| 125 | = note: `std` is required by `stable_deref_trait` because it does not declare `#![no_std]` | ||
| 126 | ---- | ||
| 127 | |||
| 128 | Make sure that you didn’t accidentally run `+cargo add probe-rs+` (which adds it as a dependency) instead of link:https://probe.rs/docs/getting-started/installation/[correctly installing probe-rs]. | ||
| 129 | |||
| 130 | If you’re using a raspberry pi pico-w, make sure you’re running `+cargo run --bin wifi_blinky --release+` rather than the regular blinky. The pico-w’s on-board LED is connected to the WiFi chip, which needs to be initialized before the LED can be blinked. | ||
| 131 | |||
| 132 | If you’re using an rp2040 debug probe (e.g. the pico probe) and are having issues after running `probe-rs info`, unplug and reconnect the probe, letting it power cycle. Running `probe-rs info` is link:https://github.com/probe-rs/probe-rs/issues/1849[known to put the pico probe into an unusable state]. | ||
| 133 | |||
| 134 | If you’re still having problems, check the link:https://embassy.dev/book/dev/faq.html[FAQ], or ask for help in the link:https://matrix.to/#/#embassy-rs:matrix.org[Embassy Chat Room]. | ||
| 135 | |||
| 136 | == What's next? | ||
| 137 | |||
| 138 | Congratulations, you have your first Embassy application running! Here are some suggestions for where to go from here: | ||
| 139 | |||
| 140 | * Read more about the xref:_embassy_executor[executor]. | ||
| 141 | * Read more about the xref:_hardware_abstraction_layer_hal[HAL]. | ||
| 142 | * Start xref:_a_basic_embassy_application[writing your application]. | ||
| 143 | * Learn how to xref:_starting_a_new_project[start a new embassy project by adapting an example]. | ||
