diff options
| author | Olof <[email protected]> | 2024-12-18 01:48:25 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-18 01:48:25 +0100 |
| commit | 7cf96e4730964d085015320648c870a05fbaf431 (patch) | |
| tree | 04072529b62082cb66443377b589fe08169f83be /docs | |
| parent | 8678911028a591d72fd1d8418407b5885ed4c417 (diff) | |
| parent | 341036a8b865609767fbf9015b482ea70ed4f23f (diff) | |
Merge branch 'embassy-rs:main' into u5_adc
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/examples/basic/Cargo.toml | 2 | ||||
| -rw-r--r-- | docs/examples/layer-by-layer/blinky-async/Cargo.toml | 2 | ||||
| -rw-r--r-- | docs/pages/embassy_in_the_wild.adoc | 2 | ||||
| -rw-r--r-- | docs/pages/faq.adoc | 59 | ||||
| -rw-r--r-- | docs/pages/new_project.adoc | 20 | ||||
| -rw-r--r-- | docs/pages/overview.adoc | 4 |
6 files changed, 81 insertions, 8 deletions
diff --git a/docs/examples/basic/Cargo.toml b/docs/examples/basic/Cargo.toml index 5d391adf3..daf83873d 100644 --- a/docs/examples/basic/Cargo.toml +++ b/docs/examples/basic/Cargo.toml | |||
| @@ -6,7 +6,7 @@ version = "0.1.0" | |||
| 6 | license = "MIT OR Apache-2.0" | 6 | license = "MIT OR Apache-2.0" |
| 7 | 7 | ||
| 8 | [dependencies] | 8 | [dependencies] |
| 9 | embassy-executor = { version = "0.6.0", path = "../../../embassy-executor", features = ["defmt", "integrated-timers", "arch-cortex-m", "executor-thread"] } | 9 | embassy-executor = { version = "0.6.3", path = "../../../embassy-executor", features = ["defmt", "arch-cortex-m", "executor-thread"] } |
| 10 | embassy-time = { version = "0.3.2", path = "../../../embassy-time", features = ["defmt"] } | 10 | embassy-time = { version = "0.3.2", path = "../../../embassy-time", features = ["defmt"] } |
| 11 | embassy-nrf = { version = "0.2.0", path = "../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } | 11 | embassy-nrf = { version = "0.2.0", path = "../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote"] } |
| 12 | 12 | ||
diff --git a/docs/examples/layer-by-layer/blinky-async/Cargo.toml b/docs/examples/layer-by-layer/blinky-async/Cargo.toml index 7f8d8af3e..f6d2e4fc7 100644 --- a/docs/examples/layer-by-layer/blinky-async/Cargo.toml +++ b/docs/examples/layer-by-layer/blinky-async/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | cortex-m = "0.7" | 8 | cortex-m = "0.7" |
| 9 | cortex-m-rt = "0.7" | 9 | cortex-m-rt = "0.7" |
| 10 | embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"] } | 10 | embassy-stm32 = { version = "0.1.0", features = ["stm32l475vg", "memory-x", "exti"] } |
| 11 | embassy-executor = { version = "0.6.0", features = ["arch-cortex-m", "executor-thread"] } | 11 | embassy-executor = { version = "0.6.3", features = ["arch-cortex-m", "executor-thread"] } |
| 12 | 12 | ||
| 13 | defmt = "0.3.0" | 13 | defmt = "0.3.0" |
| 14 | defmt-rtt = "0.3.0" | 14 | defmt-rtt = "0.3.0" |
diff --git a/docs/pages/embassy_in_the_wild.adoc b/docs/pages/embassy_in_the_wild.adoc index bb457a869..620794c31 100644 --- a/docs/pages/embassy_in_the_wild.adoc +++ b/docs/pages/embassy_in_the_wild.adoc | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | Here are known examples of real-world projects which make use of Embassy. Feel free to link:https://github.com/embassy-rs/embassy/blob/main/docs/pages/embassy_in_the_wild.adoc[add more]! | 3 | Here are known examples of real-world projects which make use of Embassy. Feel free to link:https://github.com/embassy-rs/embassy/blob/main/docs/pages/embassy_in_the_wild.adoc[add more]! |
| 4 | 4 | ||
| 5 | * link:https://github.com/1-rafael-1/simple-robot[A simple tracked robot based on Raspberry Pi Pico 2] | ||
| 6 | ** A hobbyist project building a tracked robot with basic autonomous and manual drive mode. | ||
| 5 | * link:https://github.com/1-rafael-1/pi-pico-alarmclock-rust[A Raspberry Pi Pico W Alarmclock] | 7 | * link:https://github.com/1-rafael-1/pi-pico-alarmclock-rust[A Raspberry Pi Pico W Alarmclock] |
| 6 | ** A hobbyist project building an alarm clock around a Pi Pico W complete with code, components list and enclosure design files. | 8 | ** A hobbyist project building an alarm clock around a Pi Pico W complete with code, components list and enclosure design files. |
| 7 | * link:https://github.com/haobogu/rmk/[RMK: A feature-rich Rust keyboard firmware] | 9 | * link:https://github.com/haobogu/rmk/[RMK: A feature-rich Rust keyboard firmware] |
diff --git a/docs/pages/faq.adoc b/docs/pages/faq.adoc index 8eb947b5e..3e32563cc 100644 --- a/docs/pages/faq.adoc +++ b/docs/pages/faq.adoc | |||
| @@ -372,3 +372,62 @@ Issues like these while implementing drivers often fall into one of the followin | |||
| 372 | 3. Some kind of hardware errata, or some hardware misconfiguration like wrong clock speeds | 372 | 3. Some kind of hardware errata, or some hardware misconfiguration like wrong clock speeds |
| 373 | 4. Some issue with an interrupt handler, either enabling, disabling, or re-enabling of interrupts when necessary | 373 | 4. Some issue with an interrupt handler, either enabling, disabling, or re-enabling of interrupts when necessary |
| 374 | 5. Some kind of async issue, like not registering wakers fully before checking flags, or not registering or pending wakers at the right time | 374 | 5. Some kind of async issue, like not registering wakers fully before checking flags, or not registering or pending wakers at the right time |
| 375 | |||
| 376 | == How can I prevent the thread-mode executor from going to sleep? == | ||
| 377 | |||
| 378 | In some cases you might want to prevent the thread-mode executor from going to sleep, for example when doing so would result in current spikes that reduce analog performance. | ||
| 379 | As a workaround, you can spawn a task that yields in a loop, preventing the executor from going to sleep. Note that this may increase power consumption. | ||
| 380 | |||
| 381 | [source,rust] | ||
| 382 | ---- | ||
| 383 | #[embassy_executor::task] | ||
| 384 | async fn idle() { | ||
| 385 | loop { embassy_futures::yield_now().await; } | ||
| 386 | } | ||
| 387 | ---- | ||
| 388 | |||
| 389 | == Why is my bootloader restarting in loop? | ||
| 390 | |||
| 391 | == Troubleshooting Bootloader Restart Loops | ||
| 392 | |||
| 393 | If your bootloader restarts in a loop, there could be multiple reasons. Here are some things to check: | ||
| 394 | |||
| 395 | === Validate the `memory.x` File | ||
| 396 | The bootloader performs critical checks when creating partitions using the addresses defined in `memory.x`. Ensure the following assertions hold true: | ||
| 397 | |||
| 398 | [source,rust] | ||
| 399 | ---- | ||
| 400 | const { | ||
| 401 | core::assert!(Self::PAGE_SIZE % ACTIVE::WRITE_SIZE as u32 == 0); | ||
| 402 | core::assert!(Self::PAGE_SIZE % ACTIVE::ERASE_SIZE as u32 == 0); | ||
| 403 | core::assert!(Self::PAGE_SIZE % DFU::WRITE_SIZE as u32 == 0); | ||
| 404 | core::assert!(Self::PAGE_SIZE % DFU::ERASE_SIZE as u32 == 0); | ||
| 405 | } | ||
| 406 | |||
| 407 | // Ensure enough progress pages to store copy progress | ||
| 408 | assert_eq!(0, Self::PAGE_SIZE % aligned_buf.len() as u32); | ||
| 409 | assert!(aligned_buf.len() >= STATE::WRITE_SIZE); | ||
| 410 | assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE); | ||
| 411 | assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE); | ||
| 412 | ---- | ||
| 413 | |||
| 414 | If any of these assertions fail, the bootloader will likely restart in a loop. This failure might not log any messages (e.g., when using `defmt`). Confirm that your `memory.x` file and flash memory align with these requirements. | ||
| 415 | |||
| 416 | === Handling Panic Logging | ||
| 417 | Some panic errors might log messages, but certain microcontrollers reset before the message is fully printed. To ensure panic messages are logged, add a delay using no-operation (NOP) instructions before the reset: | ||
| 418 | |||
| 419 | [source,rust] | ||
| 420 | ---- | ||
| 421 | #[panic_handler] | ||
| 422 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 423 | for _ in 0..10_000_000 { | ||
| 424 | cortex_m::asm::nop(); | ||
| 425 | } | ||
| 426 | cortex_m::asm::udf(); | ||
| 427 | } | ||
| 428 | ---- | ||
| 429 | |||
| 430 | === Feed the watchdog | ||
| 431 | |||
| 432 | |||
| 433 | Some `embassy-boot` implementations (like `embassy-boot-nrf` and `embassy-boot-rp`) rely on a watchdog timer to detect application failure. The bootloader will restart if your application code does not properly feed the watchdog timer. Make sure to feed it correctly. | ||
diff --git a/docs/pages/new_project.adoc b/docs/pages/new_project.adoc index 821bcbd27..63340016b 100644 --- a/docs/pages/new_project.adoc +++ b/docs/pages/new_project.adoc | |||
| @@ -73,22 +73,34 @@ Now that cargo knows what target to compile for (and probe-rs knows what chip to | |||
| 73 | 73 | ||
| 74 | Looking in `examples/stm32g4/Cargo.toml`, we can see that the examples require a number of embassy crates. For blinky, we’ll only need three of them: `embassy-stm32`, `embassy-executor` and `embassy-time`. | 74 | Looking in `examples/stm32g4/Cargo.toml`, we can see that the examples require a number of embassy crates. For blinky, we’ll only need three of them: `embassy-stm32`, `embassy-executor` and `embassy-time`. |
| 75 | 75 | ||
| 76 | At the time of writing, the latest version of embassy isn‘t available on crates.io, so we need to install it straight from the git repository. The recommended way of doing so is as follows: | 76 | |
| 77 | At the time of writing, embassy is already published to crates.io. Therefore, dependencies can easily added via Cargo.toml. | ||
| 78 | |||
| 79 | [source,toml] | ||
| 80 | ---- | ||
| 81 | [dependencies] | ||
| 82 | embassy-stm32 = { version = "0.1.0", features = ["defmt", "time-driver-any", "stm32g474re", "memory-x", "unstable-pac", "exti"] } | ||
| 83 | embassy-executor = { version = "0.6.3", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt"] } | ||
| 84 | embassy-time = { version = "0.3.2", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 85 | ---- | ||
| 86 | |||
| 87 | Prior, embassy needed to be installed straight from the git repository. Installing from git is still useful, if you want to checkout a specic revision of an embassy crate which is not yet published. | ||
| 88 | The recommended way of doing so is as follows: | ||
| 77 | 89 | ||
| 78 | * Copy the required `embassy-*` lines from the example `Cargo.toml` | 90 | * Copy the required `embassy-*` lines from the example `Cargo.toml` |
| 79 | * Make any necessary changes to `features`, e.g. requiring the `stm32g474re` feature of `embassy-stm32` | 91 | * Make any necessary changes to `features`, e.g. requiring the `stm32g474re` feature of `embassy-stm32` |
| 80 | * Remove the `path = ""` keys in the `embassy-*` entries | 92 | * Remove the `path = ""` keys in the `embassy-*` entries |
| 81 | * Create a `[patch.crates-io]` section, with entries for each embassy crate we need. These should all contain identical values: a link to the git repository, and a reference to the commit we’re checking out. Assuming you want the latest commit, you can find it by running `git ls-remote https://github.com/embassy-rs/embassy.git HEAD` | 93 | * Create a `[patch.crates-io]` section, with entries for each embassy crate we need. These should all contain identical values: a link to the git repository, and a reference to the commit we’re checking out. Assuming you want the latest commit, you can find it by running `git ls-remote https://github.com/embassy-rs/embassy.git HEAD` |
| 82 | 94 | ||
| 83 | NOTE: When using this method, it’s necessary that the `version` keys in `[dependencies]` match up with the versions defined in each crate’s `Cargo.toml` in the specificed `rev` under `[patch.crates.io]`. This means that when updating, you have to a pick a new revision, change everything in `[patch.crates.io]` to match it, and then correct any versions under `[dependencies]` which have changed. Hopefully this will no longer be necessary once embassy is released on crates.io! | 95 | NOTE: When using this method, it’s necessary that the `version` keys in `[dependencies]` match up with the versions defined in each crate’s `Cargo.toml` in the specificed `rev` under `[patch.crates.io]`. This means that when updating, you have to a pick a new revision, change everything in `[patch.crates.io]` to match it, and then correct any versions under `[dependencies]` which have changed. |
| 84 | 96 | ||
| 85 | At the time of writing, this method produces the following results: | 97 | An example Cargo.toml file might look as follows: |
| 86 | 98 | ||
| 87 | [source,toml] | 99 | [source,toml] |
| 88 | ---- | 100 | ---- |
| 89 | [dependencies] | 101 | [dependencies] |
| 90 | embassy-stm32 = {version = "0.1.0", features = ["defmt", "time-driver-any", "stm32g474re", "memory-x", "unstable-pac", "exti"]} | 102 | embassy-stm32 = {version = "0.1.0", features = ["defmt", "time-driver-any", "stm32g474re", "memory-x", "unstable-pac", "exti"]} |
| 91 | embassy-executor = { version = "0.3.3", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 103 | embassy-executor = { version = "0.3.3", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt"] } |
| 92 | embassy-time = { version = "0.2", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 104 | embassy-time = { version = "0.2", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 93 | 105 | ||
| 94 | [patch.crates-io] | 106 | [patch.crates-io] |
diff --git a/docs/pages/overview.adoc b/docs/pages/overview.adoc index 2ebc85f6d..8f97d937f 100644 --- a/docs/pages/overview.adoc +++ b/docs/pages/overview.adoc | |||
| @@ -52,7 +52,7 @@ link:https://github.com/embassy-rs/embassy/tree/main/embassy-boot[embassy-boot] | |||
| 52 | 52 | ||
| 53 | == What is DMA? | 53 | == What is DMA? |
| 54 | 54 | ||
| 55 | For most I/O in embedded devices, the peripheral doesn't directly support the transmission of multiple bits at once, with CAN being a notable exception. Instead, the MCU must write each byte, one at a time, and then wait until the peripheral is ready to send the next. For high I/O rates, this can pose a problem if the MCU must devote an increasing portion of its time handling each byte. The solution to this problem is to use the Direct Memory Access controller. | 55 | For most I/O in embedded devices, the peripheral doesn't directly support the transmission of multiple bytes at once, with CAN being a notable exception. Instead, the MCU must write each byte, one at a time, and then wait until the peripheral is ready to send the next. For high I/O rates, this can pose a problem if the MCU must devote an increasing portion of its time handling each byte. The solution to this problem is to use the Direct Memory Access controller. |
| 56 | 56 | ||
| 57 | The Direct Memory Access controller (DMA) is a controller that is present in MCUs that Embassy supports, including stm32 and nrf. The DMA allows the MCU to set up a transfer, either send or receive, and then wait for the transfer to complete. With DMA, once started, no MCU intervention is required until the transfer is complete, meaning that the MCU can perform other computation, or set up other I/O while the transfer is in progress. For high I/O rates, DMA can cut the time that the MCU spends handling I/O by over half. However, because DMA is more complex to set-up, it is less widely used in the embedded community. Embassy aims to change that by making DMA the first choice rather than the last. Using Embassy, there's no additional tuning required once I/O rates increase because your application is already set-up to handle them. | 57 | The Direct Memory Access controller (DMA) is a controller that is present in MCUs that Embassy supports, including stm32 and nrf. The DMA allows the MCU to set up a transfer, either send or receive, and then wait for the transfer to complete. With DMA, once started, no MCU intervention is required until the transfer is complete, meaning that the MCU can perform other computation, or set up other I/O while the transfer is in progress. For high I/O rates, DMA can cut the time that the MCU spends handling I/O by over half. However, because DMA is more complex to set-up, it is less widely used in the embedded community. Embassy aims to change that by making DMA the first choice rather than the last. Using Embassy, there's no additional tuning required once I/O rates increase because your application is already set-up to handle them. |
| 58 | 58 | ||
| @@ -80,4 +80,4 @@ For more reading material on async Rust and Embassy: | |||
| 80 | 80 | ||
| 81 | Videos: | 81 | Videos: |
| 82 | 82 | ||
| 83 | * link:https://www.youtube.com/watch?v=wni5h5vIPhU[From Zero to Async in Embedded Rust] \ No newline at end of file | 83 | * link:https://www.youtube.com/watch?v=wni5h5vIPhU[From Zero to Async in Embedded Rust] |
