aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-05-11 22:48:55 +0000
committerGitHub <[email protected]>2023-05-11 22:48:55 +0000
commit7f96359804b5f2bb3248cb7c0e1bab30e9135a41 (patch)
tree153a60a3813fce4335fada366ecea76d1735aec2 /examples
parente179e7cf85810f0aa7ef8027d8d48f6d21f64dac (diff)
parentbf45b1d83dba837dabc63361dc472902ab82cda4 (diff)
Merge #1424
1424: add TL maibox for stm32wb r=xoviat a=OueslatiGhaith Hello, This pull request is related to #1397 and #1401, inspired by #24, build upon the work done in #1405, and was tested on an stm32wb55rg. This pull request aims to add the transport layer mailbox for stm32wb microcontrollers. For now it's only capable of initializing it and getting the firmware information Co-authored-by: goueslati <[email protected]> Co-authored-by: Ghaith Oueslati <[email protected]> Co-authored-by: xoviat <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wb/.cargo/config.toml3
-rw-r--r--examples/stm32wb/Cargo.toml2
-rw-r--r--examples/stm32wb/memory.x32
-rw-r--r--examples/stm32wb/src/bin/tl_mbox.rs68
4 files changed, 84 insertions, 21 deletions
diff --git a/examples/stm32wb/.cargo/config.toml b/examples/stm32wb/.cargo/config.toml
index 5d78d79e5..d23fdc513 100644
--- a/examples/stm32wb/.cargo/config.toml
+++ b/examples/stm32wb/.cargo/config.toml
@@ -1,6 +1,7 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))'] 1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2# replace STM32WB55CCUx with your chip as listed in `probe-rs-cli chip list` 2# replace STM32WB55CCUx with your chip as listed in `probe-rs-cli chip list`
3runner = "probe-rs-cli run --chip STM32WB55CCUx --speed 1000 --connect-under-reset" 3# runner = "probe-rs-cli run --chip STM32WB55CCUx --speed 1000 --connect-under-reset"
4runner = "teleprobe local run --chip STM32WB55RG --elf"
4 5
5[build] 6[build]
6target = "thumbv7em-none-eabihf" 7target = "thumbv7em-none-eabihf"
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml
index db1816da3..3c7e3e874 100644
--- a/examples/stm32wb/Cargo.toml
+++ b/examples/stm32wb/Cargo.toml
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
8embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } 8embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
9embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 9embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
10embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } 10embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } 11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "exti"] }
12 12
13defmt = "0.3" 13defmt = "0.3"
14defmt-rtt = "0.4" 14defmt-rtt = "0.4"
diff --git a/examples/stm32wb/memory.x b/examples/stm32wb/memory.x
index 0e48c916d..5a07b7d19 100644
--- a/examples/stm32wb/memory.x
+++ b/examples/stm32wb/memory.x
@@ -10,6 +10,17 @@ MEMORY
10 RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K 10 RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K
11} 11}
12 12
13/*
14 Memory size for STM32WB55xC with 512K FLASH
15
16 MEMORY
17 {
18 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K
19 RAM (xrw) : ORIGIN = 0x20000008, LENGTH = 0x2FFF8
20 RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K
21 }
22*/
23
13/* Place stack at the end of SRAM1 */ 24/* Place stack at the end of SRAM1 */
14_stack_start = ORIGIN(RAM) + LENGTH(RAM); 25_stack_start = ORIGIN(RAM) + LENGTH(RAM);
15 26
@@ -19,23 +30,6 @@ _stack_start = ORIGIN(RAM) + LENGTH(RAM);
19SECTIONS { 30SECTIONS {
20 TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED 31 TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED
21 32
22 TL_DEVICE_INFO_TABLE 0x2003001c (NOLOAD) : { *(TL_DEVICE_INFO_TABLE) } >RAM_SHARED 33 MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED
23 TL_BLE_TABLE 0x2003003c (NOLOAD) : { *(TL_BLE_TABLE) } >RAM_SHARED 34 MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED
24 TL_THREAD_TABLE 0x2003004c (NOLOAD) : { *(TL_THREAD_TABLE) } >RAM_SHARED
25 TL_SYS_TABLE 0x20030058 (NOLOAD) : { *(TL_SYS_TABLE) } >RAM_SHARED
26 TL_MEM_MANAGER_TABLE 0x20030060 (NOLOAD) : { *(TL_MEM_MANAGER_TABLE) } >RAM_SHARED
27 TL_TRACES_TABLE 0x2003007c (NOLOAD) : { *(TL_TRACES_TABLE) } >RAM_SHARED
28 TL_MAC_802_15_4_TABLE 0x20030080 (NOLOAD) : { *(TL_MAC_802_15_4_TABLE) } >RAM_SHARED
29
30 HCI_ACL_DATA_BUFFER 0x20030a08 (NOLOAD) : { *(HCI_ACL_DATA_BUFFER) } >RAM_SHARED
31 BLE_CMD_BUFFER 0x200308fc (NOLOAD) : { *(BLE_CMD_BUFFER) } >RAM_SHARED
32 BLE_SPARE_EVT_BUF 0x200301a8 (NOLOAD) : { *(BLE_SPARE_EVT_BUF) } >RAM_SHARED
33 SYS_SPARE_EVT_BUF 0x200302b4 (NOLOAD) : { *(SYS_SPARE_EVT_BUF) } >RAM_SHARED
34 EVT_POOL 0x200303c0 (NOLOAD) : { *(EVT_POOL) } >RAM_SHARED
35 SYS_CMD_BUF 0x2003009c (NOLOAD) : { *(SYS_CMD_BUF) } >RAM_SHARED
36 SYSTEM_EVT_QUEUE 0x20030b28 (NOLOAD) : { *(SYSTEM_EVT_QUEUE) } >RAM_SHARED
37 EVT_QUEUE 0x20030b10 (NOLOAD) : { *(EVT_QUEUE) } >RAM_SHARED
38 CS_BUFFER 0x20030b18 (NOLOAD) : { *(CS_BUFFER) } >RAM_SHARED
39 TRACES_EVT_QUEUE 0x20030094 (NOLOAD) : { *(TRACES_EVT_QUEUE) } >RAM_SHARED
40 FREE_BUF_QUEUE 0x2003008c (NOLOAD) : { *(FREE_BUF_QUEUE) } >RAM_SHARED
41} 35}
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs
new file mode 100644
index 000000000..6876526ae
--- /dev/null
+++ b/examples/stm32wb/src/bin/tl_mbox.rs
@@ -0,0 +1,68 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::ipcc::{Config, Ipcc};
8use embassy_stm32::tl_mbox::TlMbox;
9use embassy_time::{Duration, Timer};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 /*
15 How to make this work:
16
17 - Obtain a NUCLEO-STM32WB55 from your preferred supplier.
18 - Download and Install STM32CubeProgrammer.
19 - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from
20 gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x
21 - Open STM32CubeProgrammer
22 - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware.
23 - Once complete, click connect to connect to the device.
24 - On the left hand pane, click the RSS signal icon to open "Firmware Upgrade Services".
25 - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file
26 - Select that file, the memory address, "verify download", and then "Firmware Upgrade".
27 - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the
28 stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address.
29 - Select that file, the memory address, "verify download", and then "Firmware Upgrade".
30 - Disconnect from the device.
31 - In the examples folder for stm32wb, modify the memory.x file to match your target device.
32 - Run this example.
33
34 Note: extended stack versions are not supported at this time. Do not attempt to install a stack with "extended" in the name.
35 */
36
37 let p = embassy_stm32::init(Default::default());
38 info!("Hello World!");
39
40 let config = Config::default();
41 let mut ipcc = Ipcc::new(p.IPCC, config);
42
43 let mbox = TlMbox::init(&mut ipcc);
44
45 loop {
46 let wireless_fw_info = mbox.wireless_fw_info();
47 match wireless_fw_info {
48 None => error!("not yet initialized"),
49 Some(fw_info) => {
50 let version_major = fw_info.version_major();
51 let version_minor = fw_info.version_minor();
52 let subversion = fw_info.subversion();
53
54 let sram2a_size = fw_info.sram2a_size();
55 let sram2b_size = fw_info.sram2b_size();
56
57 info!(
58 "version {}.{}.{} - SRAM2a {} - SRAM2b {}",
59 version_major, version_minor, subversion, sram2a_size, sram2b_size
60 );
61
62 break;
63 }
64 }
65
66 Timer::after(Duration::from_millis(500)).await;
67 }
68}