Skip to content

Commit

Permalink
Merge branch 'main' into fix-dependabot
Browse files Browse the repository at this point in the history
  • Loading branch information
networkfusion authored Jun 14, 2024
2 parents 6e5a5f2 + 0d2f7b4 commit 1425aaf
Show file tree
Hide file tree
Showing 81 changed files with 3,257 additions and 1,292 deletions.
1 change: 0 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
<configuration>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Azure Artifacts nanoFramework dev" value="https://pkgs.dev.azure.com/nanoframework/feed/_packaging/sandbox/nuget/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ To show the details of the ESP32 device connected to COM31.
nanoff --platform esp32 --serialport COM31 --devicedetails
```

Optionally an extra parameter `--checkpsram` can be passed, which forces the detection of PSRAM availability.

### Deploy a managed application to an ESP32 target

To deploy a managed application to an ESP32_PSRAM_REV0 target connected to COM31.
Expand Down Expand Up @@ -447,6 +449,50 @@ nanoff --listtargets --platform stm32

If you use the `--listtargets` switch in conjunction with `--preview`, you'll get the list of available firmware packages that are available with experimental or major feature changes.

## Deploy file to device storage

Some devices like ESP32, Orgpal and few others have storage available. Files can be deployed in this storage. You have to use the `filedeployment` parameter pointing on a JSON file to deploy files while flashing the device:

```console
nanoff --target XIAO_ESP32C3 --update --masserase --serialport COM21 --filedeployment C:\path\deploy.json
```

The JSON an optional `SerialPort` in case the port to upload the files must be different than the one to flash the device or not specified in the main command line and a **mandatory** list of `Files` entries. Each entry must contains `DestinationFilePath`, the destination full path file name and `SourceFilePath` to deploy content, otherwise to delete the file, the full path with file name of the source file to be deployed:

```json
{
"serialport":"COM42",
"files": [
{
"DestinationFilePath": "I:\\TestFile.txt",
"SourceFilePath": "C:\\tmp\\NFApp3\\NFApp3\\TestFile.txt"
},
{
"DestinationFilePath": "I:\\NoneFile.txt"
},
{
"DestinationFilePath": "I:\\wilnotexist.txt",
"SourceFilePath": "C:\\WRONGPATH\\TestFile.txt"
}
]
}
```

In the case you just want to deploy the files without any other operation, you can just specify:

```console
nanoff --filedeployment C:\path\deploy.json
```

In that case, the `SerialPort` must be present in the JSON file.

> [!Note]
> If a file already exists in the storage, it will be replaced by the new one.
>
> If a file does not exist and is requested to be deleted, nothing will happen, a warning will be displayed.
>
> If a file can't be uploaded because of a problem, the deployment of the other files will continue and an error will be displayed.
## Clear cache location

If needed one can clear the local cache from the firmware packages that are stored there.
Expand All @@ -462,6 +508,12 @@ nanoff --clearcache

The exit codes can be checked in [this source file](https://github.com/nanoframework/nanoFirmwareFlasher/blob/main/nanoFirmwareFlasher.Library/ExitCodes.cs).

## Telemetry

This tool is using anonymous telemetry to help us improve the usage. You can opt out by setting up an environment variable `NANOFRAMEWORK_TELEMETRY_OPTOUT` to 1.

The telemetry information is mainly related to the command line arguments, the firmware versions installed and any issue that can occurs during the code execution.

## Feedback and documentation

To provide feedback, report issues and finding out how to contribute please refer to the [Home repo](https://github.com/nanoframework/Home).
Expand Down
2 changes: 2 additions & 0 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ nanoff --update --target KALUGA_1 --serialport COM31 --clrfile "C:\nf-interprete
nanoff --platform esp32 --serialport COM31 --devicedetails
```

可选地,可以传递额外的参数 `--checkpsram`,它会强制检测PSRAM的可用性。

### 将托管应用程序部署到ESP32设备

将托管应用程序部署到连接到COM31的ESP32_PSRAM_REV0设备上。
Expand Down
66 changes: 48 additions & 18 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,17 @@ jobs:
vmImage: 'windows-latest'

variables:
DOTNET_NOLOGO: true
buildPlatform: 'x64'
buildConfiguration: 'Release'
solution: 'nanoFirmwareFlasher.sln'
run_update_dependents: $[dependencies.Check_Build_Options.outputs['BuildOptions.RUN_UPDATE_DEPENDENTS']]
- group: sign-client-credentials
- name: DOTNET_NOLOGO
value: true
- name: buildPlatform
value: 'x64'
- name: buildConfiguration
value: 'Release'
- name: solution
value: 'nanoFirmwareFlasher.sln'
- name: run_update_dependents
value: $[dependencies.Check_Build_Options.outputs['BuildOptions.RUN_UPDATE_DEPENDENTS']]

steps:

Expand All @@ -203,6 +209,11 @@ jobs:

- task: Cache@2
displayName: Cache NuGet packages
condition: >-
and(
succeeded(),
eq(variables['UPDATE_DEPENDENTS'], 'false')
)
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json, !bin/**'
restoreKeys: |
Expand Down Expand Up @@ -321,6 +332,21 @@ jobs:
eq(variables['UPDATE_DEPENDENTS'], 'false')
)
# Replace the intrument key
- powershell: |
. ./common.ps1
$fileToReplace = "$(System.DefaultWorkingDirectory)/nanoFirmwareFlasher.Tool\appsettings.json"
$sourceString = "INSTRUMENT_KEY"
$instrumentKey = "$(InstrumentKey)"
Find-ReplaceInFile -filePath $fileToReplace -sourceString $sourceString -targetString $instrumentKey
displayName: Replace intrument key
condition: >-
and(
succeeded(),
eq(variables['UPDATE_DEPENDENTS'], 'false')
)
- task: CopyFiles@1
condition: >-
and(
Expand All @@ -336,7 +362,7 @@ jobs:
flattenFolders: true

- task: DotNetCoreCLI@2
displayName: Install SignTool tool
displayName: Install Sign Client CLI
condition: >-
and(
succeeded(),
Expand All @@ -346,19 +372,21 @@ jobs:
inputs:
command: custom
custom: tool
arguments: install --tool-path . SignClient
arguments: install --tool-path . sign --version 0.9.1-beta.23530.1

- pwsh: |
.\SignClient "Sign" `
--baseDirectory "$(Build.ArtifactStagingDirectory)" `
--input "**/*.nupkg" `
--config "$(Build.Repository.LocalPath)\config\SignClient.json" `
--filelist "$(Build.Repository.LocalPath)\config\filelist.txt" `
--user "$(SignClientUser)" `
--secret '$(SignClientSecret)' `
--name ".NET nanoFramework firmware flasher" `
.\sign code azure-key-vault `
"**/*.nupkg" `
--base-directory "$(Build.ArtifactStagingDirectory)" `
--file-list "$(Build.Repository.LocalPath)\config\filelist.txt" `
--description ".NET nanoFramework firmware flasher" `
--descriptionUrl "https://github.com/$env:Build_Repository_Name"
--description-url "https://github.com/$env:Build_Repository_Name" `
--azure-key-vault-tenant-id "$(SignTenantId)" `
--azure-key-vault-client-id "$(SignClientId)" `
--azure-key-vault-client-secret "$(SignClientSecret)" `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)" `
--timestamp-url http://timestamp.digicert.com
displayName: Sign packages
continueOnError: true
condition: >-
Expand Down Expand Up @@ -388,7 +416,7 @@ jobs:
eq(variables['System.PullRequest.PullRequestId'], ''),
eq(variables['UPDATE_DEPENDENTS'], 'false')
)
displayName: Push nanoff NuGet package to NuGet
displayName: Push nanoff dotnet tool to NuGet
continueOnError: true
inputs:
command: push
Expand All @@ -406,7 +434,7 @@ jobs:
eq(variables['System.PullRequest.PullRequestId'], ''),
eq(variables['UPDATE_DEPENDENTS'], 'false')
)
displayName: Push library NuGet package to NuGet
displayName: Push NuGet package with library to NuGet
continueOnError: true
inputs:
command: push
Expand Down Expand Up @@ -435,6 +463,7 @@ jobs:
action: create
isDraft: false
addChangeLog: true
changeLogType: issueBased
changeLogLabels: |
[
{ "label" : "Type: bug", "displayName" : "Bugs fixed", "state" : "closed" },
Expand All @@ -448,6 +477,7 @@ jobs:
- task: PowerShell@2
condition: >-
or(
eq(variables['System.PullRequest.PullRequestId'], ''),
eq(variables['UPDATE_DEPENDENTS'], 'true'),
eq(variables['run_update_dependents'], 'true')
)
Expand Down
24 changes: 12 additions & 12 deletions azure-pipelines/update-dependents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# compute authorization header in format "AUTHORIZATION: basic 'encoded token'"
# 'encoded token' is the Base64 of the string "nfbot:personal-token"
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$env:GH_TOKEN"))))"
$auth = "basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("nfbot:$env:GH_TOKEN")))"

# init/reset these
$commitMessage = ""
Expand Down Expand Up @@ -55,21 +55,21 @@ $commitMessage += "`n[version update]`n`n"
# better add this warning line
$commitMessage += "### :warning: This is an automated update. Merge only after all tests pass. :warning:`n"

Write-Debug "Git branch"

# create branch to perform updates
git branch $newBranchName

Write-Debug "Checkout branch"

# checkout branch
git checkout $newBranchName

# check if anything was changed
$repoStatus = "$(git status --short --porcelain)"

if ($repoStatus -ne "")
{
Write-Debug "Git branch"

# create branch to perform updates
git branch $newBranchName

Write-Debug "Checkout branch"

# checkout branch
git checkout $newBranchName

Write-Debug "Add changes"

# commit changes
Expand Down Expand Up @@ -114,5 +114,5 @@ if ($repoStatus -ne "")
}
else
{
Write-Host "Nothing udpate at nanoFramework.Tools.FirmwareFlasher."
Write-Host "Nothing udpate at $repoName."
}
62 changes: 62 additions & 0 deletions common.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# Common functions used by the other scripts

function Check-DirectoryExists {
param (
[string]$rootDirectory
)

return Test-Path -Path $rootDirectory -PathType Container
}

function Find-ReplaceInFiles {
param (
[string]$rootDirectory,
[string]$sourceString,
[string]$targetString
)

Get-ChildItem -Recurse -File $rootDirectory | ForEach-Object {
$filePath = $_.FullName

Find-ReplaceInFile -filePath $filePath -sourceString $sourceString -targetString $targetString
}

Write-Host "String replacement completed."
}

function Find-ReplaceInFile {
param (
[string]$filePath,
[string]$sourceString,
[string]$targetString
)

# Get the original encoding of the file
$sr = New-Object System.IO.StreamReader($filePath, $true)
[char[]] $buffer = new-object char[] 3
$sr.Read($buffer, 0, 3)
$originalEncoding = $sr.CurrentEncoding
$sr.Close()

# Making it simple as we only want to preserve UTF8 encoding
if ( $originalEncoding.BodyName -eq "utf-8" ) {
$fileEncoding = "UTF8"
}
else {
$fileEncoding = "ASCII"
}

# Read the content of the file using the original encoding
$content = Get-Content -Path $filePath -Raw -Encoding $fileEncoding

# Perform the replacement
$newContent = $content -replace [regex]::Escape($sourceString), $targetString

if ($content -ne $newContent) {
Write-Host "Replacing in $filePath"

# Save the modified content back to the file using the original encoding
Set-Content -Path $filePath -Value $newContent -Encoding $fileEncoding
}
}
Binary file modified lib/esp32bootloader/bootloader.bin
Binary file not shown.
Binary file removed lib/esp32bootloader/partitions_16mb.bin
Binary file not shown.
Binary file modified lib/esp32bootloader/partitions_2mb.bin
Binary file not shown.
Binary file removed lib/esp32bootloader/partitions_8mb.bin
Binary file not shown.
Binary file modified lib/esp32bootloader/test_startup.bin
Binary file not shown.
Binary file modified lib/esp32s2bootloader/bootloader.bin
Binary file not shown.
Binary file removed lib/esp32s2bootloader/partitions_16mb.bin
Binary file not shown.
Binary file removed lib/esp32s2bootloader/partitions_8mb.bin
Binary file not shown.
Binary file modified lib/esp32s2bootloader/test_startup.bin
Binary file not shown.
Binary file added lib/esp32s3bootloader/bootloader.bin
Binary file not shown.
File renamed without changes.
Binary file added lib/esp32s3bootloader/test_startup.bin
Binary file not shown.
Binary file modified lib/esptool/esptoolLinux/esptool
Binary file not shown.
Binary file modified lib/esptool/esptoolMac/esptool
Binary file not shown.
Binary file modified lib/esptool/esptoolWin/esptool.exe
Binary file not shown.
Binary file modified lib/jlink/JLink.exe
Binary file not shown.
Binary file modified lib/jlink/JLink_x64.dll
Binary file not shown.
Binary file modified lib/jlinkLinux/JLinkExe
Binary file not shown.
Binary file modified lib/jlinkMac/JLinkExe
Binary file not shown.
3 changes: 0 additions & 3 deletions nanoFirmwareFlasher.Library/CC13x26x2Firmware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
// See LICENSE file in the project root for full license information.
//

using System.IO;
using System.Linq;

namespace nanoFramework.Tools.FirmwareFlasher
{
/// <summary>
Expand Down
5 changes: 2 additions & 3 deletions nanoFirmwareFlasher.Library/CC13x26x2Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace nanoFramework.Tools.FirmwareFlasher
{
Expand Down Expand Up @@ -119,15 +118,15 @@ public static async System.Threading.Tasks.Task<ExitCodes> UpdateFirmwareAsync(

ExitCodes programResult = ExitCodes.OK;
// write HEX files to flash
if (filesToFlash.Any(f => f.EndsWith(".hex")))
if (filesToFlash.Exists(f => f.EndsWith(".hex")))
{
programResult = ccDevice.FlashHexFiles(filesToFlash);
}

if (programResult == ExitCodes.OK && isApplicationBinFile)
{
// now program the application file
programResult = ccDevice.FlashBinFiles(new[] { applicationPath }, new[] { deploymentAddress });
programResult = ccDevice.FlashBinFiles([applicationPath], [deploymentAddress]);
}

if (updateFw)
Expand Down
Loading

0 comments on commit 1425aaf

Please sign in to comment.