diff --git a/embedded-examples/stm32f3-disco-rtic/README.md b/embedded-examples/stm32f3-disco-rtic/README.md index 57ed964..32a1935 100644 --- a/embedded-examples/stm32f3-disco-rtic/README.md +++ b/embedded-examples/stm32f3-disco-rtic/README.md @@ -35,7 +35,7 @@ the correct name. This is so that the config file can be updated or edited for c without being tracked by git. ```sh -cp def_config.toml config.toml +cp .cargo/config.toml.template .cargo/config.toml ``` The configuration file will also set the target so it does not always have to be specified with @@ -74,41 +74,33 @@ to automatically rebuild and flash your application. The `tasks.json` and `launch.json` files are generic and you can use them immediately by opening the folder in VS code or adding it to a workspace. -## Commanding with Python +## Commanding the board -When the SW is running on the Discovery board, you can command the MCU via a serial interface, -using COBS encoded PUS packets. - -It is recommended to use a virtual environment to do this. To set up one in the command line, -you can use `python3 -m venv venv` on Unix systems or `py -m venv venv` on Windows systems. -After doing this, you can check the [venv tutorial](https://docs.python.org/3/tutorial/venv.html) -on how to activate the environment and then use the following command to install the required -dependency: - -```sh -pip install -r requirements.txt -``` +When the software is running on the Discovery board, you can command the MCU via a serial +interface. The telecommands are CCSDS space packets with a [`postcard`](https://docs.rs/postcard) +serialized payload, using [COBS](https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing) +as the packet framing format. The packets are exchanged using a dedicated serial interface. You can use any generic USB-to-UART converter device with the TX pin connected to the PA3 pin and the RX pin connected to the PA2 pin. -A default configuration file for the python application is provided and can be used by running +The [`embedded-client`](../embedded-client) application is used to command the board. Set the +serial port of your USB-to-UART converter inside `embedded-client/config.toml`: -```sh -cp def_tmtc_conf.json tmtc_conf.json +```toml +[interface] +serial_port = "/dev/ttyUSB0" ``` -After that, you can for example send a ping to the MCU using the following command +Then run the client from inside the `embedded-client` directory. For example, you can send a ping +to the MCU using ```sh -./main.py -p /ping +cargo run --bin stm32f3-client -- --ping ``` -You can configure the blinky frequency using +and set the LED blink frequency to 500 ms using ```sh -./main.py -p /change_blink_freq +cargo run --bin stm32f3-client -- --set-led-frequency 500 ``` - -All these commands will package a PUS telecommand which will be sent to the MCU using the COBS -format as the packet framing format. diff --git a/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template b/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template new file mode 100644 index 0000000..f01cbee --- /dev/null +++ b/embedded-examples/stm32h7-nucleo-rtic/.cargo/config.toml.template @@ -0,0 +1,29 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +runner = "probe-rs run --chip STM32H753ZITx" +# runner = ["probe-rs", "run", "--chip", "$CHIP", "--log-format", "{L} {s}"] + +rustflags = [ + "-C", "linker=flip-link", + "-C", "link-arg=-Tlink.x", + "-C", "link-arg=-Tdefmt.x", + # This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x + # See https://github.com/rust-embedded/cortex-m-quickstart/pull/95 + "-C", "link-arg=--nmagic", + # Can be useful for debugging. + # "-Clink-args=-Map=app.map" +] + +[build] +# (`thumbv6m-*` is compatible with all ARM Cortex-M chips but using the right +# target improves performance) +# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+ +# target = "thumbv7m-none-eabi" # Cortex-M3 +# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU) +target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) + +[alias] +rb = "run --bin" +rrb = "run --release --bin" + +[env] +DEFMT_LOG = "info" diff --git a/embedded-examples/stm32h7-nucleo-rtic/.gitignore b/embedded-examples/stm32h7-nucleo-rtic/.gitignore index c2bb1e7..54f6671 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/.gitignore +++ b/embedded-examples/stm32h7-nucleo-rtic/.gitignore @@ -1,4 +1,4 @@ /target -/.cargo/config* +/.cargo/config.toml /.vscode /app.map diff --git a/embedded-examples/stm32h7-nucleo-rtic/Cargo.lock b/embedded-examples/stm32h7-nucleo-rtic/Cargo.lock index 36b406c..b7f77fd 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/Cargo.lock +++ b/embedded-examples/stm32h7-nucleo-rtic/Cargo.lock @@ -303,23 +303,15 @@ dependencies = [ "litrs", ] -[[package]] -name = "dsp-fixedpoint" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb62c4b76dcbb298300dbc74a3ecd9fc0e180b806500bd5b1fc53ec85c0f27cd" -dependencies = [ - "num-traits", -] - [[package]] name = "embassy-embedded-hal" version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0641612053b2f34fc250bb63f6630ae75de46e02ade7f457268447081d709ce" dependencies = [ "defmt 1.1.0", "embassy-futures", - "embassy-hal-internal", + "embassy-hal-internal 0.4.0", "embassy-sync", "embassy-time", "embedded-hal 0.2.7", @@ -333,17 +325,29 @@ dependencies = [ [[package]] name = "embassy-executor-timer-queue" version = "0.1.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc328bf943af66b80b98755db9106bf7e7471b0cf47dc8559cd9a6be504cc9c" [[package]] name = "embassy-futures" version = "0.1.2" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc2d050bdc5c21e0862a89256ed8029ae6c290a93aecefc73084b3002cdebb01" + +[[package]] +name = "embassy-hal-internal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f10ce10a4dfdf6402d8e9bd63128986b96a736b1a0a6680547ed2ac55d55dba" +dependencies = [ + "num-traits", +] [[package]] name = "embassy-hal-internal" version = "0.5.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "568659fc53866d3d85c60fa33723fb751aa69e71507634fc2c19e7649432fb75" dependencies = [ "cortex-m", "critical-section", @@ -354,14 +358,15 @@ dependencies = [ [[package]] name = "embassy-net" version = "0.9.1" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "347bc855bdbdf50ed9c5a1d80e8204badb0ba149b8732dde38e1e9708ed9d313" dependencies = [ "defmt 1.1.0", "document-features", "embassy-net-driver", "embassy-sync", "embassy-time", - "embedded-io-async", + "embedded-io-async 0.7.0", "embedded-nal-async", "heapless 0.9.3", "managed", @@ -371,15 +376,17 @@ dependencies = [ [[package]] name = "embassy-net-driver" version = "0.2.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524eb3c489760508f71360112bca70f6e53173e6fe48fc5f0efd0f5ab217751d" dependencies = [ - "defmt 1.1.0", + "defmt 0.3.100", ] [[package]] name = "embassy-stm32" version = "0.6.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "486c0622deb5a519fc4d2cb8e3ef324f7568fcdfff201ff8fcab46557d663ceb" dependencies = [ "aligned", "bit_field", @@ -391,10 +398,9 @@ dependencies = [ "critical-section", "defmt 1.1.0", "document-features", - "dsp-fixedpoint", "embassy-embedded-hal", "embassy-futures", - "embassy-hal-internal", + "embassy-hal-internal 0.5.0", "embassy-net-driver", "embassy-sync", "embassy-time", @@ -407,8 +413,8 @@ dependencies = [ "embedded-hal 1.0.0", "embedded-hal-async", "embedded-hal-nb", - "embedded-io", - "embedded-io-async", + "embedded-io 0.7.1", + "embedded-io-async 0.7.0", "embedded-storage", "embedded-storage-async", "futures-util", @@ -416,14 +422,12 @@ dependencies = [ "nb 1.1.0", "proc-macro2", "quote", - "rand_core 0.10.1", "rand_core 0.6.4", "rand_core 0.9.5", "regex", "sdio-host", "static_assertions", "stm32-fmc", - "stm32-hrtim", "stm32-metapac", "trait-set", "vcell", @@ -433,12 +437,13 @@ dependencies = [ [[package]] name = "embassy-sync" version = "0.8.0" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bbd85cf5a5ae56bdf26f618364af642d1d0a4e245cdd75cd9aabda382f65a81" dependencies = [ "cfg-if", "critical-section", "defmt 1.1.0", - "embedded-io-async", + "embedded-io-async 0.7.0", "futures-core", "futures-sink", "heapless 0.9.3", @@ -447,7 +452,8 @@ dependencies = [ [[package]] name = "embassy-time" version = "0.5.1" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "592b0c143ec626e821d4d90da51a2bd91d559d6c442b7c74a47d368c9e23d97a" dependencies = [ "cfg-if", "critical-section", @@ -464,7 +470,8 @@ dependencies = [ [[package]] name = "embassy-time-driver" version = "0.2.2" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee71af1b3a0deaa53eaf2d39252f83504c853646e472400b763060389b9fcc9" dependencies = [ "document-features", ] @@ -472,7 +479,8 @@ dependencies = [ [[package]] name = "embassy-time-queue-utils" version = "0.3.2" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168297bf80aaf114b3c9ad589bf38b01b3009b9af7f97cd18086c5bbf96f5693" dependencies = [ "embassy-executor-timer-queue", "heapless 0.9.3", @@ -480,17 +488,20 @@ dependencies = [ [[package]] name = "embassy-usb-driver" -version = "0.2.1" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa675c5f4349b6aa0fcffc4bf9b241f18cd11b97c1f8323273fb9a5449937fbd" dependencies = [ "defmt 1.1.0", - "embedded-io-async", + "embedded-io-async 0.6.1", + "embedded-io-async 0.7.0", ] [[package]] name = "embassy-usb-synopsys-otg" version = "0.3.3" -source = "git+https://github.com/embassy-rs/embassy.git?rev=dd8e4c14e53f088bae27c5d841ab7a4fa338a52c#dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb205e26d59e483e8c48f91f637ec217ec7e2cfb0b61d50482301b991b4ff431" dependencies = [ "critical-section", "defmt 1.1.0", @@ -556,6 +567,12 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "embedded-io" version = "0.7.1" @@ -565,6 +582,15 @@ dependencies = [ "defmt 1.1.0", ] +[[package]] +name = "embedded-io-async" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ff09972d4073aa8c299395be75161d582e7629cd663171d62af73c8d50dba3f" +dependencies = [ + "embedded-io 0.6.1", +] + [[package]] name = "embedded-io-async" version = "0.7.0" @@ -572,7 +598,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2564b9f813c544241430e147d8bc454815ef9ac998878d30cc3055449f7fd4c0" dependencies = [ "defmt 1.1.0", - "embedded-io", + "embedded-io 0.7.1", ] [[package]] @@ -590,7 +616,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5a1bd585135d302f8f6d7de329310938093da6271b37a6c94b8798795c0c6d" dependencies = [ - "embedded-io-async", + "embedded-io-async 0.7.0", "embedded-nal", ] @@ -626,15 +652,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" -[[package]] -name = "fugit" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e639847d312d9a82d2e75b0edcc1e934efcc64e6cb7aa94f0b1fbec0bc231d6" -dependencies = [ - "gcd", -] - [[package]] name = "futures-core" version = "0.3.32" @@ -664,12 +681,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "gcd" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d758ba1b47b00caf47f24925c0074ecb20d6dfcffe7f6d53395c0465674841a" - [[package]] name = "hash32" version = "0.2.1" @@ -735,12 +746,6 @@ version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" -[[package]] -name = "libm" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" - [[package]] name = "linked_list_allocator" version = "0.10.6" @@ -796,7 +801,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -912,12 +916,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -[[package]] -name = "rand_core" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" - [[package]] name = "regex" version = "1.12.3" @@ -1182,36 +1180,17 @@ dependencies = [ "embedded-hal 1.0.0", ] -[[package]] -name = "stm32-hrtim" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee749ac0511b9977bcd5d508641bae0045964e861a4dc3fb40131f2e8aeb0360" -dependencies = [ - "fugit", - "stm32h7", -] - [[package]] name = "stm32-metapac" version = "21.0.0" -source = "git+https://github.com/embassy-rs/stm32-data-generated?tag=stm32-data-fe91bec726df47c6467dafce3fcf64075f662a3c#1569e3dc33adb6924329da79ef7dc8ce64bc791d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74b78632cea498cfb28386a29f8bfae7476d6570a78733eb5fecbee66c2f4ce" dependencies = [ "cortex-m", "cortex-m-rt", "defmt 0.3.100", ] -[[package]] -name = "stm32h7" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55e8634413ba08452b793b2f0f8574edd801a65b24c7f3cdce8034eef1359db4" -dependencies = [ - "cortex-m", - "vcell", -] - [[package]] name = "svgbobdoc" version = "0.3.0" diff --git a/embedded-examples/stm32h7-nucleo-rtic/Cargo.toml b/embedded-examples/stm32h7-nucleo-rtic/Cargo.toml index 5271a72..11b3ab3 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/Cargo.toml +++ b/embedded-examples/stm32h7-nucleo-rtic/Cargo.toml @@ -27,11 +27,10 @@ rtic = { version = "2", features = ["thumbv7-backend"] } spacepackets = { version = "0.18", default-features = false, features = ["defmt"] } postcard = "1" -embassy-stm32 = { git = "https://github.com/embassy-rs/embassy.git", rev = "dd8e4c14e53f088bae27c5d841ab7a4fa338a52c", version = "0.6", features = ["stm32h743zi", "memory-x", "defmt", "time-driver-any"]} - -embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "dd8e4c14e53f088bae27c5d841ab7a4fa338a52c", version = "0.5", features = ["defmt-timestamp-uptime-ms", "generic-queue-16"] } -embassy-net = { git = "https://github.com/embassy-rs/embassy.git", rev = "dd8e4c14e53f088bae27c5d841ab7a4fa338a52c", version = "0.9", features = ["medium-ethernet", "proto-ipv4", "tcp", "udp", "auto-icmp-echo-reply", "dhcpv4", "defmt"] } -embassy-sync = { git = "https://github.com/embassy-rs/embassy.git", rev = "dd8e4c14e53f088bae27c5d841ab7a4fa338a52c" } +embassy-stm32 = { version = "0.6", features = ["stm32h753zi", "memory-x", "defmt", "time-driver-any"] } +embassy-time = { version = "0.5", features = ["defmt-timestamp-uptime-ms", "generic-queue-16"] } +embassy-net = { version = "0.9", features = ["medium-ethernet", "proto-ipv4", "tcp", "udp", "auto-icmp-echo-reply", "dhcpv4", "defmt"] } +embassy-sync = "0.8" [dev-dependencies] defmt-test = "0.5" diff --git a/embedded-examples/stm32h7-nucleo-rtic/README.md b/embedded-examples/stm32h7-nucleo-rtic/README.md index 63fcaaa..35bba02 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/README.md +++ b/embedded-examples/stm32h7-nucleo-rtic/README.md @@ -1,4 +1,4 @@ -sat-rs example for the STM32H73ZI-Nucleo board +sat-rs example for the STM32H753ZI-Nucleo board ======= This example application shows how the [sat-rs library](https://egit.irs.uni-stuttgart.de/rust/sat-rs) @@ -7,9 +7,9 @@ It also shows how a relatively simple OBSW could be built when no standard runti It uses [RTIC](https://rtic.rs/2/book/en/) as the concurrency framework and the [defmt](https://defmt.ferrous-systems.com/) framework for logging. -The STM32H743ZIT device was picked because it is one of the more powerful Cortex-M based devices -available for STM with which also has a little bit more RAM available and also allows commanding -via TCP/IP. +The STM32H753ZIT device was picked because it is one of the more powerful Cortex-M based STM32 +devices. It has more RAM available and allows commanding via Ethernet. The example is written for +the NUCLEO-H753ZI board, which uses the MB1364 Nucleo-144 board layout. ## Pre-Requisites @@ -29,15 +29,19 @@ If you have not installed it yet, you can do so with rustup target add thumbv7em-none-eabihf ``` -A default `.cargo` config file is provided for this project, but needs to be copied to have -the correct name. This is so that the config file can be updated or edited for custom needs -without being tracked by git. +A default `.cargo` config file is provided as `.cargo/config.toml.template`. The build script +copies it to `.cargo/config.toml` if that file does not exist yet. The copy is not tracked by git, +so you can change settings like the runner for your setup. + +Cargo reads the configuration before the build script runs, so the very first build on a fresh +checkout does not use it yet and might fail. Simply run the build again, or copy the file +manually beforehand: ```sh -cp def_config.toml config.toml +cp .cargo/config.toml.template .cargo/config.toml ``` -The configuration file will also set the target so it does not always have to be specified with +The configuration file also sets the target so it does not always have to be specified with the `--target` argument. ## Building @@ -54,13 +58,13 @@ cargo build You can flash the application from the command line using `probe-rs`: ```sh -probe-rs run --chip STM32H743ZITx +probe-rs run --chip STM32H753ZITx ``` ## Debugging with VS Code -The STM32F3-Discovery comes with an on-board ST-Link so all that is required to flash and debug -the board is a Mini-USB cable. The code in this repository was debugged using [`probe-rs`](https://probe.rs/docs/tools/debuggerA) +The Nucleo board comes with an on-board ST-Link so all that is required to flash and debug +the board is a USB cable. The code in this repository was debugged using [`probe-rs`](https://probe.rs/docs/tools/debuggerA) and the VS Code [`probe-rs` plugin](https://marketplace.visualstudio.com/items?itemName=probe-rs.probe-rs-debugger). Make sure to install this plugin first. @@ -73,44 +77,37 @@ to automatically rebuild and flash your application. The `tasks.json` and `launch.json` files are generic and you can use them immediately by opening the folder in VS code or adding it to a workspace. -## Commanding with Python +## Commanding the board -When the SW is running on the Discovery board, you can command the MCU via a serial interface, -using COBS encoded PUS packets. +The board is commanded via UDP on port 7301. It gets its IP address via DHCP, so it needs to be +connected to a network with a DHCP server. The network configuration including the IP address is +logged after startup. According to the board user manual UM2407, jumper JP6 and solder bridge SB72 +must be ON when using Ethernet. The telecommands are CCSDS space packets with a +[`postcard`](https://docs.rs/postcard) serialized payload. -It is recommended to use a virtual environment to do this. To set up one in the command line, -you can use `python3 -m venv venv` on Unix systems or `py -m venv venv` on Windows systems. -After doing this, you can check the [venv tutorial](https://docs.python.org/3/tutorial/venv.html) -on how to activate the environment and then use the following command to install the required -dependency: +The [`embedded-client`](../embedded-client) application is used to command the board. Set the +address of the board inside `embedded-client/config.toml`, for example: -```sh -pip install -r requirements.txt +```toml +[interface] +udp_addr = "192.168.1.50:7301" ``` -The packets are exchanged using a dedicated serial interface. You can use any generic USB-to-UART -converter device with the TX pin connected to the PA3 pin and the RX pin connected to the PA2 pin. - -A default configuration file for the python application is provided and can be used by running +Then run the client from inside the `embedded-client` directory. For example, you can send a ping +to the MCU using ```sh -cp def_tmtc_conf.json tmtc_conf.json +cargo run --bin stm32h7-client -- --ping ``` -After that, you can for example send a ping to the MCU using the following command +and set the LED blink frequency to 500 ms using ```sh -./main.py -p /ping +cargo run --bin stm32h7-client -- --set-led-frequency 500 ``` -You can configure the blinky frequency using - -```sh -./main.py -p /change_blink_freq -``` - -All these commands will package a PUS telecommand which will be sent to the MCU using the COBS -format as the packet framing format. +You can also pass the board address with `--udp-addr` instead of setting it inside the +configuration file. ## Resources diff --git a/embedded-examples/stm32h7-nucleo-rtic/build.rs b/embedded-examples/stm32h7-nucleo-rtic/build.rs index 5f7e192..93b7aa1 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/build.rs +++ b/embedded-examples/stm32h7-nucleo-rtic/build.rs @@ -3,7 +3,7 @@ use std::{env, fs}; fn main() { let manifest_dir = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap()); - let cargo_dir = manifest_dir.parent().unwrap().join(".cargo"); + let cargo_dir = manifest_dir.join(".cargo"); let config = cargo_dir.join("config.toml"); let config_template = cargo_dir.join("config.toml.template"); diff --git a/embedded-examples/stm32h7-nucleo-rtic/docs/stm32h743bi.pdf b/embedded-examples/stm32h7-nucleo-rtic/docs/stm32h743bi.pdf deleted file mode 100644 index 0a8f77c..0000000 Binary files a/embedded-examples/stm32h7-nucleo-rtic/docs/stm32h743bi.pdf and /dev/null differ diff --git a/embedded-examples/stm32h7-nucleo-rtic/docs/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf b/embedded-examples/stm32h7-nucleo-rtic/docs/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf deleted file mode 100644 index 57d4957..0000000 Binary files a/embedded-examples/stm32h7-nucleo-rtic/docs/um1974-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf and /dev/null differ diff --git a/embedded-examples/stm32h7-nucleo-rtic/docs/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf b/embedded-examples/stm32h7-nucleo-rtic/docs/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf new file mode 100644 index 0000000..f7f9452 Binary files /dev/null and b/embedded-examples/stm32h7-nucleo-rtic/docs/um2407-stm32h7-nucleo144-boards-mb1364-stmicroelectronics.pdf differ diff --git a/embedded-examples/stm32h7-nucleo-rtic/src/bin/blinky.rs b/embedded-examples/stm32h7-nucleo-rtic/src/bin/blinky.rs index b7388ea..68e9bc1 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/src/bin/blinky.rs +++ b/embedded-examples/stm32h7-nucleo-rtic/src/bin/blinky.rs @@ -1,7 +1,8 @@ //! Blinks an LED //! -//! This assumes that LD2 (blue) is connected to pb7 and LD3 (red) is connected -//! to pb14. This assumption is true for the nucleo-h743zi board. +//! This assumes that LD1 (green) is connected to PB0, LD2 (yellow) to PE1 and LD3 (red) to +//! PB14. This assumption is true for the MB1364 Nucleo-144 board, for example the +//! NUCLEO-H753ZI. #![no_std] #![no_main] @@ -24,7 +25,7 @@ mod app { defmt::info!("Hello World!"); // Configure gpio B pin 0 as a push-pull output. let ld1 = gpio::Output::new(p.PB0, gpio::Level::High, gpio::Speed::Low); - let ld2 = gpio::Output::new(p.PB7, gpio::Level::High, gpio::Speed::Low); + let ld2 = gpio::Output::new(p.PE1, gpio::Level::High, gpio::Speed::Low); let ld3 = gpio::Output::new(p.PB14, gpio::Level::High, gpio::Speed::Low); // Schedule the blinking task diff --git a/embedded-examples/stm32h7-nucleo-rtic/src/main.rs b/embedded-examples/stm32h7-nucleo-rtic/src/main.rs index 3886e5f..20526dd 100644 --- a/embedded-examples/stm32h7-nucleo-rtic/src/main.rs +++ b/embedded-examples/stm32h7-nucleo-rtic/src/main.rs @@ -51,7 +51,7 @@ mod app { bind_interrupts!(struct Irqs { ETH => eth::InterruptHandler; - RNG => rng::InterruptHandler; + HASH_RNG => rng::InterruptHandler; }); type Device = eth::Ethernet< @@ -105,35 +105,34 @@ mod app { #[init] fn init(_cx: init::Context) -> (Shared, Local) { - defmt::println!("Starting sat-rs demo application for the STM32H743ZIT"); + defmt::println!("Starting sat-rs demo application for the STM32H753ZIT"); let mut config = embassy_stm32::Config::default(); { use embassy_stm32::rcc::*; - config.rcc.hsi = Some(HSIPrescaler::Div1); + config.rcc.hsi = Some(HSIPrescaler::DIV1); config.rcc.csi = true; config.rcc.hsi48 = Some(Default::default()); // needed for RNG config.rcc.pll1 = Some(Pll { - source: PllSource::Hsi, - prediv: PllPreDiv::Div4, - mul: PllMul::Mul50, - fracn: None, - divp: Some(PllDiv::Div2), + source: PllSource::HSI, + prediv: PllPreDiv::DIV4, + mul: PllMul::MUL50, + divp: Some(PllDiv::DIV2), divq: None, divr: None, }); - config.rcc.sys = Sysclk::Pll1P; // 400 Mhz - config.rcc.ahb_pre = AHBPrescaler::Div2; // 200 Mhz - config.rcc.apb1_pre = APBPrescaler::Div2; // 100 Mhz - config.rcc.apb2_pre = APBPrescaler::Div2; // 100 Mhz - config.rcc.apb3_pre = APBPrescaler::Div2; // 100 Mhz - config.rcc.apb4_pre = APBPrescaler::Div2; // 100 Mhz + config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz + config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz + config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz + config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz + config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz + config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz config.rcc.voltage_scale = VoltageScale::Scale1; } let periphs = embassy_stm32::init(config); let link_led = gpio::Output::new(periphs.PB0, gpio::Level::Low, gpio::Speed::Medium); - let mut led1 = gpio::Output::new(periphs.PB7, gpio::Level::Low, gpio::Speed::Medium); + let mut led1 = gpio::Output::new(periphs.PE1, gpio::Level::Low, gpio::Speed::Medium); let mut led2 = gpio::Output::new(periphs.PB14, gpio::Level::Low, gpio::Speed::Medium); // Criss-cross pattern looks cooler.