Skip to content

Commit a59f518

Browse files
authored
Add support for updating CLR and deploy app using serial port (#210)
1 parent c631ecf commit a59f518

File tree

5 files changed

+376
-159
lines changed

5 files changed

+376
-159
lines changed

README.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,17 @@ The tool includes help for all available commands. You can see a list of all ava
8989
nanoff --help
9090
```
9191

92-
List of usage examples per platform:
92+
List of usage examples per platform and common options:
9393

9494
- [ESP32](#esp32-usage-examples)
9595
- [STM32](#stm32-usage-examples)
9696
- [TI CC13x2](#ti-cc13x2-usage-examples)
9797
- [Silabs Giant Gecko](#silabs-giant-gecko-usage-examples)
98+
- [Plain connection usage examples](#plain-connection-usage-examples)
9899
- [Common options](#common-options)
99100

101+
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.
102+
100103
## ESP32 usage examples
101104

102105
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:
@@ -301,6 +304,45 @@ This useful to list all Silabs devices that are connected through J-Link.
301304
nanoff --listjlink
302305
```
303306

307+
## Plain connection usage examples
308+
309+
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.
310+
311+
### Update the CLR of a nano device
312+
313+
To update the CLR of a nano device connected to a serial port to the latest available version.
314+
This will find the latest available firmware for the connected device and will update the CLR.
315+
316+
```console
317+
nanoff --nanodevice --update --serialport COM9
318+
```
319+
320+
### Deploy a managed application
321+
322+
To deploy (or update) a managed application, the path to the managed application has to be provided.
323+
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.
324+
325+
```console
326+
nanoff --nanodevice --deploy --serialport COM9 --image "c:\dev\my awesome app\bin\debug\my_awesome_app.bin"
327+
```
328+
329+
### Update the CLR of a nano device from a local file
330+
331+
To update the firmware of a nano device with a local firmware file (for example from a build).
332+
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.
333+
334+
```console
335+
nanoff --nanodevice --serialport COM9 --binfile "C:\nf-interpreter\build\nanoclr.bin"
336+
```
337+
338+
### Get details from a nano device
339+
340+
To get the details of a nano device connected to a serial port.
341+
342+
```console
343+
nanoff --nanodevice --devicedetails --serialport COM9
344+
```
345+
304346
## Common options
305347

306348
### Pre-check if target fits connected device

nanoFirmwareFlasher.Library/FirmwarePackageFactory.cs

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,18 @@
1-
using nanoFramework.Tools.Debugger;
1+
//
2+
// Copyright (c) .NET Foundation and Contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using nanoFramework.Tools.Debugger;
27
using System;
38

49
namespace nanoFramework.Tools.FirmwareFlasher
510
{
6-
//public class FirmwarePackage<T> : FirmwarePackageBase, IDisposable where T : new()
7-
//{
8-
// public Stm32Firmware DeviceFirmware { get; }
9-
10-
// public FirmwarePackage(NanoDeviceBase nanoDevice) : base(nanoDevice)
11-
// {
12-
// if (nanoDevice is null)
13-
// {
14-
// throw new ArgumentNullException(nameof(nanoDevice));
15-
// }
16-
17-
// if (nanoDevice.Platform.StartsWith("STM32"))
18-
// {
19-
// DeviceFirmware = new Stm32Firmware(
20-
// nanoDevice.TargetName,
21-
// "",
22-
// false);
23-
// }
24-
// else if (nanoDevice.Platform.StartsWith("STM32"))
25-
// {
26-
// DeviceFirmware = new JLinkFirmware(
27-
// nanoDevice.TargetName,
28-
// "",
29-
// false);
30-
31-
// }
32-
// }
33-
34-
// public FirmwarePackage(string targetName, string fwVersion, bool preview) : base(targetName, fwVersion, preview)
35-
// {
36-
// }
37-
38-
//}
3911
public class FirmwarePackageFactory
4012
{
41-
public static FirmwarePackage GetFirmwarePackage(NanoDeviceBase nanoDevice)
13+
public static FirmwarePackage GetFirmwarePackage(
14+
NanoDeviceBase nanoDevice,
15+
string fwVersion)
4216
{
4317
if (nanoDevice is null)
4418
{
@@ -49,14 +23,14 @@ public static FirmwarePackage GetFirmwarePackage(NanoDeviceBase nanoDevice)
4923
{
5024
return new Stm32Firmware(
5125
nanoDevice.TargetName,
52-
"",
26+
fwVersion,
5327
false);
5428
}
5529
else if (nanoDevice.Platform.StartsWith("GGECKO_S1"))
5630
{
5731
return new JLinkFirmware(
5832
nanoDevice.TargetName,
59-
"",
33+
fwVersion,
6034
false);
6135
}
6236
else

0 commit comments

Comments
 (0)