Skip to content

Commit 6177edd

Browse files
authored
Merge pull request #23 from nanoframework/release-v1.5.0
Release release-v1.5.0
2 parents d5d164c + f8a242f commit 6177edd

File tree

280 files changed

+50767
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+50767
-259
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ Is part of **nanoFramework** toolbox, along with other various tools that are re
1313
It makes use of several 3rd party tools:
1414

1515
- Espressif esptool.
16-
You can find the esptool and licensing information on the repository [here](http://github.com/espressif/esptool).
16+
You can find the esptool and licensing information on the repository [here](http://github.com/espressif/esptool).
1717
- ST DfuSe USB.
1818
You can find the source, licensing information and documentation [here](https://www.st.com/en/development-tools/stsw-stm32080.html).
1919
- ST-LINK Utility.
2020
You can find the source, licensing information and documentation [here](https://www.st.com/content/st_com/en/products/development-tools/software-development-tools/stm32-software-development-tools/stm32-programmers/stsw-link004.html).
21+
- Texas Instruments Uniflash
22+
You can find the Uniflash tool and licensing information [here](http://www.ti.com/tool/download/UNIFLASH).
2123

2224
## Install **nanoFramework** Firmware Flasher
2325

@@ -132,6 +134,22 @@ This useful to list all STM32 devices that are connected through DFU.
132134
nanoff --listdfu
133135
```
134136

137+
### Update the firmware of a specific TI CC13x2 target
138+
139+
To update the firmware of the TI_CC1352R1_LAUNCHXL target to the latest available stable version.
140+
141+
```console
142+
nanoff --update --target TI_CC1352R1_LAUNCHXL --stable
143+
```
144+
145+
### Install the XDS110 USB drivers required by TI LaunchPad targets
146+
147+
To install the XDS110 USB drivers.
148+
149+
```console
150+
nanoff --platform cc13x2 --installdrivers
151+
```
152+
135153
### Tool output verbosity
136154

137155
The tool output verbosity can be set through the `v|verbosity` option.

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ jobs:
160160
workingDirectory: source
161161
displayName: Restore NuGet packages
162162

163-
- script: dotnet build -c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack"
163+
- script: dotnet build -c $(BuildConfiguration) /p:PublicRelease=true --no-restore /t:build,pack
164164
workingDirectory: source
165165
displayName: Build NuGet package
166166

@@ -311,7 +311,7 @@ jobs:
311311
githubReleaseDraft: false
312312
githubReleasePrerelease: false
313313
githubReuseDraftOnly: false
314-
githubReuseRelease: false
314+
githubReuseRelease: true
315315
githubEditRelease: false
316316
githubDeleteEmptyTag: true
317317
githubReleaseAsset: '$(Build.ArtifactStagingDirectory)/$(nugetPackageName).$(MY_NUGET_VERSION).nupkg'
Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,295 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Text.RegularExpressions;
8+
9+
namespace nanoFramework.Tools.FirmwareFlasher
10+
{
11+
internal class CC13x26x2Device
12+
{
13+
/// <summary>
14+
/// Configuration file for the device to connect to.
15+
/// </summary>
16+
public string ConfigurationFile { get; }
17+
18+
/// <summary>
19+
/// Option to output progress messages.
20+
/// Default is <see langword="true"/>.
21+
/// </summary>
22+
public VerbosityLevel Verbosity { get; internal set; } = VerbosityLevel.Normal;
23+
24+
/// <summary>
25+
/// Property with option for performing mass erase on the connected device.
26+
/// If <see langword="false"/> only the flash sectors that will programmed are erased.
27+
/// </summary>
28+
public bool DoMassErase { get; set; } = false;
29+
30+
/// <summary>
31+
/// Creates a new <see cref="CC13x26x2Device"/>.
32+
/// </summary>
33+
public CC13x26x2Device(string configurationFile)
34+
{
35+
ConfigurationFile = configurationFile;
36+
}
37+
38+
/// <summary>
39+
/// Flash the HEX supplied to the connected device.
40+
/// </summary>
41+
/// <param name="files"></param>
42+
public ExitCodes FlashHexFiles(IEnumerable<string> files)
43+
{
44+
// check file existence
45+
foreach (string f in files)
46+
{
47+
if (!File.Exists(f))
48+
{
49+
return ExitCodes.E5003;
50+
}
51+
}
52+
53+
string cliOuput;
54+
55+
// TODO
56+
// use the -d switch
57+
//// erase flash
58+
//if (DoMassErase)
59+
//{
60+
// if (Verbosity >= VerbosityLevel.Normal)
61+
// {
62+
// Console.Write("Mass erase device...");
63+
// }
64+
65+
// cliOuput = RunUniflashCli($"-c SN={DeviceId} UR -ME");
66+
67+
// if (!cliOuput.Contains("Flash memory erased."))
68+
// {
69+
// return ExitCodes.E5005;
70+
// }
71+
72+
// if (Verbosity >= VerbosityLevel.Normal)
73+
// {
74+
// Console.WriteLine(" OK");
75+
// }
76+
// else
77+
// {
78+
// Console.WriteLine("");
79+
// }
80+
81+
// // toggle mass erase so it's only performed before the first file is flashed
82+
// DoMassErase = false;
83+
//}
84+
85+
if (Verbosity == VerbosityLevel.Normal)
86+
{
87+
Console.Write("Flashing device...");
88+
}
89+
else if (Verbosity >= VerbosityLevel.Detailed)
90+
{
91+
Console.WriteLine("Flashing device...");
92+
}
93+
94+
// program HEX file(s)
95+
foreach (string hexFile in files)
96+
{
97+
if (Verbosity >= VerbosityLevel.Detailed)
98+
{
99+
Console.WriteLine($"{Path.GetFileName(hexFile)}");
100+
}
101+
102+
cliOuput = RunUniflashCli($" flash -c {ConfigurationFile} -f -v {hexFile}");
103+
104+
if (!cliOuput.Contains("Program verification successful"))
105+
{
106+
return ExitCodes.E5006;
107+
}
108+
}
109+
110+
if (Verbosity == VerbosityLevel.Normal)
111+
{
112+
Console.WriteLine(" OK");
113+
}
114+
else if (Verbosity >= VerbosityLevel.Detailed)
115+
{
116+
Console.WriteLine("Flashing completed...");
117+
}
118+
119+
return ExitCodes.OK;
120+
}
121+
122+
/// <summary>
123+
/// Flash the BIN supplied to the connected device.
124+
/// </summary>
125+
/// <param name="files"></param>
126+
/// <param name="addresses"></param>
127+
public ExitCodes FlashBinFiles(IEnumerable<string> files, IEnumerable<string> addresses)
128+
{
129+
// check file existence
130+
foreach (string f in files)
131+
{
132+
if (!File.Exists(f))
133+
{
134+
return ExitCodes.E5003;
135+
}
136+
}
137+
138+
// check address(es)
139+
140+
// need to match files count
141+
if(files.Count() != addresses.Count())
142+
{
143+
return ExitCodes.E5009;
144+
}
145+
146+
foreach (string address in addresses)
147+
{
148+
if (string.IsNullOrEmpty(address))
149+
{
150+
return ExitCodes.E5007;
151+
}
152+
else
153+
{
154+
// format too
155+
if (!address.StartsWith("0x"))
156+
{
157+
return ExitCodes.E5008;
158+
}
159+
160+
// try parse
161+
// need to remove the leading 0x and to specify that hexadecimal values are allowed
162+
int dummyAddress;
163+
if (!int.TryParse(address.Substring(2), System.Globalization.NumberStyles.AllowHexSpecifier, System.Globalization.CultureInfo.InvariantCulture, out dummyAddress))
164+
{
165+
return ExitCodes.E5008;
166+
}
167+
}
168+
}
169+
170+
string cliOuput;
171+
172+
// TODO
173+
// use the -d switch
174+
//// erase flash
175+
//if (DoMassErase)
176+
//{
177+
// if (Verbosity >= VerbosityLevel.Normal)
178+
// {
179+
// Console.Write("Mass erase device...");
180+
// }
181+
182+
// cliOuput = RunUniflashCli($"-b");
183+
184+
// if (!cliOuput.Contains("Flash memory erased."))
185+
// {
186+
// Console.WriteLine("");
187+
// return ExitCodes.E5005;
188+
// }
189+
190+
// if (Verbosity >= VerbosityLevel.Normal)
191+
// {
192+
// Console.WriteLine(" OK");
193+
// }
194+
// else
195+
// {
196+
// Console.WriteLine("");
197+
// }
198+
199+
// // toggle mass erase so it's only performed before the first file is flashed
200+
// DoMassErase = false;
201+
//}
202+
203+
if (Verbosity == VerbosityLevel.Normal)
204+
{
205+
Console.Write("Flashing device...");
206+
}
207+
else if (Verbosity >= VerbosityLevel.Detailed)
208+
{
209+
Console.WriteLine("Flashing device...");
210+
}
211+
212+
// program BIN file(s)
213+
int index = 0;
214+
foreach (string binFile in files)
215+
{
216+
if (Verbosity >= VerbosityLevel.Detailed)
217+
{
218+
Console.WriteLine($"{Path.GetFileName(binFile)} @ {addresses.ElementAt(index)}");
219+
}
220+
221+
cliOuput = RunUniflashCli($" flash -c {ConfigurationFile} -f -v {binFile},{addresses.ElementAt(index++)}");
222+
223+
if (!cliOuput.Contains("Program verification successful"))
224+
{
225+
return ExitCodes.E5006;
226+
}
227+
}
228+
229+
if (Verbosity == VerbosityLevel.Normal)
230+
{
231+
Console.WriteLine(" OK");
232+
}
233+
else if (Verbosity >= VerbosityLevel.Detailed)
234+
{
235+
Console.WriteLine("Flashing completed...");
236+
}
237+
238+
return ExitCodes.OK;
239+
}
240+
241+
/// <summary>
242+
/// Reset MCU of connected CC13x2 device.
243+
/// </summary>
244+
public ExitCodes ResetMcu()
245+
{
246+
// try to connect to device with RESET
247+
var cliOuput = RunUniflashCli($" flash -c {ConfigurationFile} -r 0");
248+
249+
if (!cliOuput.Contains("CPU Reset is issued"))
250+
{
251+
Console.WriteLine("");
252+
return ExitCodes.E5010;
253+
}
254+
255+
if (Verbosity >= VerbosityLevel.Normal)
256+
{
257+
Console.WriteLine(" OK");
258+
}
259+
else
260+
{
261+
Console.WriteLine("");
262+
}
263+
264+
return ExitCodes.OK;
265+
}
266+
267+
private static string RunUniflashCli(string arguments)
268+
{
269+
try
270+
{
271+
Process uniflashCli = new Process();
272+
uniflashCli.StartInfo = new ProcessStartInfo(Path.Combine(Program.ExecutingPath, "uniflash\\DebugServer\\bin", "DSLite.exe"), arguments)
273+
{
274+
WorkingDirectory = Path.Combine(Program.ExecutingPath, "uniflash"),
275+
UseShellExecute = false,
276+
RedirectStandardOutput = true,
277+
};
278+
279+
280+
// start Uniflash CLI and...
281+
uniflashCli.Start();
282+
283+
// ... wait for exit
284+
uniflashCli.WaitForExit();
285+
286+
// collect output messages
287+
return uniflashCli.StandardOutput.ReadToEnd();
288+
}
289+
catch(Exception ex)
290+
{
291+
throw new UniflashCliExecutionException(ex.Message);
292+
}
293+
}
294+
}
295+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) 2019 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
using System.IO;
7+
using System.Linq;
8+
9+
namespace nanoFramework.Tools.FirmwareFlasher
10+
{
11+
/// <summary>
12+
/// Class that handles the download of STM32 firmware files from Bintray.
13+
/// </summary>
14+
internal class CC13x26x2Firmware : FirmwarePackage
15+
{
16+
public string nanoCLRFile { get; internal set; }
17+
18+
public CC13x26x2Firmware(string targetName, string fwVersion, bool stable)
19+
:base(targetName, fwVersion, stable)
20+
{
21+
}
22+
23+
internal new async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
24+
{
25+
// perform download and extract
26+
var executionResult = await base.DownloadAndExtractAsync();
27+
28+
if (executionResult == ExitCodes.OK)
29+
{
30+
nanoCLRFile = Directory.EnumerateFiles(LocationPath, "nanoCLR.hex").FirstOrDefault();
31+
}
32+
33+
return executionResult;
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)