KSociety.SharpCubeProgrammer 0.2.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package KSociety.SharpCubeProgrammer --version 0.2.4                
NuGet\Install-Package KSociety.SharpCubeProgrammer -Version 0.2.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KSociety.SharpCubeProgrammer" Version="0.2.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KSociety.SharpCubeProgrammer --version 0.2.4                
#r "nuget: KSociety.SharpCubeProgrammer, 0.2.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install KSociety.SharpCubeProgrammer as a Cake Addin
#addin nuget:?package=KSociety.SharpCubeProgrammer&version=0.2.4

// Install KSociety.SharpCubeProgrammer as a Cake Tool
#tool nuget:?package=KSociety.SharpCubeProgrammer&version=0.2.4                

Logo

build status NuGet download count KSociety.SharpCubeProgrammer Home

KSociety.SharpCubeProgrammer

KSociety.SharpCubeProgrammer is a wrapper for CubeProgrammer_API v2.15.0.

It makes use of several 3rd party tools:

  • STM32 Cube Programmer You can find the source, licensing information and documentation here.

Introduction

This is a C# wrapper for STM32 CubeProgrammer_API v2.15.0 (not fully tested). This package does not contain any C/C++ runtimes (MSVC), and is meant to run on Windows operating systems only (for now). Please make sure you have updated the firmware of your ST-LINK V2 / V3, you can do this using STM32CubeProgrammer. The STM32 CubeProgrammer_API is a C-library, created by ST for ST-Link access to micro-controllers for the purpose of flash downloads or general memory access. The ST-Link drivers is required, and can be downloaded from st.com and installed (STSW-LINK009). This has been tested on Windows 10, you don't need to install cubeprogrammer.

KSociety.SharpCubeProgrammer

STM32CubeProgrammer_API C# wrapper, the first wrapper for C#. Any suggestions are welcome.

Get Packages

You can get KSociety.SharpCubeProgrammer by grabbing the latest NuGet package.

Currently supported features

  • GetStLinkList
  • GetStLinkEnumerationList
  • ConnectStLink
  • Reset

Bootloader functions

  • GetDfuDeviceList
  • ConnectDfuBootloader

General purposes functions

  • SetDisplayCallbacks
  • SetVerbosityLevel
  • CheckDeviceConnection
  • GetDeviceGeneralInf
  • ReadMemory
  • WriteMemory
  • EditSector
  • DownloadFile
  • Execute
  • MassErase
  • SectorErase
  • ReadUnprotect
  • TzenRegression (does not exist)
  • GetTargetInterfaceType
  • GetCancelPointer
  • FileOpen
  • Verify
  • VerifyMemory
  • SaveFileToFile
  • SaveMemoryToFile
  • Disconnect
  • DeleteInterfaceList
  • AutomaticMode
  • GetStorageStructure

Option Bytes functions

  • SendOptionBytesCmd
  • InitOptionBytesInterface
  • FastRomInitOptionBytesInterface
  • ObDisplay

Loaders functions

  • SetLoadersPath
  • SetExternalLoaderPath
  • GetExternalLoaders
  • RemoveExternalLoader
  • DeleteLoaders

STM32WB specific functions

  • GetUID64
  • FirmwareDelete
  • FirmwareUpgrade
  • StartWirelessStack
  • UpdateAuthKey
  • AuthKeyLock
  • WriteUserKey
  • AntiRollBack
  • StartFus
  • UnlockChip

STM32MP specific functions

  • ProgramSsp

STM32 HSM specific functions

  • GetHsmFirmwareID
  • GetHsmCounter
  • GetHsmState
  • GetHsmVersion
  • GetHsmType
  • GetHsmLicense

Prerequisites

  • Visual Studio 2022 (17.8.3 or higher) with the following installed:
Workloads
.NET desktop development
Desktop development with C++
Individual components
MSVC v143 - VS 2022 C++ x64/x86

Get Started

  • Register SharpCubeProgrammer as service with Autofac IoC:

Create the module for Autofac in a dedicated file (in this example under the Bindings folder) with the following contents:

namespace MyNamespace.Bindings
{
    using Autofac;
    using KSociety.SharpCubeProgrammer;
    using KSociety.SharpCubeProgrammer.Interface;

    public class ProgrammerApi : Module
    {
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType<CubeProgrammerApi>().As<ICubeProgrammerApi>().SingleInstance();
        }
    }
}

Register the module:

builder.RegisterModule(new Bindings.ProgrammerApi());
  • Connect:
var tryConnectionResult = CubeProgrammerApi.TryConnectStLink();
  • General Info:
var generalInfo = _cubeProgrammerApi.GetDeviceGeneralInf();
  • Erase:
var massErase = _cubeProgrammerApi.MassErase("");
  • Flash:
var downloadFile = _cubeProgrammerApi.DownloadFile(firmwarePath, "0x08000000", 1U, 1U);
  • Run:
var execute = _cubeProgrammerApi.Execute("0x08000000");
  • Send Option Bytes:
var sendOptionBytesCmd = CubeProgrammerApi.SendOptionBytesCmd("-ob RDP=170");
  • Disconnect:
CubeProgrammerApi.Disconnect();

License

The project is under Microsoft Reciprocal License (MS-RL)

Dependencies

List of technologies, frameworks and libraries used for implementation:

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.50 190 10/22/2024
0.3.47 206 10/16/2024
0.3.32 362 8/20/2024
0.3.20 394 5/16/2024
0.3.9 445 3/20/2024
0.2.71 197 2/24/2024
0.2.59 172 2/13/2024
0.2.4 194 1/17/2024
0.1.70 192 1/8/2024
0.1.59 242 12/15/2023
0.1.49 239 11/29/2023
0.1.29 220 11/21/2023
0.1.13 175 11/5/2023
0.0.80 200 10/20/2023
0.0.43 163 10/12/2023
0.0.40 162 10/5/2023
0.0.38 177 10/5/2023
0.0.33 179 10/4/2023
0.0.27 189 10/3/2023
0.0.25 188 10/2/2023