From a09a8b11d0b89d4d4022dbac73dbcd5c21026dab Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Thu, 26 Sep 2024 19:00:32 -0400 Subject: [PATCH 1/6] chore(ci): Move to release-plz Remove home-rolled automated release scripts in favor of release-plz --- .github/actions/sync-bsp-versions/action.yml | 9 - .../sync-bsp-versions/update-from-hal.py | 24 --- .github/actions/sync-pac-versions/action.yml | 9 - .../sync-pac-versions/update-from-pac.py | 25 --- .github/dependabot.yml | 7 + .github/workflows/bump-crates.yml | 135 ------------ .github/workflows/bump-t2-bsp.yml | 96 --------- .github/workflows/release-crates.yml | 194 +++--------------- .github/workflows/update_changelog.py | 38 ---- .release-plz.toml | 13 ++ Cargo.toml | 18 +- 11 files changed, 62 insertions(+), 506 deletions(-) delete mode 100644 .github/actions/sync-bsp-versions/action.yml delete mode 100755 .github/actions/sync-bsp-versions/update-from-hal.py delete mode 100644 .github/actions/sync-pac-versions/action.yml delete mode 100755 .github/actions/sync-pac-versions/update-from-pac.py create mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/bump-crates.yml delete mode 100644 .github/workflows/bump-t2-bsp.yml delete mode 100644 .github/workflows/update_changelog.py create mode 100644 .release-plz.toml diff --git a/.github/actions/sync-bsp-versions/action.yml b/.github/actions/sync-bsp-versions/action.yml deleted file mode 100644 index f19093da27d..00000000000 --- a/.github/actions/sync-bsp-versions/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: 'Sync BSPs to HAL version' -description: 'Updates BSP files to point to latest HAL' -runs: - using: "composite" - steps: - - run: sudo apt-get install python3-pip && pip install tomlkit - shell: bash - - run: python3 ${{ github.action_path }}/update-from-hal.py - shell: bash diff --git a/.github/actions/sync-bsp-versions/update-from-hal.py b/.github/actions/sync-bsp-versions/update-from-hal.py deleted file mode 100755 index cc31b2a4000..00000000000 --- a/.github/actions/sync-bsp-versions/update-from-hal.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 - -from tomlkit import parse, dumps -from pathlib import Path -import json -import sys - -hal_path = Path("hal") / "Cargo.toml" -hal = parse(hal_path.read_text()) -hal_version = hal["package"]["version"] - -crates = Path("crates.json") -boards = json.loads(crates.read_text())["boards"] -board_names = [name for name, info in boards.items() if info["tier"] == 1] - -for name in board_names: - bsp_path = Path("boards") / name / "Cargo.toml" - bsp = parse(bsp_path.read_text()) - bsp_version = bsp["dependencies"]["atsamd-hal"]["version"] - if bsp_version != hal_version: - print(f"Upgrading {name} from {bsp_version} to {hal_version}.", file=sys.stderr) - bsp["dependencies"]["atsamd-hal"]["version"] = hal_version - bsp_path.write_text(dumps(bsp)) - diff --git a/.github/actions/sync-pac-versions/action.yml b/.github/actions/sync-pac-versions/action.yml deleted file mode 100644 index 1a32321d55c..00000000000 --- a/.github/actions/sync-pac-versions/action.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: 'Sync HAL to PAC versions' -description: 'Updates HAL file with latest PAC versions' -runs: - using: "composite" - steps: - - run: sudo apt-get install python3-pip && pip install --user tomlkit - shell: bash - - run: python3 ${{ github.action_path }}/update-from-pac.py - shell: bash diff --git a/.github/actions/sync-pac-versions/update-from-pac.py b/.github/actions/sync-pac-versions/update-from-pac.py deleted file mode 100755 index 0a144df0a7e..00000000000 --- a/.github/actions/sync-pac-versions/update-from-pac.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 - -from tomlkit import parse, dumps -from pathlib import Path -import sys - -hal_path = Path("hal") / "Cargo.toml" -hal = parse(hal_path.read_text()) - -pacs = {} -for path in Path("pac").glob("atsam*/Cargo.toml"): - name = path.parent.name - pacs[name] = parse(path.read_text()) - -for name, pac in pacs.items(): - hal_version = hal["dependencies"][name]["version"] - pac_version = pac["package"]["version"] - if hal_version == pac_version: - print(f"HAL dependency on {name} is up-to-date.", file=sys.stderr) - else: - hal["dependencies"][name]["version"] = pac_version - msg = f"HAL dependency on {name} upgraded from {hal_version} to {pac_version}." - print(msg, file=sys.stderr) - -hal_path.write_text(dumps(hal)) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000000..7ee8cf82492 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + # Check for updates every Monday + schedule: + interval: "weekly" diff --git a/.github/workflows/bump-crates.yml b/.github/workflows/bump-crates.yml deleted file mode 100644 index 44d183af37b..00000000000 --- a/.github/workflows/bump-crates.yml +++ /dev/null @@ -1,135 +0,0 @@ -name: Bump crate versions -on: - workflow_dispatch: - inputs: - pac_bump: - description: 'PAC version bump (none/patch/minor/major)' - required: true - default: 'none' - hal_bump: - description: 'HAL version bump (none/patch/minor/major)' - required: true - default: 'none' - bsp_bump: - description: 'T1 BSP version bump (none/patch/minor/major)' - required: true - default: 'none' - -jobs: - bump-versions: - runs-on: ubuntu-latest - steps: - - name: Set up Rust - run: | - rustup set profile minimal - rustup override set stable - - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.ATSAMD_BOT_SSH_PRIVKEY }} - - name: Setup - shell: bash - run: | - set -ex - cargo install cargo-edit - - - name: Bump PAC versions - if: github.event.inputs.pac_bump != 'none' - shell: bash - run: | - set -ex - - for dir in pac/*/ ; do - # Remove the trailing slash - dir=${dir%/} - manifest="$dir/Cargo.toml" - - # Bump the PAC version - cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.pac_bump }} - - # Update the changelog - version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version') - python3 .github/workflows/update_changelog.py $dir $version - done - - - name: Update HAL deps - uses: ./.github/actions/sync-pac-versions - - - name: Bump HAL version - if: github.event.inputs.hal_bump != 'none' - shell: bash - run: | - set -ex - - # Bump the HAL version - cargo set-version --manifest-path "hal/Cargo.toml" --exclude atsamd-hal-macros --bump ${{ github.event.inputs.hal_bump }} - - # Update the changelog - version=$(cargo metadata --manifest-path "hal/Cargo.toml" --no-deps --format-version 1 | jq -r '.packages[0].version') - python3 .github/workflows/update_changelog.py hal/ $version - - - name: Update BSP deps - uses: ./.github/actions/sync-bsp-versions - - - name: Bump BSP versions - if: github.event.inputs.bsp_bump != 'none' - shell: bash - run: | - set -ex - - jq -r '.boards | to_entries | map(select(.value.tier == 1) | .key) | .[]' crates.json | while read dir; do - manifest="boards/$dir/Cargo.toml" - - # Bump the BSP version - cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.bsp_bump }} - - # Update the changelog - version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version') - python3 .github/workflows/update_changelog.py "boards/$dir/" $version - done - - - name: Generate patch - shell: bash - run: | - git diff > bump.patch - - - name: Upload diff - uses: actions/upload-artifact@v4 - with: - name: bump.patch - path: bump.patch - - - name: Cleanup - shell: bash - run: | - set -ex - rm bump.patch - - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - commit-message: | - Bump crate versions - - HAL: ${{ github.event.inputs.hal_bump }} - Tier 1 BSPs: ${{ github.event.inputs.bsp_bump }} - PACs: ${{ github.event.inputs.pac_bump }} - committer: GitHub - author: atsamd-bot - signoff: false - branch: bump-versions - delete-branch: true - title: '[atsamd-bot] Bump crate versions' - body: | - Automated bump of crate versions. - - Workflow launched by `${{ github.actor }}` - - Workflow: [bump-crates.yml][1] - - PAC bump = `${{ github.event.inputs.pac_bump }}` - - HAL bump = `${{ github.event.inputs.hal_bump }}` - - BSP bump = `${{ github.event.inputs.bsp_bump }}` - - [1]: https://github.com/atsamd-rs/atsamd/tree/master/.github/workflows - labels: | - automated pr - version-bump - draft: false diff --git a/.github/workflows/bump-t2-bsp.yml b/.github/workflows/bump-t2-bsp.yml deleted file mode 100644 index 91150556de4..00000000000 --- a/.github/workflows/bump-t2-bsp.yml +++ /dev/null @@ -1,96 +0,0 @@ -name: Bump version of a single Tier 2 crate -on: - workflow_dispatch: - inputs: - bsp_name: - description: 'Name of Tier 2 BSP to bump' - required: true - bsp_bump: - description: 'Tier 2 BSP version bump (none/patch/minor/major)' - required: true - default: 'none' - -jobs: - bump-versions: - runs-on: ubuntu-latest - steps: - - name: Set up Rust - run: | - rustup set profile minimal - rustup override set stable - - uses: actions/checkout@v4 - with: - ssh-key: ${{ secrets.ATSAMD_BOT_SSH_PRIVKEY }} - - name: Setup - shell: bash - run: | - set -ex - cargo install cargo-edit - - - name: Bump BSP version - if: github.event.inputs.bsp_bump != 'none' - shell: bash - run: | - set -ex - bsp=${{github.event.inputs.bsp_name }} - - if [ ! -d "boards/$bsp" ]; then - echo "BSP $bsp does not exist" - exit 1 - fi - - if jq -r '.boards | to_entries | map(select(.value.tier == 2) | .key) | .[]' crates.json | grep -q $bsp; then - manifest="boards/$bsp/Cargo.toml" - - # Bump the BSP version - cargo set-version --manifest-path $manifest --bump ${{ github.event.inputs.bsp_bump }} - - # Update the changelog - version=$(cargo metadata --manifest-path $manifest --no-deps --format-version 1 | jq -r '.packages[0].version') - python3 .github/workflows/update_changelog.py "boards/$bsp/" $version - else - echo "BSP $bsp is not Tier 2." - exit 2 - fi - - - name: Generate patch - shell: bash - run: | - git diff > bump.patch - - - name: Upload diff - uses: actions/upload-artifact@v4 - with: - name: bump.patch - path: bump.patch - - - name: Cleanup - shell: bash - run: | - set -ex - rm bump.patch - - - name: Create Pull Request - id: cpr - uses: peter-evans/create-pull-request@v6 - with: - commit-message: | - Bump ${{ github.event.inputs.bsp_name }} (${{ github.event.inputs.bsp_bump }}) - committer: GitHub - author: atsamd-bot - signoff: false - branch: bump-${{ github.event.inputs.bsp_name }} - delete-branch: true - title: '[atsamd-bot] Bump crate versions' - body: | - Automated bump of Tier 2 BSP. - - Workflow launched by `${{ github.actor }}` - - Workflow: [bump-t2-bsp.yml][1] - - BSP name = `${{ github.event.inputs.bsp_name}}` - - Bump = `${{ github.event.inputs.bsp_bump }}` - - [1]: https://github.com/atsamd-rs/atsamd/tree/master/.github/workflows - labels: | - automated pr - version-bump - draft: false diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml index 285a20cb576..a6721be13f0 100644 --- a/.github/workflows/release-crates.yml +++ b/.github/workflows/release-crates.yml @@ -1,176 +1,34 @@ name: Release crates + +permissions: + pull-requests: write + contents: write + on: - workflow_dispatch: - inputs: - release_pac: - description: 'Release PAC (yes/no)' - required: true - default: 'yes' - release_hal: - description: 'Release HAL (yes/no)' - required: true - default: 'yes' - release_bsp: - description: 'Release BSPs (yes/no)' - required: true - default: 'yes' + push: + branches: + - master + jobs: - release-crates: + release-plz: + name: Release-plz runs-on: ubuntu-latest steps: - - name: Install Rust - run: | - rustup set profile minimal - rustup override set stable - rustup target add thumbv6m-none-eabi - rustup target add thumbv7em-none-eabihf - - - name: Login - run: cargo login ${CRATES_IO_TOKEN} - env: - CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} - - - name: Release PAC crates - if: github.event.inputs.release_pac == 'yes' - shell: bash - run: | - set -ex - - # Run `cargo publish` on each PAC. - # Unfortunately, cargo publish errors if the crate is already uploaded, - # and there is no way to turn that off. As a result, we need to do some - # janky hacks to detect that condition and ignore it. - # - # Specifically, we ignore the exit code but capture the stderr. If - # the standard error contains ' is already uploaded', then it must - # be the error we dont care about, so we exit the subshell with a - # success status. - # - # All errors start with the form 'error: ', so we detect that and - # bail the subshell to crash out on other publish errors. - # - # Before publishing, we also tag each PAC with its current version. - # If creating+pushing the tag fails, we check if there already is an - # identical tag at the same commit, and continue processing if that's - # the case. If tagging fails for any other reason, bail the subshell. - - for d in pac/*/ - do - ( - cd "${d}" - - PAC_NAME="${d#pac/}" - PAC_NAME="${PAC_NAME%/}" - - VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - TAG_NAME="${PAC_NAME}-${VERSION}" - - if ! git tag -a $TAG_NAME -m "${PAC_NAME} release ${VERSION}" && git push origin tag "$TAG_NAME"; then - if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then - echo '(and points at this commit). Continuing.' - else - false - fi - fi - - set +e - PUBLISH_ERR=$(cargo publish 2>&1 >/dev/null) - set -e - if [[ "$PUBLISH_ERR" == *" is already uploaded"* ]]; then - exit 0 - fi - if [[ "$PUBLISH_ERR" == *"error: "* ]]; then - echo "$PUBLISH_ERR" - exit 1 - fi - ) - done - - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: - ssh-key: ${{ secrets.ATSAMD_BOT_SSH_PRIVKEY }} - - - name: Release HAL crate - if: github.event.inputs.release_hal == 'yes' - shell: bash - run: | - set -ex - - # Force update of the registry - cargo update || true + fetch-depth: 0 - cd hal - - VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - TAG_NAME="atsamd-hal-${VERSION}" - - # Create+push a git tag. If that fails, check if an identical tag already exists at the - # same commit. Bail otherwise. - if ! git tag -a $TAG_NAME -m "atsamd-hal release ${VERSION}" && git push origin tag "$TAG_NAME"; then - if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then - echo '(and points at this commit). Continuing.' - else - false - fi - fi - - - cargo publish - - - - name: Release BSP crates - if: github.event.inputs.release_bsp == 'yes' - shell: bash - run: | - set -ex - - # Force update of the registry - cargo update || true - - sudo apt-get install -y jq - - # Unfortunately, cargo publish errors if the crate is already uploaded, - # and there is no way to turn that off. As a result, we need to do some - # janky hacks to detect that condition and ignore it. - # - # Specifically, we ignore the exit code but capture the stderr. If - # the standard error contains ' is already uploaded', then it must - # be the error we dont care about, so we exit the subshell with a - # success status. - # - # All errors start with the form 'error: ', so we detect that and - # bail the subshell to crash out on other publish errors. - # - # Before publishing, we also tag each BSP with its current version. - # If creating+pushing the tag fails, we check if there already is an - # identical tag at the same commit, and continue processing if that's - # the case. If tagging fails for any other reason, bail the subshell. - - for bsp in $(cat crates.json | jq -Mr -c '.boards | keys[]'); - do - ( - cd "boards/${bsp}" - - VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') - TAG_NAME="${bsp}-${VERSION}" - - if ! git tag -a $TAG_NAME -m "${bsp} release ${VERSION}" && git push origin tag "$TAG_NAME"; then - if git tag --points-at "$(git rev-parse HEAD)" | grep "$TAG_NAME" > /dev/null; then - echo '(and points at this commit). Continuing.' - else - false - fi - fi + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: thumbv6m-none-eabi, thumbv7em-none-eabihf - set +e - PUBLISH_ERR=$(cargo publish 2>&1 >/dev/null) - set -e - if [[ "$PUBLISH_ERR" == *" is already uploaded"* ]]; then - exit 0 - fi - if [[ "$PUBLISH_ERR" == *"error: "* ]]; then - echo "$PUBLISH_ERR" - exit 1 - fi - ) - done + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + # Remove the next two lines when ready to go live with release-plz + with: + command: release-pr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/.github/workflows/update_changelog.py b/.github/workflows/update_changelog.py deleted file mode 100644 index d9cf7b20c62..00000000000 --- a/.github/workflows/update_changelog.py +++ /dev/null @@ -1,38 +0,0 @@ -import argparse -import re -import sys - -def update_changelog(changelog_path, version): - try: - with open(changelog_path, 'r', encoding='utf-8') as f: - changelog = f.read() - except FileNotFoundError: - sys.stderr.write(f"Error: Changelog file not found at {changelog_path}.") - sys.exit(1) - - unreleased_pattern = re.compile(r'^# unreleased.*$', re.IGNORECASE | re.MULTILINE) - - if not unreleased_pattern.search(changelog): - sys.stderr.write(f"Error: No 'Unreleased' section found in {changelog_path}.") - sys.exit(2) - - replacement_text = f"# Unreleased Changes\n\n# v{version}" - updated_changelog = re.sub(unreleased_pattern, replacement_text, changelog) - with open(changelog_path, 'w', encoding='utf-8') as f: - f.write(updated_changelog) - - print(f"Changelog updated successfully with version {version}.") - -if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Update crate changelog by parsing version from Cargo manifest") - parser.add_argument('crate_path', help="Path to the crate") - parser.add_argument('crate_version', help="Version of the crate") - - args = parser.parse_args() - - # Get the crate version from Cargo.toml - manifest_path = f'{args.crate_path}/Cargo.toml' - - # Update the changelog - crate_changelog_path = f'{args.crate_path}/CHANGELOG.md' - update_changelog(crate_changelog_path, args.crate_version) diff --git a/.release-plz.toml b/.release-plz.toml new file mode 100644 index 00000000000..55e485ecbed --- /dev/null +++ b/.release-plz.toml @@ -0,0 +1,13 @@ +[workspace] +git_release_name = "{{ package }}-{{ version }}" +git_tag_name = "{{ package }}-{{ version }}" +pr_labels = ["release", "bot"] +git_tag_enable = false # # Remove this line when ready to go live with release-plz +publish = false # Remove this line when ready to go live with release-plz +publish_timeout = "10m" + +# Only try to publish releases when a release PR is merged +release_always = false + +[changelog] +protect_breaking_commits = true diff --git a/Cargo.toml b/Cargo.toml index 54874e2ffc4..cf46f9c5a10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,18 @@ [workspace] resolver = "2" -members = ["hal", "atsamd-hal-macros"] -exclude = ["pac", "boards"] \ No newline at end of file +members = [ + "hal", + "atsamd-hal-macros", + "pac/*", + "boards/*", +] + +[profile.dev] +debug = true +opt-level = 0 +lto = false + +[profile.release] +lto = true +opt-level = "s" +debug = true From 44833a14fbd48a27123045913ea82e602a839a4a Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Thu, 26 Sep 2024 20:52:11 -0400 Subject: [PATCH 2/6] Remove safeguards to get ready to go live with release-plz --- .github/workflows/release-crates.yml | 3 --- .release-plz.toml | 2 -- 2 files changed, 5 deletions(-) diff --git a/.github/workflows/release-crates.yml b/.github/workflows/release-crates.yml index a6721be13f0..75e49c097cb 100644 --- a/.github/workflows/release-crates.yml +++ b/.github/workflows/release-crates.yml @@ -26,9 +26,6 @@ jobs: - name: Run release-plz uses: MarcoIeni/release-plz-action@v0.5 - # Remove the next two lines when ready to go live with release-plz - with: - command: release-pr env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/.release-plz.toml b/.release-plz.toml index 55e485ecbed..ec9eedf946b 100644 --- a/.release-plz.toml +++ b/.release-plz.toml @@ -2,8 +2,6 @@ git_release_name = "{{ package }}-{{ version }}" git_tag_name = "{{ package }}-{{ version }}" pr_labels = ["release", "bot"] -git_tag_enable = false # # Remove this line when ready to go live with release-plz -publish = false # Remove this line when ready to go live with release-plz publish_timeout = "10m" # Only try to publish releases when a release PR is merged From 04bf2fccd1fcc060f99b56b67b0d12d5552c4300 Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Mon, 14 Oct 2024 20:38:51 -0400 Subject: [PATCH 3/6] Remove profiles from BSP Cargo.toml's and add a dev-optimized profile to workspace --- Cargo.toml | 10 ++++++++++ boards/atsame54_xpro/Cargo.toml | 10 ---------- boards/circuit_playground_express/Cargo.toml | 3 --- boards/edgebadge/Cargo.toml | 11 ----------- boards/feather_m0/Cargo.toml | 11 ----------- boards/feather_m4/Cargo.toml | 12 ------------ boards/grand_central_m4/Cargo.toml | 10 ---------- boards/itsybitsy_m0/Cargo.toml | 11 ----------- boards/itsybitsy_m4/Cargo.toml | 11 ----------- boards/metro_m0/Cargo.toml | 11 ----------- boards/metro_m4/Cargo.toml | 10 ---------- boards/p1am_100/Cargo.toml | 11 ----------- boards/pfza_proto1/Cargo.toml | 10 ---------- boards/pygamer/Cargo.toml | 10 ---------- boards/pyportal/Cargo.toml | 10 ---------- boards/samd11_bare/Cargo.toml | 6 ------ boards/sodaq_one/Cargo.toml | 10 ---------- boards/trellis_m4/Cargo.toml | 10 ---------- boards/wio_terminal/Cargo.toml | 10 ---------- boards/xiao_m0/Cargo.toml | 5 ----- 20 files changed, 10 insertions(+), 182 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf46f9c5a10..00183351b87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,16 @@ debug = true opt-level = 0 lto = false +# Neopixel and USB examples rely on some timing constraints that can only be upheld +# with some optimizations enabled. +# +# Add `--profile dev-optimized` to your cargo invocations to use this profile. +[profile.dev-optimized] +inherits = "dev" +opt-level = 2 +lto = "thin" + + [profile.release] lto = true opt-level = "s" diff --git a/boards/atsame54_xpro/Cargo.toml b/boards/atsame54_xpro/Cargo.toml index 608afad2705..46a5beda4a0 100644 --- a/boards/atsame54_xpro/Cargo.toml +++ b/boards/atsame54_xpro/Cargo.toml @@ -43,16 +43,6 @@ rt = ["cortex-m-rt", "atsamd-hal/same54p-rt"] usb = ["atsamd-hal/usb", "usb-device"] can = ["atsamd-hal/can"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - [[example]] name = "mcan" required-features = ["can"] diff --git a/boards/circuit_playground_express/Cargo.toml b/boards/circuit_playground_express/Cargo.toml index be8626dd374..f25d01e3e4f 100644 --- a/boards/circuit_playground_express/Cargo.toml +++ b/boards/circuit_playground_express/Cargo.toml @@ -40,9 +40,6 @@ unproven = ["atsamd-hal/unproven"] usb = ["atsamd-hal/usb", "usb-device"] use_semihosting = [] -[profile.release] -debug = true - # for cargo flash [package.metadata] chip = "ATSAMD21G18A" diff --git a/boards/edgebadge/Cargo.toml b/boards/edgebadge/Cargo.toml index 6efbabbd03a..628843527ee 100644 --- a/boards/edgebadge/Cargo.toml +++ b/boards/edgebadge/Cargo.toml @@ -49,17 +49,6 @@ unproven = ["atsamd-hal/unproven"] usb = ["atsamd-hal/usb", "usb-device"] math = ["micromath"] -[profile.dev] -# opt-level = 2 # uncomment for neopixel functionality during debug -incremental = false -debug = true -lto = "thin" # thin for debug speed - -[profile.release] -debug = true -lto = "fat" -opt-level = 's' - # for cargo flash [package.metadata] chip = "ATSAMD51J19A" diff --git a/boards/feather_m0/Cargo.toml b/boards/feather_m0/Cargo.toml index 56c06f250d6..ef8eefc5d9d 100644 --- a/boards/feather_m0/Cargo.toml +++ b/boards/feather_m0/Cargo.toml @@ -69,17 +69,6 @@ sdmmc = ["embedded-sdmmc", "atsamd-hal/sdmmc"] rtic = ["atsamd-hal/rtic"] use_semihosting = [] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = false - -[profile.release] -debug = true -lto = true -opt-level = "s" - [[example]] name = "blinky_basic" diff --git a/boards/feather_m4/Cargo.toml b/boards/feather_m4/Cargo.toml index 4fcd5a6bbe8..59e03b4e229 100644 --- a/boards/feather_m4/Cargo.toml +++ b/boards/feather_m4/Cargo.toml @@ -49,18 +49,6 @@ usb = ["atsamd-hal/usb", "usb-device"] dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/dma"] - -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -debug = true -lto = true -opt-level = "s" - [[example]] name = "pwm" diff --git a/boards/grand_central_m4/Cargo.toml b/boards/grand_central_m4/Cargo.toml index b7466002a0f..79cb98c243f 100644 --- a/boards/grand_central_m4/Cargo.toml +++ b/boards/grand_central_m4/Cargo.toml @@ -39,16 +39,6 @@ default = ["rt", "atsamd-hal/samd51p"] rt = ["cortex-m-rt", "atsamd-hal/samd51p-rt"] usb = ["atsamd-hal/usb", "usb-device"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD51P20A" diff --git a/boards/itsybitsy_m0/Cargo.toml b/boards/itsybitsy_m0/Cargo.toml index 0526dd5ecc0..e20ccadc484 100644 --- a/boards/itsybitsy_m0/Cargo.toml +++ b/boards/itsybitsy_m0/Cargo.toml @@ -58,17 +58,6 @@ sdmmc = ["embedded-sdmmc", "atsamd-hal/sdmmc"] rtic = ["atsamd-hal/rtic"] use_semihosting = [] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = false - -[profile.release] -debug = true -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD21G18A" diff --git a/boards/itsybitsy_m4/Cargo.toml b/boards/itsybitsy_m4/Cargo.toml index ff58190923a..bcda4aed83e 100644 --- a/boards/itsybitsy_m4/Cargo.toml +++ b/boards/itsybitsy_m4/Cargo.toml @@ -45,17 +45,6 @@ usb = ["atsamd-hal/usb", "usb-device"] use_rtt = ["atsamd-hal/use_rtt"] use_semihosting = [] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -debug = true -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD51G19A" diff --git a/boards/metro_m0/Cargo.toml b/boards/metro_m0/Cargo.toml index 6181434f178..a87ce242117 100644 --- a/boards/metro_m0/Cargo.toml +++ b/boards/metro_m0/Cargo.toml @@ -49,17 +49,6 @@ use_rtt = ["atsamd-hal/use_rtt"] usb = ["atsamd-hal/usb", "usb-device"] use_semihosting = [] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = false - -[profile.release] -debug = true -lto = true -opt-level = "s" - [[example]] name = "usb_echo" required-features = ["usb"] diff --git a/boards/metro_m4/Cargo.toml b/boards/metro_m4/Cargo.toml index 0a605cd0c0e..54a5913a1a4 100644 --- a/boards/metro_m4/Cargo.toml +++ b/boards/metro_m4/Cargo.toml @@ -56,16 +56,6 @@ rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"] use_semihosting = [] usb = ["atsamd-hal/usb", "usb-device"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = 3 - [[example]] name = "blinky_basic" diff --git a/boards/p1am_100/Cargo.toml b/boards/p1am_100/Cargo.toml index 3dd22499009..35a4a6b0ab7 100644 --- a/boards/p1am_100/Cargo.toml +++ b/boards/p1am_100/Cargo.toml @@ -44,17 +44,6 @@ dma = ["atsamd-hal/dma"] max-channels = ["dma", "atsamd-hal/max-channels"] use_semihosting = [] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = false - -[profile.release] -debug = true -lto = true -opt-level = "s" - [[example]] name = "blinky_basic" diff --git a/boards/pfza_proto1/Cargo.toml b/boards/pfza_proto1/Cargo.toml index d37134584b8..c4bac292628 100644 --- a/boards/pfza_proto1/Cargo.toml +++ b/boards/pfza_proto1/Cargo.toml @@ -28,16 +28,6 @@ default = ["rt", "atsamd-hal/same54p", "atsamd-hal/same54"] rt = ["cortex-m-rt", "atsamd-hal/same54p-rt"] unproven = ["atsamd-hal/unproven"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAME54P20A" diff --git a/boards/pygamer/Cargo.toml b/boards/pygamer/Cargo.toml index 3cae3c6eea4..df1ed0d68de 100644 --- a/boards/pygamer/Cargo.toml +++ b/boards/pygamer/Cargo.toml @@ -58,16 +58,6 @@ sd-card = ["embedded-sdmmc"] math = ["micromath"] panic_led = [] -[profile.dev] -# opt-level = 2 # uncomment for neopixel functionality during debug -incremental = false -debug = true -lto = "thin" # thin for debug speed - -[profile.release] -lto = "fat" -opt-level = 's' - # for cargo flash [package.metadata] chip = "ATSAMD51J19A" diff --git a/boards/pyportal/Cargo.toml b/boards/pyportal/Cargo.toml index 8361b948ef2..e1e898f7e4d 100644 --- a/boards/pyportal/Cargo.toml +++ b/boards/pyportal/Cargo.toml @@ -53,16 +53,6 @@ rt = ["cortex-m-rt", "atsamd-hal/samd51j-rt"] usb = ["atsamd-hal/usb", "usb-device"] display = ["display-interface-parallel-gpio", "ili9341"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD51J20A" diff --git a/boards/samd11_bare/Cargo.toml b/boards/samd11_bare/Cargo.toml index 2499d72500e..962826bf794 100644 --- a/boards/samd11_bare/Cargo.toml +++ b/boards/samd11_bare/Cargo.toml @@ -41,12 +41,6 @@ max-channels = ["dma", "atsamd-hal/max-channels"] rt = ["cortex-m-rt", "atsamd-hal/samd11c-rt"] use_semihosting = [] -[profile.release] -debug = true - -[profile.dev] -opt-level = "s" - [[example]] name = "adc" required-features = ["rt", "use_semihosting"] diff --git a/boards/sodaq_one/Cargo.toml b/boards/sodaq_one/Cargo.toml index 28c4c9e74cf..0b8e478079e 100644 --- a/boards/sodaq_one/Cargo.toml +++ b/boards/sodaq_one/Cargo.toml @@ -35,13 +35,3 @@ use_semihosting = [] # for cargo flash [package.metadata] chip = "ATSAMD21G18A" - -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = false - -[profile.release] -lto = true -opt-level = "s" diff --git a/boards/trellis_m4/Cargo.toml b/boards/trellis_m4/Cargo.toml index 4555d5ead66..f8c0263ecd5 100644 --- a/boards/trellis_m4/Cargo.toml +++ b/boards/trellis_m4/Cargo.toml @@ -48,16 +48,6 @@ rt = ["cortex-m-rt", "atsamd-hal/samd51g-rt"] unproven = ["atsamd-hal/unproven"] keypad-unproven = ["keypad", "unproven"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD51G19A" diff --git a/boards/wio_terminal/Cargo.toml b/boards/wio_terminal/Cargo.toml index f77f6ee597d..f9a01057587 100644 --- a/boards/wio_terminal/Cargo.toml +++ b/boards/wio_terminal/Cargo.toml @@ -63,16 +63,6 @@ usb = ["atsamd-hal/usb", "usb-device"] wifi-fw-before-212 = [] wifi = ["bbqueue", "generic-array", "seeed-erpc"] -[profile.dev] -incremental = false -codegen-units = 1 -debug = true -lto = true - -[profile.release] -lto = true -opt-level = "s" - [[example]] name = "blinky" diff --git a/boards/xiao_m0/Cargo.toml b/boards/xiao_m0/Cargo.toml index e7a8f2c3d62..e8f73f8259f 100644 --- a/boards/xiao_m0/Cargo.toml +++ b/boards/xiao_m0/Cargo.toml @@ -52,11 +52,6 @@ name = "ssd1306_i2c" name = "usb_echo" required-features = ["usb"] -[profile.release] -debug = false -lto = true -opt-level = "s" - # for cargo flash [package.metadata] chip = "ATSAMD21G18A" From 389882146598e34e94a21946e16e184b58ccf9ad Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Wed, 16 Oct 2024 10:13:08 -0400 Subject: [PATCH 4/6] Add HAL as default workspace build package --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 00183351b87..6613515bbc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] resolver = "2" +default-members = ["hal"] members = [ "hal", "atsamd-hal-macros", From 727daafaf06f8e5a90ca016d9bdf88fba725d484 Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Wed, 16 Oct 2024 10:35:25 -0400 Subject: [PATCH 5/6] Somehow some BSPs were missing build scripts. I'm not even sure how examples built without a build script? --- boards/samd21_mini/build.rs | 17 +++++++++++++++++ boards/xiao_m0/build.rs | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 boards/samd21_mini/build.rs create mode 100644 boards/xiao_m0/build.rs diff --git a/boards/samd21_mini/build.rs b/boards/samd21_mini/build.rs new file mode 100644 index 00000000000..44c87ffae9a --- /dev/null +++ b/boards/samd21_mini/build.rs @@ -0,0 +1,17 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + if env::var_os("CARGO_FEATURE_RT").is_some() { + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + println!("cargo:rerun-if-changed=memory.x"); + } + println!("cargo:rerun-if-changed=build.rs"); +} diff --git a/boards/xiao_m0/build.rs b/boards/xiao_m0/build.rs new file mode 100644 index 00000000000..44c87ffae9a --- /dev/null +++ b/boards/xiao_m0/build.rs @@ -0,0 +1,17 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + if env::var_os("CARGO_FEATURE_RT").is_some() { + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + println!("cargo:rerun-if-changed=memory.x"); + } + println!("cargo:rerun-if-changed=build.rs"); +} From f83b72134c156fb068c880b76b0cde3da05dfa70 Mon Sep 17 00:00:00 2001 From: Justin Beaurivage Date: Wed, 16 Oct 2024 10:36:21 -0400 Subject: [PATCH 6/6] Build samd11_bare examples with optimizations --- crates.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates.json b/crates.json index 41192c50320..6a3872969ff 100644 --- a/crates.json +++ b/crates.json @@ -27,7 +27,7 @@ }, "samd11_bare": { "tier": 1, - "build": "cargo build --examples --all-features", + "build": "cargo build --profile dev-optimized --examples --all-features", "target": "thumbv6m-none-eabi" }, "arduino_mkr1000": {