Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use of firmware archive #290

Merged
merged 9 commits into from
Oct 9, 2024
Merged

Conversation

frobijn
Copy link
Contributor

@frobijn frobijn commented Sep 27, 2024

Description

The changes in this repository implement the firmware archive feature:

  • Extra command line options added to nanoFirmwareFlasher.Tool and the implementation to nanoFirmwareFlasher.Library to download cloudsmith packages to a firmware archive, list the content of the archive, and deploy firmware from the archive to a device.

  • Apart from firmware .zip packages, the .dll for the WIN_DLL_nanoCLR target can be downloaded and is placed in the archive in such a way if can be used as runtime for nanoclr.exe. Same for WIN32_nanoCLR, but that is probably not needed as firmware development is probably done in a fork of the nf-interpreter repository and based on the correct version of the CLR.

  • Added a description of the new command line options to the README.md file

  • Made some changes to nanoFirmwareFlasher.Tool and nanoFirmwareFlasher.Library so that the code can be tested:

    • nanoFirmwareFlasher.Tests is a friend of nanoFirmwareFlasher.Tool and nanoFirmwareFlasher.Library.
    • Use of new OutputWriter instead of Console. The OutputWriter's output can be collected per unit test even if they are executed in parallel
    • The location of the firmware archive (~/.nanoFramework/fw_cache) can be set in unit tests
  • Added unit tests to nanoFirmwareFlasher.Tests to test the affected code. There are still 4 do-nothing-tests that are left untouched.

  • Use of nf-debugger's serial-port protection (GlobalExclusiveDeviceAccess).

  • Added .editorconfig. This may have resulted in some changes to nanoFirmwareFlasher.Tool and nanoFirmwareFlasher.Library: update of the file header, use of explicit type instead of var.

Motivation and Context

The current version of the .NET nanoFramework is based on "auto-update everything" versioning: make sure that you always use the latest version of NuGet packages, firmware and tools, and you can be sure that the packages and tools are consistent with each other.

This may be fine if there never are breaking changes in the .NET nanoFramework, and if it is always possible to update the firmware on any device. But that is not the case. E.g., recent move to littlefs was a breaking change: it would have broken some low-level libraries of this contributor (File.GetLastWriteTime disappeared). If nanoclr.exe is auto-updated the Virtual nanoDevice is no longer consistent with the libraries. If firmware is installed on a new device, that firmware will also be different.

What is needed is a versioning strategy where the user of the framework (and not the framework's core team) is in charge of updating the framework components used by the project. In this controlled update strategy the user works with a frozen version of the framework and has a guarantee very early in the development process that the final deployment to a device will succeed. The user decides if and when to update to a next version of the framework.

The auto-update and the controlled update strategies are described in a getting started guide (concept). This guide will be made available once the PR of all required components have been accepted. Apart from this PR, there will also be a PR for the MSBuild task/NuGet package. (See the first comment below for a more elaborate description.)

The use of a firmware archive is added to Packaging, versioning and deployment (concept) in the architecture section. A PR for this page will be created after this PR has been accepted.

How Has This Been Tested?

Unit tests have been added for all code that is affected by this change, except for the tasks that require a real hardware device (e.g., GlobalExclusiveDeviceAccess). Those have been tested by running the tool for a connected device.

Types of changes

  • Improvement (non-breaking change that improves a feature, code or algorithm)
  • Bug fix (non-breaking change which fixes an issue with code or algorithm)
  • New feature (non-breaking change which adds functionality to code)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Config and build (change in the configuration and build system, has no impact on code or features)
  • Dependencies (update dependencies and changes associated, has no impact on code or features)
  • Unit Tests (add new Unit Test(s) or improved existing one(s), has no impact on code or features)
  • Documentation (changes or updates in the documentation, has no impact on code or features)

Checklist:

  • My code follows the code style of this project (only if there are changes in source code).
  • My changes require an update to the documentation (there are changes that require the docs website to be updated).
  • I have updated the documentation accordingly (the changes require an update on the docs in this repo).
  • I have read the CONTRIBUTING document.
  • I have tested everything locally and all new and existing tests passed (only if there are changes in source code).
  • I have added new tests to cover my changes.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration file for the nanoFirmwareFlasher tool, allowing users to specify command-line arguments for various operations.
    • Updated the package version for nanoFramework.Tools.Debugger.Net to ensure compatibility with the latest features.
  • Bug Fixes

    • Resolved issues related to package integrity by updating the content hash for the nanoFramework.Tools.Debugger.Net package.

- Extra command line options added to *nanoFirmwareFlasher.Tool* and the implementation to *nanoFirmwareFlasher.Library* to download cloudsmith packages to a firmware archive, list the content of the archive, and deploy firmware from the archive to a device.

- Apart from firmware .zip packages, the .dll for the *WIN_DLL_nanoCLR* target can be downloaded and is placed in the archive in such a way if can be used as runtime for *nanoclr.exe*. Same for *WIN32_nanoCLR*, but that is probably not needed as firmware development is probably done in a fork of the nf-interpreter repository and based on the correct version of the CLR.

- Added a description of the new command line options to the README.md file

- Made some changes to *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library* so that the code can be tested:
    - *nanoFirmwareFlasher.Tests* is a friend of *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library*.
    - Use of new OutputWriter instead of Console. The OutputWriter's output can be collected per unit test even if they are executed in parallel
    - The location of the firmware archive can be set in unit tests

- Added unit tests to *nanoFirmwareFlasher.Tests* to test the affected code.

- Use nf-debugger's serial-port protection (GlobalExclusiveDeviceAccess).

- Added .editorconfig. This may have resulted in some changes to *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library*: update of the file header, use of explicit type instead of `var`.
Copy link

coderabbitai bot commented Sep 27, 2024

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (7)
  • README.md is excluded by !**/*.md and included by none
  • nanoFirmwareFlasher.Library/FirmwareArchiveManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/NanoDeviceOperations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/OutputWriter.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/FirmwarePackageTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/ToolFirmwareArchiveTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Program.cs is excluded by none and included by none

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces updates to the packages.lock.json file, specifically upgrading the version of the package nanoFramework.Tools.Debugger.Net from 2.4.42 to 2.4.45. Additionally, a new configuration file, nanoFirmwareFlasher.Tool.args.json, is added, which defines structured command-line arguments for the nanoFirmwareFlasher tool, detailing various commands and options available for users.

Changes

File Path Change Summary
packages.lock.json Updated package version for nanoFramework.Tools.Debugger.Net from 2.4.42 to 2.4.45.
Changed dependency version range from [2.4.42, ) to [2.4.45, ).
nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.args.json Added new configuration file defining command-line arguments for the nanoFirmwareFlasher tool.

Possibly related PRs

  • Update dependencies #287: The changes in this PR also involve updates to the packages.lock.json file, specifically upgrading package versions, which is directly related to the version update of nanoFramework.Tools.Debugger.Net in the main PR.

Suggested labels

Type: dependencies


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4363e6c and 8747764.

⛔ Files ignored due to path filters (49)
  • .editorconfig is excluded by none and included by none
  • README.md is excluded by !**/*.md and included by none
  • nanoFirmwareFlasher.Library/CC13x26x2Device.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/CC13x26x2Firmware.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/CC13x26x2Operations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Esp32DeviceInfo.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Esp32Firmware.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Esp32Operations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/EspTool.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/ExitCodes.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/FileDeployment/FileDeploymentManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/FirmwareArchiveManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/FirmwarePackage.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/JLinkCli.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/JLinkDevice.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/JLinkFirmware.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/JLinkOperations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/NanoDeviceOperations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/OutputWriter.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Properties/AssemblyInfo.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/SilinkCli.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Stm32Firmware.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Stm32Operations.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/StmDeviceBase.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/StmDfuDevice.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/StmJtagDevice.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/Utilities.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Library/nanoFirmwareFlasher.Library.csproj is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/CloudsmithApiTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/FirmwareArchiveManagerTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/FirmwarePackageTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/FirmwarePackage_Tests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/Helpers/GetTargetListHelper.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/Helpers/OutputWriterHelper.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/Helpers/TestDirectoryHelper.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/MSTest.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/Tool_FirmwareArchiveTests.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tests/nanoFirmwareFlasher.Tests.csproj is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Esp32Manager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Friends.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/NanoDeviceManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Options.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Program.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/SilabsManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/Stm32Manager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/TIManager.cs is excluded by none and included by none
  • nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.csproj is excluded by none and included by none
  • nanoFirmwareFlasher.sln is excluded by none and included by none
  • spelling_exclusion.dic is excluded by none and included by none
📒 Files selected for processing (3)
  • nanoFirmwareFlasher.Library/packages.lock.json (2 hunks)
  • nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.args.json (1 hunks)
  • nanoFirmwareFlasher.Tool/packages.lock.json (2 hunks)
🔇 Additional comments (3)
nanoFirmwareFlasher.Tool/nanoFirmwareFlasher.Tool.args.json (1)

1-4: LGTM: File structure and metadata are well-defined.

The JSON structure is correct, and the inclusion of a file version and unique ID is a good practice for configuration management. This will help with versioning and tracking changes to the configuration over time.

nanoFirmwareFlasher.Library/packages.lock.json (1)

39-41: Approved: nanoFramework.Tools.Debugger.Net package update

The update of the nanoFramework.Tools.Debugger.Net package from version 2.4.42 to 2.4.45 is consistent with the PR objectives of enhancing the nanoFirmwareFlasher project. This minor version update likely includes backward-compatible new features or bug fixes.

To ensure this update doesn't introduce any unexpected issues, please verify the compatibility of this new version with the rest of the project. You can run the following command to check for any breaking changes or deprecations:

Also applies to: 307-309

✅ Verification successful

Verified: nanoFramework.Tools.Debugger.Net package update

The update of the nanoFramework.Tools.Debugger.Net package to version 2.4.45 has been verified across the project files. All usages are consistent, and no compatibility issues have been detected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any breaking changes or deprecations in the new version

# Search for any usage of nanoFramework.Tools.Debugger.Net in the project
rg --type csharp "using.*nanoFramework\.Tools\.Debugger" -A 10

Length of output: 6577

nanoFirmwareFlasher.Tool/packages.lock.json (1)

19-21: LGTM! Verify compatibility with the updated debugger version.

The update of nanoFramework.Tools.Debugger.Net from version 2.4.42 to 2.4.45 looks good. This minor version update should bring improvements or bug fixes to the debugger tool.

To ensure compatibility, please run the following script to check for any breaking changes or significant updates in the changelog:

Also applies to: 1099-1099

✅ Verification successful

Verified: No breaking changes detected in nanoFramework.Tools.Debugger.Net v2.4.45.

The update is safe and aligns with project objectives.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for breaking changes or significant updates in nanoFramework.Tools.Debugger.Net changelog

# Fetch the changelog or release notes
changelog=$(curl -s "https://api.github.com/repos/nanoframework/nf-debugger/releases/tags/v2.4.45")

# Check for keywords indicating breaking changes or significant updates
if echo "$changelog" | grep -iE "breaking change|major update|significant change"; then
  echo "Warning: Potential breaking changes or significant updates detected in nanoFramework.Tools.Debugger.Net v2.4.45"
  echo "Please review the following changelog entries:"
  echo "$changelog" | grep -iE "breaking change|major update|significant change" -C 2
else
  echo "No obvious breaking changes or significant updates detected in nanoFramework.Tools.Debugger.Net v2.4.45"
fi

Length of output: 8124

@frobijn
Copy link
Contributor Author

frobijn commented Sep 28, 2024

Some more context about the controlled update strategy and the nanoFramework components involved. This also provides the background for the Discord question about the repository of one of the MSBuild task. It is a bit long, sorry about that, I don't know how to shorten this.

Consistency of nanoFramework components

There are many components that make up the nanoFramework:

  • Firmware/targets from the cloudsmith repository that each implement the native part of the nanoFramework, including the Virtual nanoDevice that comes in at least two flavors (nanoclr.exe, WIN_DLL_nanoCLR)
  • NuGet packages that each contain a class library that implements part of the .NET side of the nanoFramework or a tool (e.g., test framework, debugger, metaprocessor).
  • The nanoff tool that contains some business logic about how to install firmware, e.g., (for ESP32) which flash sizes are allowed and addresses in the flash memory for some of the components.
  • Visual Studio extension with the MSBuild system, project templates and debugger.
  • The development environment for custom firmware: the nf-interpreter repository with tools dev environment, WIN32_nanoCLR Virtual nanoDevice runtime.

The question which version of the components can be combined (are consistent with each other) is hard to answer. Some components rely on each other, so a new version of one component implies inconsistency with an older version of the other. Some don't, so multiple versions of one component are consistent with multiple versions of another. There is no way to know about that, because there is no documentation on the relations between components, not for humans and certainly not in machine readable formats. Even if there was documentation, there are no tests that verify that consistency.

Especially for a "simple" user who relies on the development tools (Visual Studio, NuGet, nanoFramework tools) and has no deep knowledge about the framework, it is impossible to answer the consistency question. The best answer for such a user is:

"According to the best knowledge of the nanoFramework contributors, at any given time the components that are current at that moment are consistent with each other."

With this in mind, there seem to be only two strategies for a user to work with consistent versions of all components:

  • Auto-update: at all times use the version that is current at that moment, always update to the latest versions. The user has to make sure that NuGet packages are always updated if an update is available, and always be ready to install the latest firmware on devices; the nanoFramework tools already auto-update themselves or at least check for updates regularly.

The main disadvantage is that the user must always be prepared to do some work: update all components and/or update the user's code if updates come with breaking changes. Someone with a program manager's hat may categorize the nanoFramework as an uncontrollable risk for the success of a project, as it is impossible to schedule/prepare for the work that results from an auto-update. The only other strategy that seems to be possible is an answer to that:

  • Controlled update: al all times work with a frozen version of the nanoFramework, consisting of all components that are current at the moment the freeze is made. Make sure to regularly check for updates, and reserve time to switch to a new version by freezing the then-current components.

It is not sufficient to use only current components. The NuGet packages that are used must be compatible with the firmware of the device the software is to be deployed to. That is important to keep in mind for both strategies. But as the controlled update strategy is driven by I don't want any surprises, it is important for that strategy that the compatibility of NuGet packages and firmware can be verified as early as possible.

Controlled update: requirements and solutions for nanoFramework

The controlled update strategy is not yet supported by the nanoFramework, because for a simple user it is hard to freeze and work with a frozen version of the nanoFramework. It may even not be possible at all. What a user should be able to do, per component:

  • Firmware from cloudsmith, nanoclr.exe and WIN_DLL_nanoCLR:

    • It should be easy to freeze the firmware packages, put them in an archive and use that archive instead of cloudsmith when deploying to devices - just as is possible with NuGet packages. This requires changes to nanoff - this PR covers those changes.
    • nanoclr.exe can already be frozen by installing it as a local rather than global tool (as it may be necessary that multiple versions of the tool have to co-exist on the same computer). The other nanoFramework tools need to use this version instead of the global tool. The proposal is to introduce a new configuration file, nano.devices.json, that lists the location of the local nanoclr.exe. That should be used by the existing tools:
      • Device Explorer, for starting a new Virtual nanoDevice. (via a future PR)
      • Test framework - this is part of the planned v3 version (future PR)
    • It makes sense to also archive WIN_DLL_nanoCLR and provide an option in nano.devices.json to use that runtime. The nanoclr.exe tool depends on third-party components, so there is a chance that nanoclr.exe stops working because of that dependency. As long as the new nanoclr.exe still works with the frozen WIN_DLL_nanoCLR, the user can update to a newer version of nanoclr.exe. But as nanoclr.exe may also have breaking changes, it is better to freeze both nanoclr.exe and WIN_DLL_nanoCLR.
  • NuGet packages:

    • Can be frozen. If the user fears that old versions of the packages disappear from nuget.org, NuGet has ways to archive the packages in use. No support from nanoFramework needed.
    • The user should use a specific version of the NuGet packages (the ones that are current at the time of the freeze). The list of current versions can easily be created (see documentation link above). NuGet does not offer a way to work with white-listed package versions; proposal is to have a nanoFramework MSBuild task (the subject of the Discord question - future PR, code is ready for a PR) that takes the whitelist from nano.devices.json and verifies that the correct NuGet package versions are included in a project.
    • The compatibility check of firmware and NuGet packages is: are the native assemblies (name, version, checksum) that are required by the NuGet packages implemented by the firmware of the device(s) the software is intended to be deployed to? That can be done if:
      • The native assemblies are known. This is already the case for NuGet/,NET assemblies, and the recent PR ensures it is available in nanoclr/WIN_DLL_nanoCLR and will be available for firmware packages in the near future.
      • Proprosal: the type of devices the software should be deployed to are mentioned in a configuration file per project (nano.devices.json)
      • Proposal: there is a MSBuild task (the subject of the Discord question - future PR, code is ready for a PR) that compares the required (NuGet/.NET) and available (firmware packages from the firmware archive) native implementations and generates errors in case of mismatches.
  • nanoff tool: this can be frozen by installing it as a local rather than global tool. The changes in this PR introduce a --suppressversioncheck option to suppress the version check that is not necessary if nanoff is frozen.

  • Visual Studio extension with the MSBuild system, templates and debugger. No changes needed now:

    • Extension/debugger/project templates are tied to the nfproj format and the wire protocol. These are stable. As long as there are no breaking changes, the extension can be updated and will still work with all versions of all other components. Requirement for nanoFramework is that if there are breaking changes (e.g., Sdk-style nfproj) the extension gets a different name so that the old version does not auto-update to the new, and new and old can co-exist. Anyway: if a user wants to archive a version of the VS extension and reinstall it later, that is possible without changes to the nanoFramework.
    • MSBuild components are part of the extension and are installed globally. That is fine, as long as there are no breaking changes. If there are breaking changes, an update to the version "v1.0" of the build system is sufficient.
  • The development environment for custom firmware. I presume this is all done by forking/branching in git. Not sure if there are other conponents to worry about (VSCode extensions?). I think custom firmware is a rather advance feature of nanoFramework, a "simple" user would not need to know about that. Out of scope for the moment.

Summary: PR

To get the controlled update strategy working, there are going to be several PRs:

  • The closed PR to make native assembly information available for firmware packages. Only remaining issue is to re-generate the firmware packages. Let's revisit that once all other work has been done.

  • This PR (1): firmware archive and nanoff without auto-update check.

  • Next PR (2) (the subject of the Discord question):

    • MSBuild task to verify that the versions of nanoFramework NuGet packages match the frozen version
    • MSBuild task to verify that the native assemblies required by the NuGet packages are implemented in the firmware of the devices the software is deployed to.
    • Library with the business logic for the task, also required to implement the PRs below. The library also implements a locking mechanism for the global nanoclr.exe, equivalent to the serial-port-locking-mechanism recently introduced in nf-debugger.

    The code for this PR is ready to be submitted, but which repository should it be in?

  • PR 3: Update to the Device Explorer to be able to start the Virtual nanoDevice that is specified in a solution-wide nano.devices.json. Also use the serial-port-lock mechanism from nf-debugger, and the nanoclr-update-lock from the library from the previous PR.

  • PRs for the test framework v3. The test framework should use the Virtual nanoDevice specified in nano.devices.json, so the PRs should wait for PR 2 to be closed, as the test framework will use the library of that PR.

  • PR for MSBuild NuGet package?

    The logical way to package the MSBuild task from PR 2 is to make a NuGet package that adds a build task to the nfproj file. This is simular to the solution chosen in test framework v3 for the test adapter (as that now consist of a lot of assemblies that should not be in the same directory as the nanoFramework test assembly). As mentioned in the Discord discussion, that does not seem to work. I don't think it is appropriate to let a user modify the nfproj file manually - a recipe for disaster. It would be better if nanoFramework would compensate for this and modify the nfproj file in an automated way. Not sure yet how to solve that.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass on review.
Overall, it looks good.

Too name changes and most of them "hide" the real and relevant ones. That's why it's preferreable to have atomic and focused PRs.

nanoFirmwareFlasher.Library/OutputWriter.cs Show resolved Hide resolved
nanoFirmwareFlasher.Library/OutputWriter.cs Outdated Show resolved Hide resolved
nanoFirmwareFlasher.Library/OutputWriter.cs Outdated Show resolved Hide resolved
nanoFirmwareFlasher.Library/FirmwareArchiveManager.cs Outdated Show resolved Hide resolved
nanoFirmwareFlasher.Tool/Program.cs Outdated Show resolved Hide resolved
nanoFirmwareFlasher.Tool/Program.cs Outdated Show resolved Hide resolved
nanoFirmwareFlasher.Tool/Program.cs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@josesimoes
Copy link
Member

@frobijn your description of the controlled update motivation and proposed solutions, despite valid, will get "lost" in this PR...
Better to have this on a doc, stored in the project's OneDrive, and the refer to it. I can create an empty doc and give you write access to it.

@frobijn
Copy link
Contributor Author

frobijn commented Sep 28, 2024

Too name changes and most of them "hide" the real and relevant ones.

Are you saying I should have split this up into multiple PR? E.g,. testability improvement. locking, extra options? That is not always easy. The work on the options came first, quite a while ago, but when I started to add unit tests I stumbles upon the testability issues. It's hard to work on multiple branches at the same time..

@frobijn
Copy link
Contributor Author

frobijn commented Sep 28, 2024

Too name changes and most of them "hide" the real and relevant ones.

Are you saying I should have split this up into multiple PR? E.g,. testability improvement. locking, extra options? That is not always easy. The work on the options came first, quite a while ago, but when I started to add unit tests I stumbles upon the testability issues. It's hard to work on multiple branches at the same time..

Please do, I didn't find a suitable place for that. Perhaps also make a document for the test framework v3.

@josesimoes
Copy link
Member

@frobijn URLs for the RFCs docs emailed to you.

Frank Robijn added 3 commits October 9, 2024 16:58
- Extra command line options added to *nanoFirmwareFlasher.Tool* and the implementation to *nanoFirmwareFlasher.Library* to download cloudsmith packages to a firmware archive, list the content of the archive, and deploy firmware from the archive to a device.

- Apart from firmware .zip packages, the .dll for the *WIN_DLL_nanoCLR* target can be downloaded and is placed in the archive in such a way if can be used as runtime for *nanoclr.exe*. Same for *WIN32_nanoCLR*, but that is probably not needed as firmware development is probably done in a fork of the nf-interpreter repository and based on the correct version of the CLR.

- Added a description of the new command line options to the README.md file

- Made some changes to *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library* so that the code can be tested:
    - *nanoFirmwareFlasher.Tests* is a friend of *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library*.
    - Use of new OutputWriter instead of Console. The OutputWriter's output can be collected per unit test even if they are executed in parallel
    - The location of the firmware archive can be set in unit tests

- Added unit tests to *nanoFirmwareFlasher.Tests* to test the affected code.

- Use nf-debugger's serial-port protection (GlobalExclusiveDeviceAccess).

- Added .editorconfig. This may have resulted in some changes to *nanoFirmwareFlasher.Tool* and *nanoFirmwareFlasher.Library*: update of the file header, use of explicit type instead of `var`.
@frobijn
Copy link
Contributor Author

frobijn commented Oct 9, 2024

@josesimoes all changes from review comments applied, plus exclusive access.

Copy link
Member

@josesimoes josesimoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for adding this. And for the rest of the improvements, of course. 👍🏻

@josesimoes josesimoes merged commit a35e67e into nanoframework:main Oct 9, 2024
5 checks passed
@Ellerbach
Copy link
Member

Seems that this PR broke the ability to run the tool on Linux platform. Is there anything obvious here?

@frobijn frobijn deleted the Versioning branch January 3, 2025 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants