Skip to content

Commit

Permalink
Add support for updating CLR and deploy app using serial port (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Apr 27, 2023
1 parent c631ecf commit a59f518
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 159 deletions.
44 changes: 43 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ The tool includes help for all available commands. You can see a list of all ava
nanoff --help
```

List of usage examples per platform:
List of usage examples per platform and common options:

- [ESP32](#esp32-usage-examples)
- [STM32](#stm32-usage-examples)
- [TI CC13x2](#ti-cc13x2-usage-examples)
- [Silabs Giant Gecko](#silabs-giant-gecko-usage-examples)
- [Plain connection usage examples](#plain-connection-usage-examples)
- [Common options](#common-options)

Note that it's possible to combine multiple options if those operations are supported by the platforms, e.g. update the CLR and deploy a managed application in the same execution.

## ESP32 usage examples

There are multiple ESP32 images available, some are build specifically for a target. Please check out the [list](https://github.com/nanoframework/nf-interpreter#firmware-for-reference-boards). You will need as well to know the COM port used by your device. Find [how to do this here](#finding-the-device-com-port-on-windows). Alternatively, you can as well list the available COM ports. If you list them first without the device to flash and then plugging the device, the additional port which will show up is the one for the device to flash. This method works for all OS:
Expand Down Expand Up @@ -301,6 +304,45 @@ This useful to list all Silabs devices that are connected through J-Link.
nanoff --listjlink
```

## Plain connection usage examples

It's possible to update a nano device using the same connection that is used for Visual Studio connection, meaning that no specialized connection is required (like JTAG, or JLink). This is only possible if the device has previously been flashed with a working nanoFramework firmware.

### Update the CLR of a nano device

To update the CLR of a nano device connected to a serial port to the latest available version.
This will find the latest available firmware for the connected device and will update the CLR.

```console
nanoff --nanodevice --update --serialport COM9
```

### Deploy a managed application

To deploy (or update) a managed application, the path to the managed application has to be provided.
This example uses the binary format file that is generated by Visual Studio when building any nanoFramework C# application. Because it's possible to retrieve all the required details from the connected device no other configuration is required.

```console
nanoff --nanodevice --deploy --serialport COM9 --image "c:\dev\my awesome app\bin\debug\my_awesome_app.bin"
```

### Update the CLR of a nano device from a local file

To update the firmware of a nano device with a local firmware file (for example from a build).
This file has to be a binary file with a valid nanoCLR from a build. No checks or validations are performed on the file content.

```console
nanoff --nanodevice --serialport COM9 --binfile "C:\nf-interpreter\build\nanoclr.bin"
```

### Get details from a nano device

To get the details of a nano device connected to a serial port.

```console
nanoff --nanodevice --devicedetails --serialport COM9
```

## Common options

### Pre-check if target fits connected device
Expand Down
48 changes: 11 additions & 37 deletions nanoFirmwareFlasher.Library/FirmwarePackageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,18 @@
using nanoFramework.Tools.Debugger;
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

using nanoFramework.Tools.Debugger;
using System;

namespace nanoFramework.Tools.FirmwareFlasher
{
//public class FirmwarePackage<T> : FirmwarePackageBase, IDisposable where T : new()
//{
// public Stm32Firmware DeviceFirmware { get; }

// public FirmwarePackage(NanoDeviceBase nanoDevice) : base(nanoDevice)
// {
// if (nanoDevice is null)
// {
// throw new ArgumentNullException(nameof(nanoDevice));
// }

// if (nanoDevice.Platform.StartsWith("STM32"))
// {
// DeviceFirmware = new Stm32Firmware(
// nanoDevice.TargetName,
// "",
// false);
// }
// else if (nanoDevice.Platform.StartsWith("STM32"))
// {
// DeviceFirmware = new JLinkFirmware(
// nanoDevice.TargetName,
// "",
// false);

// }
// }

// public FirmwarePackage(string targetName, string fwVersion, bool preview) : base(targetName, fwVersion, preview)
// {
// }

//}
public class FirmwarePackageFactory
{
public static FirmwarePackage GetFirmwarePackage(NanoDeviceBase nanoDevice)
public static FirmwarePackage GetFirmwarePackage(
NanoDeviceBase nanoDevice,
string fwVersion)
{
if (nanoDevice is null)
{
Expand All @@ -49,14 +23,14 @@ public static FirmwarePackage GetFirmwarePackage(NanoDeviceBase nanoDevice)
{
return new Stm32Firmware(
nanoDevice.TargetName,
"",
fwVersion,
false);
}
else if (nanoDevice.Platform.StartsWith("GGECKO_S1"))
{
return new JLinkFirmware(
nanoDevice.TargetName,
"",
fwVersion,
false);
}
else
Expand Down
Loading

0 comments on commit a59f518

Please sign in to comment.