From f0ebfc94e419d62da8c895746f051a1fe7ec13f7 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Sat, 10 Jun 2023 09:49:47 +0800 Subject: [PATCH 1/6] check CARGO_HOME env var --- Makefile.toml | 7 ++++--- scripts/tool_install.sh | 19 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 295f459ed..0417380f0 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,5 +1,4 @@ -env_scripts = [ -''' +env_scripts = [''' #!@duckscript crates = get_env CRATES crates = array %{crates} @@ -318,4 +317,6 @@ script = "rm -r .deps" [env] PYTHON = { value = "python3", condition = { env_not_set = ["PYTHON"] } } SVDTOOLS = { value = "svdtools", condition = { env_not_set = ["SVDTOOLS"] } } -CRATES = { value = "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h5 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32wl stm32wb stm32u5", condition = { env_not_set = ["CRATES"] } } +CRATES = { value = "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h5 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32wl stm32wb stm32u5", condition = { env_not_set = [ + "CRATES", +] } } diff --git a/scripts/tool_install.sh b/scripts/tool_install.sh index bfac2a728..d054175ff 100755 --- a/scripts/tool_install.sh +++ b/scripts/tool_install.sh @@ -29,26 +29,29 @@ case "${1:-}" in ;; esac +# check CARGO_HOME env var +CARGO_BIN_DIR="${CARGO_HOME:-${HOME}/.cargo}/bin" + if [ "${form:-}" ]; then echo "form = ${form}" - curl -sSfL https://github.com/djmcgill/form/releases/download/$form/form-x86_64-unknown-linux-gnu.gz | gzip -d - > ~/.cargo/bin/form - chmod +x ~/.cargo/bin/form + curl -sSfL https://github.com/djmcgill/form/releases/download/$form/form-x86_64-unknown-linux-gnu.gz | gzip -d - > "${CARGO_BIN_DIR}/form" + chmod +x "${CARGO_BIN_DIR}/form" fi if [ "${svdtools:-}" ]; then echo "svdtools = ${svdtools}" - curl -sSfL https://github.com/stm32-rs/svdtools/releases/download/$svdtools/svdtools-x86_64-unknown-linux-gnu.gz | gzip -d - > ~/.cargo/bin/svdtools - chmod +x ~/.cargo/bin/svdtools + curl -sSfL https://github.com/stm32-rs/svdtools/releases/download/$svdtools/svdtools-x86_64-unknown-linux-gnu.gz | gzip -d - > "${CARGO_BIN_DIR}/svdtools" + chmod +x "${CARGO_BIN_DIR}/svdtools" fi if [ "${svd2rust:-}" ]; then echo "svd2rust = ${svd2rust}" - curl -sSfL https://github.com/rust-embedded/svd2rust/releases/download/$svd2rust/svd2rust-x86_64-unknown-linux-gnu.gz | gzip -d - > ~/.cargo/bin/svd2rust - chmod +x ~/.cargo/bin/svd2rust + curl -sSfL https://github.com/rust-embedded/svd2rust/releases/download/$svd2rust/svd2rust-x86_64-unknown-linux-gnu.gz | gzip -d - > "${CARGO_BIN_DIR}/svd2rust" + chmod +x "${CARGO_BIN_DIR}/svd2rust" fi if [ "${svd2html:-}" ]; then echo "svd2html = ${svd2html}" - curl -sSfL https://github.com/burrbull/svd2html/releases/download/$svd2html/svd2html-x86_64-unknown-linux-gnu.gz | gzip -d - > ~/.cargo/bin/svd2html - chmod +x ~/.cargo/bin/svd2html + curl -sSfL https://github.com/burrbull/svd2html/releases/download/$svd2html/svd2html-x86_64-unknown-linux-gnu.gz | gzip -d - > "${CARGO_BIN_DIR}/svd2html" + chmod +x "${CARGO_BIN_DIR}/svd2html" fi From 15445fa9b2584450516f7725ec240453110ee001 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Sat, 10 Jun 2023 09:56:56 +0800 Subject: [PATCH 2/6] Update CHANGELOG.md for `CARGO_HOME` check --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c4cdf57..cb0f6961d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,10 @@ * Updated to svd2rust 0.29.0, svdtools 0.3.0, use tools binaries for CI * Enable atomic operations on register support, Rust edition 2021 (#846) * files in devices/common_patches moved to subdirectories +* check `CARGO_HOME` env var before put binary into default place ([#850]) * remove excutable file perm bit from yaml file ([#854]) +[#850]: https://github.com/stm32-rs/stm32-rs/pull/850 [#854]: https://github.com/stm32-rs/stm32-rs/pull/854 ## [v0.15.1] 2022-07-04 From 19c1b58dfcee35e2af064ef77d43d54b6af790f4 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Tue, 1 Aug 2023 22:47:46 +0800 Subject: [PATCH 3/6] Update svd2rust to 0.30.0 --- CHANGELOG.md | 5 +++- Makefile | 7 +++-- Makefile.toml | 66 ++++++++++++++++++++++++++++++++++------- README.md | 23 +++++++++----- scripts/makecrates.py | 2 +- scripts/tool_install.sh | 4 +-- 6 files changed, 83 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb0f6961d..50e7cd2f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,14 +3,17 @@ ## [Unreleased] * Replace `makehtml.py` with `svd2html` -* Updated to svd2rust 0.29.0, svdtools 0.3.0, use tools binaries for CI +* Updated to svd2rust 0.30.0, svdtools 0.3.0, use tools binaries for CI * Enable atomic operations on register support, Rust edition 2021 (#846) * files in devices/common_patches moved to subdirectories * check `CARGO_HOME` env var before put binary into default place ([#850]) * remove excutable file perm bit from yaml file ([#854]) +* `cargo make install` will install pre-build binary tools on windows ([#865]) +* bump up `svd2html` version to `v0.1.4` ([#865]) [#850]: https://github.com/stm32-rs/stm32-rs/pull/850 [#854]: https://github.com/stm32-rs/stm32-rs/pull/854 +[#865]: https://github.com/stm32-rs/stm32-rs/pull/865 ## [v0.15.1] 2022-07-04 diff --git a/Makefile b/Makefile index 68026f176..14f6b9b4b 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,9 @@ all: patch svd2rust SHELL := /usr/bin/env bash +# Path to `python3` executable binary +PYTHON ?= python3 + # Path to `svd`/`svdtools` SVDTOOLS ?= svdtools @@ -56,7 +59,7 @@ mmaps/%.mmap: svd/%.svd.patched # Generates the common crate files: Cargo.toml, build.rs, src/lib.rs, README.md crates: - python3 scripts/makecrates.py devices/ -y --families $(CRATES) + $(PYTHON) scripts/makecrates.py devices/ -y --families $(CRATES) define crate_template $(1)/src/%/mod.rs: svd/%.svd.patched $(1)/Cargo.toml @@ -138,7 +141,7 @@ clean: clean-rs clean-patch clean-html clean-svd # As alternative to `pip install --user svdtools`: # run `make venv update-venv` and `source venv/bin/activate' venv: - python3 -m venv venv + $(PYTHON) -m venv venv update-venv: venv/bin/pip install -U pip diff --git a/Makefile.toml b/Makefile.toml index 0417380f0..7031688e6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -34,8 +34,34 @@ FORMATTED_SVDS = trim ${FORMATTED_SVDS} set_env FORMATTED_SVDS ${FORMATTED_SVDS} RUST_DIRS = trim ${RUST_DIRS} set_env RUST_DIRS ${RUST_DIRS} + +cargo_home = get_env CARGO_HOME +if is_empty ${cargo_home} + set_env CARGO_BIN_DIR "${HOME}/bin" +else + set_env CARGO_BIN_DIR "${CARGO_HOME}/bin" +end '''] +[env] +PYTHON = { value = "python3", condition = { env_not_set = ["PYTHON"] } } +SVDTOOLS = { value = "svdtools", condition = { env_not_set = ["SVDTOOLS"] } } +FORM_VERSION = { value = "v0.10.0", condition = { env_not_set = [ + "FORM_VERSION", +] } } +SVDTOOLS_VERSION = { value = "v0.3.0", condition = { env_not_set = [ + "SVDTOOLS_VERSION", +] } } +SVD2RUST_VERSION = { value = "v0.30.0", condition = { env_not_set = [ + "SVD2RUST_VERSION", +] } } +SVD2HTML_VERSION = { value = "v0.1.4", condition = { env_not_set = [ + "SVD2HTML_VERSION", +] } } +CRATES = { value = "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h5 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32wl stm32wb stm32u5", condition = { env_not_set = [ + "CRATES", +] } } + [tasks.default] alias = "patch" @@ -48,6 +74,34 @@ install_crate = "svd2rust" [tasks.install] #dependencies = ["install_svdtools", "install_svd2rust"] command = "scripts/tool_install.sh" +windows_alias = "install_on_windows" +mac_alias = "not_yet_implemented" + +[tasks.install_on_windows] +script_runner = "@duckscript" +script = ''' +echo "download form ${FORM_VERSION}" +wget -O "${CARGO_BIN_DIR}/form.zip" "https://github.com/djmcgill/form/releases/download/${FORM_VERSION}/form-x86_64-pc-windows-msvc.zip" +echo download svdtools ${SVDTOOLS_VERSION} +wget -O "${CARGO_BIN_DIR}/svdtools.zip" "https://github.com/stm32-rs/svdtools/releases/download/${SVDTOOLS_VERSION}/svdtools-x86_64-pc-windows-msvc.zip" +echo download svd2rust ${SVD2RUST_VERSION} +wget -O "${CARGO_BIN_DIR}/svd2rust.exe" "https://github.com/rust-embedded/svd2rust/releases/download/${SVD2RUST_VERSION}/svd2rust-x86_64-pc-windows-msvc.exe" +echo download svd2html ${SVD2HTML_VERSION} +wget -O "${CARGO_BIN_DIR}/svd2html.exe" "https://github.com/burrbull/svd2html/releases/download/${SVD2HTML_VERSION}/svd2html-x86_64-pc-windows-msvc.exe" + +echo "unzip tools" + +rm "${CARGO_BIN_DIR}/form.exe" +unzip "${CARGO_BIN_DIR}/form.zip" "${CARGO_BIN_DIR}" + +rm "${CARGO_BIN_DIR}/svdtools.exe" +unzip "${CARGO_BIN_DIR}/svdtools.zip" "${CARGO_BIN_DIR}/svdtools" +mv "${CARGO_BIN_DIR}/svdtools/svdtools.exe" "${CARGO_BIN_DIR}/svdtools.exe" +rm -r "${CARGO_BIN_DIR}/svdtools" + +rm "${CARGO_BIN_DIR}/form.zip" +rm "${CARGO_BIN_DIR}/svdtools.zip" +''' [tasks.check-patched] env = { "CRATES" = "${CRATE_NAMES}", "NAMES" = "${NAMES}" } @@ -184,7 +238,7 @@ end [tasks.patch] env = { "SVDTOOLS" = "${SVDTOOLS}", "NAMES" = "${NAMES}" } -dependencies = ["deps", "extracted"] +dependencies = ["deps", "extract"] script_runner = "@duckscript" script = ''' NAMES = array %{NAMES} @@ -255,8 +309,7 @@ for serie in ${NAMES} end ''' -[tasks.extracted] -private = true +[tasks.extract] script_runner = "@duckscript" condition = { files_not_exist = ["svd/.extracted"] } script = { file = "svd/extract.ds" } @@ -313,10 +366,3 @@ rm svd/.extracted dependencies = ["clean-rs", "clean-patch", "clean-html", "clean-svd"] script_runner = "@duckscript" script = "rm -r .deps" - -[env] -PYTHON = { value = "python3", condition = { env_not_set = ["PYTHON"] } } -SVDTOOLS = { value = "svdtools", condition = { env_not_set = ["SVDTOOLS"] } } -CRATES = { value = "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h5 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32wl stm32wb stm32u5", condition = { env_not_set = [ - "CRATES", -] } } diff --git a/README.md b/README.md index 53958d971..a26124266 100644 --- a/README.md +++ b/README.md @@ -92,21 +92,28 @@ contain the latest patches and updates. ## Generating Device Crates / Building Locally +* Pre-requirements + * `Python3` + * `yaml` paraser for python: `pip install pyyaml` + * (Optional) install `cargo-make` if needed: `cargo install cargo-make` + * Note for using `cargo make`: if python3 executable isn't named as `python3`, or cannot be find in `PATH` + you can create a environment variable `PYTHON`, change its content to your python executable binary path * Install `svd2rust`, `svdtools`, and `form`: * On x86-64 Linux, run `make install` to download pre-built binaries at the current version used by stm32-rs + * On x86-64 Windows, run `cargo make install` to download pre-build binaries at the + current version used by stm32-rs * Otherwise, build using `cargo` (double check versions against `scripts/tool_install.sh`): * `cargo install form --version 0.10.0` * `cargo install svdtools --version 0.3.0` - * `cargo install svd2rust --version 0.29.0` - * `cargo install svd2html --version 0.1.3` + * `cargo install svd2rust --version 0.30.0` + * `cargo install svd2html --version 0.1.4` * Install rustfmt: `rustup component add rustfmt` * Generate patched SVD files: `make patch` (you probably want `-j` for all `make` invocations) * Alternatively you could install `cargo-make` runner and then use it instead of `make`. Works on MS Windows natively: - * `cargo install cargo-make` * `cargo make patch` -* Generate svd2rust device crates: `make svd2rust` -* Optional: Format device crates: `make form` +* Generate svd2rust device crates: `make svd2rust` / `cargo make svd2rust` +* Optional: Format device crates: `make form` / `cargo make form` ## Motivation and Objectives @@ -170,7 +177,7 @@ Check out the full list of supported devices [here](https://stm32-rs.github.io/s ## Adding New Devices * Update SVD zips in `svd/vendor` to include new SVDs. -* Run `make extract` to extract the new zip files. +* Run `make extract` / `cargo make extract` to extract the new zip files. * Add new YAML file in `devices/` with the new SVD path and include any required SVD patches for this device, such as renaming or merging fields. * Add the new devices to `stm32_part_table.yaml`. @@ -193,9 +200,9 @@ these steps as well: ## Updating Existing Devices/Peripherals -* Using Linux, run `make extract` at least once to pull the SVDs out. +* Run `make extract` / `cargo make extract` at least once to pull the SVDs out. * Edit the device or peripheral YAML (see below for format). -* Using Linux, run `make` to rebuild all the crates using `svd patch` and `svd2rust`. +* Run `make` / `cargo make` to rebuild all the crates using `svdtools` and `svd2rust`. * Test your new stuff compiles: `cd stm32f4; cargo build --features stm32f405` If you've added a new peripheral, consider using the `matchperipherals.py` diff --git a/scripts/makecrates.py b/scripts/makecrates.py index 47fc464c2..16a870015 100644 --- a/scripts/makecrates.py +++ b/scripts/makecrates.py @@ -17,7 +17,7 @@ import yaml VERSION = "0.15.1" -SVD2RUST_VERSION = "0.29.0" +SVD2RUST_VERSION = "0.30.0" CRATE_DOC_FEATURES = { "stm32c0": ["critical-section", "rt", "stm32c011", "stm32c031"], diff --git a/scripts/tool_install.sh b/scripts/tool_install.sh index d054175ff..1c117b2be 100755 --- a/scripts/tool_install.sh +++ b/scripts/tool_install.sh @@ -4,8 +4,8 @@ set -euo pipefail FORM_VERSION="${FORM_VERSION:-v0.10.0}" SVDTOOLS_VERSION="${SVDTOOLS_VERSION:-v0.3.0}" -SVD2RUST_VERSION="${SVD2RUST_VERSION:-v0.29.0}" -SVD2HTML_VERSION="${SVD2HTML_VERSION:-v0.1.3}" +SVD2RUST_VERSION="${SVD2RUST_VERSION:-v0.30.0}" +SVD2HTML_VERSION="${SVD2HTML_VERSION:-v0.1.4}" case "${1:-}" in form) From abe69735a96d32d0c8ce54a49ce5b5015cfea24f Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Wed, 2 Aug 2023 13:19:02 +0800 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50e7cd2f0..4e15837ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,12 +6,11 @@ * Updated to svd2rust 0.30.0, svdtools 0.3.0, use tools binaries for CI * Enable atomic operations on register support, Rust edition 2021 (#846) * files in devices/common_patches moved to subdirectories -* check `CARGO_HOME` env var before put binary into default place ([#850]) * remove excutable file perm bit from yaml file ([#854]) +* check `CARGO_HOME` env var before put binary into default place ([#865]) * `cargo make install` will install pre-build binary tools on windows ([#865]) * bump up `svd2html` version to `v0.1.4` ([#865]) -[#850]: https://github.com/stm32-rs/stm32-rs/pull/850 [#854]: https://github.com/stm32-rs/stm32-rs/pull/854 [#865]: https://github.com/stm32-rs/stm32-rs/pull/865 From a6793583942a4bcf0a1e6468a9cd4627516805bb Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Mon, 27 Nov 2023 23:03:44 +0800 Subject: [PATCH 5/6] catch up with master branch --- Makefile.toml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index 7bcaca78c..c73bde8f4 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -49,14 +49,14 @@ SVDTOOLS = { value = "svdtools", condition = { env_not_set = ["SVDTOOLS"] } } FORM_VERSION = { value = "v0.10.0", condition = { env_not_set = [ "FORM_VERSION", ] } } -SVDTOOLS_VERSION = { value = "v0.3.0", condition = { env_not_set = [ +SVDTOOLS_VERSION = { value = "v0.3.4", condition = { env_not_set = [ "SVDTOOLS_VERSION", ] } } -SVD2RUST_VERSION = { value = "v0.30.0", condition = { env_not_set = [ +SVD2RUST_VERSION = { value = "v0.30.1", condition = { env_not_set = [ "SVD2RUST_VERSION", ] } } -SVD2HTML_VERSION = { value = "v0.1.4", condition = { env_not_set = [ - "SVD2HTML_VERSION", +SVDCONV_VERSION = { value = "3.3.46", condition = { env_not_set = [ + "SVDCONV_VERSION", ] } } CRATES = { value = "stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32h5 stm32h7 stm32l0 stm32l1 stm32l4 stm32l5 stm32g0 stm32g4 stm32mp1 stm32wl stm32wb stm32u5", condition = { env_not_set = [ "CRATES", @@ -86,8 +86,8 @@ echo download svdtools ${SVDTOOLS_VERSION} wget -O "${CARGO_BIN_DIR}/svdtools.zip" "https://github.com/stm32-rs/svdtools/releases/download/${SVDTOOLS_VERSION}/svdtools-x86_64-pc-windows-msvc.zip" echo download svd2rust ${SVD2RUST_VERSION} wget -O "${CARGO_BIN_DIR}/svd2rust.exe" "https://github.com/rust-embedded/svd2rust/releases/download/${SVD2RUST_VERSION}/svd2rust-x86_64-pc-windows-msvc.exe" -echo download svd2html ${SVD2HTML_VERSION} -wget -O "${CARGO_BIN_DIR}/svd2html.exe" "https://github.com/burrbull/svd2html/releases/download/${SVD2HTML_VERSION}/svd2html-x86_64-pc-windows-msvc.exe" +echo download svdconv ${SVDCONV_VERSION} +wget -O "${CARGO_BIN_DIR}/svdconv.zip" "https://github.com/Open-CMSIS-Pack/devtools/releases/download/tools/svdconv/${SVDCONV_VERSION}/svdconv-${SVDCONV_VERSION}-windows-amd64.zip" echo "unzip tools" @@ -99,8 +99,12 @@ unzip "${CARGO_BIN_DIR}/svdtools.zip" "${CARGO_BIN_DIR}/svdtools" mv "${CARGO_BIN_DIR}/svdtools/svdtools.exe" "${CARGO_BIN_DIR}/svdtools.exe" rm -r "${CARGO_BIN_DIR}/svdtools" +rm "${CARGO_BIN_DIR}/svdconv.exe" +unzip "${CARGO_BIN_DIR}/svdconv.zip" "${CARGO_BIN_DIR}" + rm "${CARGO_BIN_DIR}/form.zip" rm "${CARGO_BIN_DIR}/svdtools.zip" +rm "${CARGO_BIN_DIR}/svdconv.zip" ''' [tasks.check-patched] From a0c1744ac1f8ff91f88fd8e503638ec3ae884263 Mon Sep 17 00:00:00 2001 From: eZio Pan Date: Mon, 27 Nov 2023 23:05:25 +0800 Subject: [PATCH 6/6] update changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3043c3739..13f4a4dcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,6 @@ - Fix DAC for stm32f4 (#921) - check `CARGO_HOME` env var before put binary into default place ([#865]) - `cargo make install` will install pre-build binary tools on windows ([#865]) -- bump up `svd2html` version to `v0.1.4` ([#865]) [#854]: https://github.com/stm32-rs/stm32-rs/pull/854 [#865]: https://github.com/stm32-rs/stm32-rs/pull/865 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy