{"id":25398018,"url":"https://github.com/k-society/ksociety.sharpcubeprogrammer","last_synced_at":"2025-07-20T17:04:06.859Z","repository":{"id":197953459,"uuid":"699705686","full_name":"K-Society/KSociety.SharpCubeProgrammer","owner":"K-Society","description":"STM32 CubeProgrammer_API C# wrapper","archived":false,"fork":false,"pushed_at":"2025-07-16T06:52:40.000Z","size":77432,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-17T09:46:21.051Z","etag":null,"topics":["csharp","cubeprogrammer","cubeprogrammerapi","k-society","ksociety","programmer","sharpcubeprogrammer","st-link","stlink","stm32","stm32cubeprogrammer-api","stm32programmer","wrapper"],"latest_commit_sha":null,"homepage":"https://k-society.github.io/KSociety.SharpCubeProgrammer","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/K-Society.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-10-03T07:10:34.000Z","updated_at":"2025-07-09T09:00:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"dee624a8-0149-4138-8434-d9b6fa3ee0bd","html_url":"https://github.com/K-Society/KSociety.SharpCubeProgrammer","commit_stats":null,"previous_names":["k-society/ksociety.sharpcubeprogrammer"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/K-Society/KSociety.SharpCubeProgrammer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Society%2FKSociety.SharpCubeProgrammer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Society%2FKSociety.SharpCubeProgrammer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Society%2FKSociety.SharpCubeProgrammer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Society%2FKSociety.SharpCubeProgrammer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/K-Society","download_url":"https://codeload.github.com/K-Society/KSociety.SharpCubeProgrammer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/K-Society%2FKSociety.SharpCubeProgrammer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266161868,"owners_count":23885924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","cubeprogrammer","cubeprogrammerapi","k-society","ksociety","programmer","sharpcubeprogrammer","st-link","stlink","stm32","stm32cubeprogrammer-api","stm32programmer","wrapper"],"created_at":"2025-02-15T22:32:10.661Z","updated_at":"2025-07-20T17:04:06.853Z","avatar_url":"https://github.com/K-Society.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Logo](https://raw.githubusercontent.com/k-society/KSociety.SharpCubeProgrammer/master/docs/K-Society__Logo_vs-negative.png)](https://github.com/K-Society)\n\n\n[![build status](https://img.shields.io/github/actions/workflow/status/K-Society/KSociety.SharpCubeProgrammer/build.yml?branch=develop)](https://github.com/K-Society/KSociety.SharpCubeProgrammer/actions/workflows/build.yml?query=branch%3Adevelop) \n[![latest version](https://img.shields.io/nuget/v/KSociety.SharpCubeProgrammer)](https://www.nuget.org/packages/KSociety.SharpCubeProgrammer)\n[![download count](https://img.shields.io/nuget/dt/KSociety.SharpCubeProgrammer)](https://www.nuget.org/stats/packages/KSociety.SharpCubeProgrammer?groupby=Version)\n\n\n[KSociety.SharpCubeProgrammer Home](https://github.com/K-Society/KSociety.SharpCubeProgrammer)\n\n# KSociety.SharpCubeProgrammer\n\nKSociety.SharpCubeProgrammer is a wrapper for CubeProgrammer_API v2.20.0.\n\n\nFirst unofficial and open source C# wrapper.\n\n\nIt makes use of several 3rd party tools:\n\n- STM32 Cube Programmer\n   You can find the source, licensing information and documentation [here](https://www.st.com/en/development-tools/stm32cubeprog.html).\n\n## Introduction\n\nThis is a C# wrapper for STM32 CubeProgrammer_API v2.20.0 (not fully tested).\nThis package does not contain any C/C++ runtimes (MSVC), and is meant to run on Windows operating systems only (for now).\nPlease make sure you have updated the firmware of your ST-LINK V2 / V3, you can do this using STM32CubeProgrammer.\nSTM32 CubeProgrammer_API is a C library created by ST to manage microcontrollers, it allows to access memory for reading and writing and to manage option bytes.\nThe ST-Link drivers is required, and can be downloaded from st.com and installed [(STSW-LINK009)](https://www.st.com/en/development-tools/stsw-link009.html).\nThis has been tested on Windows 10 and Windows 11, you don't need to install STM32CubeProgrammer.\n\n### KSociety.SharpCubeProgrammer\nSTM32CubeProgrammer_API C# wrapper, the first wrapper for C#. Any suggestions are welcome.\n\n## Get Packages\n\nYou can get KSociety.SharpCubeProgrammer by [grabbing the latest NuGet package](https://www.nuget.org/packages/KSociety.SharpCubeProgrammer/).\nYou need to use _PackageReference_, otherwise some contents will not be copied to the output folder and consequently it will not work.\n\n## Currently supported features\n\nAll functions also exist in an asynchronous version.\n\n## STLINK functions\n- GetStLinkList\n- GetStLinkEnumerationList\n- ConnectStLink\n- Reset\n\n## Bootloader functions \n- GetUsartList\n- ConnectUsartBootloader\n- SendByteUart\n- GetDfuDeviceList\n- ConnectDfuBootloader\n- ConnectDfuBootloader2\n- ConnectSpiBootloader\n- ConnectCanBootloader\n- ConnectI2CBootloader\n\n## General purposes functions\n- SetDisplayCallbacks\n- SetVerbosityLevel\n- CheckDeviceConnection\n- GetDeviceGeneralInf\n- ReadMemory\n- WriteMemory\n- WriteMemoryAutoFill\n- WriteMemoryAndVerify\n- EditSector\n- DownloadFile\n- Execute\n- MassErase\n- SectorErase\n- ReadUnprotect\n- TzenRegression (does not exist)\n- GetTargetInterfaceType\n- GetCancelPointer\n- FileOpen\n- Verify\n- VerifyMemory\n- SaveFileToFile\n- SaveMemoryToFile\n- Disconnect\n- DeleteInterfaceList\n- AutomaticMode\n- GetStorageStructure\n\n## Option Bytes functions\n- SendOptionBytesCmd\n- InitOptionBytesInterface\n- FastRomInitOptionBytesInterface\n- ObDisplay\n\n## Loaders functions\n- SetLoadersPath\n- SetExternalLoaderPath\n- GetExternalLoaders\n- RemoveExternalLoader\n- DeleteLoaders\n\n## STM32WB specific functions\n- GetUID64\n- FirmwareDelete\n- FirmwareUpgrade\n- StartWirelessStack\n- UpdateAuthKey\n- AuthKeyLock\n- WriteUserKey\n- AntiRollBack\n- StartFus\n- UnlockChip\n\n## STM32MP specific functions\n- ProgramSsp\n\n## STM32 HSM specific functions\n- GetHsmFirmwareID\n- GetHsmCounter\n- GetHsmState\n- GetHsmVersion\n- GetHsmType\n- GetHsmLicense\n\n## Prerequisites\n\n- Visual Studio 2022 (17.12.1 or higher) with the following installed:\n\n| Workloads |\n| :-------- |\n| .NET desktop development |\n| Desktop development with C++ |\n\n| Individual components |\n| :-------------------- |\n| MSVC v143 - VS 2022 C++ x64/x86 |\n\n## Get Started\n\nExamples include the [QuickStart](https://github.com/K-Society/KSociety.SharpCubeProgrammer/tree/master/src/01/Samples/QuickStart) project, is a very basic example.\n\n- Creates a new instance of the CharpCubeProgrammer class:\n\n```csharp\nvar cubeProgrammerApi = new SharpCubeProgrammer.CubeProgrammerApi();\n```\n\n- Set up the logging system:\n\n```csharp\nvar displayCallBacks = new DisplayCallBacks\n{\n    InitProgressBar = InitProgressBar,\n    LogMessage = ReceiveMessage,\n    LoadBar = ProgressBarUpdate\n};\n\ncubeProgrammerApi.SetDisplayCallbacks(displayCallBacks);\n\ncubeProgrammerApi.SetVerbosityLevel(CubeProgrammerVerbosityLevel.CubeprogrammerVerLevelDebug);\n```\n\n- Retrieves all ST-LINK connected probes:\n\n```csharp\nvar stLinkList = cubeProgrammerApi.GetStLinkEnumerationList();\n```\n\nor\n\n```csharp\nvar stLinkList = await cubeProgrammerApi.GetStLinkEnumerationListAsync();\n```\n\n- Connect:\n\n```csharp\nif (stLinkList.Any())\n{\n    var stLink = stLinkList.First();\n    stLink.ConnectionMode = DebugConnectionMode.UnderResetMode;\n    stLink.Shared = 0;\n\n    var connectionResult = cubeProgrammerApi.ConnectStLink(stLink);\n\n    //...\n\n}\nelse\n{\n    Console.WriteLine(\"No ST-Link found!\");\n}\n```\n\n- Retrieve general info:\n\n```csharp\nif (connectionResult.Equals(CubeProgrammerError.CubeprogrammerNoError))\n{\n    var generalInfo = cubeProgrammerApi.GetDeviceGeneralInf();\n    if (generalInfo != null)\n    {\n        Console.WriteLine(\"INFO: \\n\" +\n                            \"Board: {0} \\n\" +\n                            \"Bootloader Version: {1} \\n\" +\n                            \"Cpu: {2} \\n\" +\n                            \"Description: {3} \\n\" +\n                            \"DeviceId: {4} \\n\" +\n                            \"FlashSize: {5} \\n\" +\n                            \"RevisionId: {6} \\n\" +\n                            \"Name: {7} \\n\" +\n                            \"Series: {8} \\n\" +\n                            \"Type: {9}\",\n            generalInfo.Value.Board,\n            generalInfo.Value.BootloaderVersion,\n            generalInfo.Value.Cpu,\n            generalInfo.Value.Description,\n            generalInfo.Value.DeviceId,\n            generalInfo.Value.FlashSize,\n            generalInfo.Value.RevisionId,\n            generalInfo.Value.Name,\n            generalInfo.Value.Series,\n            generalInfo.Value.Type);\n    }\n}\n```\n\n- Send option bytes:\n\n```csharp\nvar sendOptionBytesCmd = cubeProgrammerApi.SendOptionBytesCmd(\"-ob RDP=170\");\n```\n\n- Erase:\n\n```csharp\nvar massErase = cubeProgrammerApi.MassErase(\"\");\n```\n\n- Flash:\n\n```csharp\nvar downloadFile = cubeProgrammerApi.DownloadFile(firmwarePath, \"0x08000000\", 1U, 1U);\n```\n\n- Run:\n\n```csharp\nvar execute = cubeProgrammerApi.Execute(\"0x08000000\");\n```\n\n- Disconnect:\n\n```csharp\ncubeProgrammerApi.Disconnect();\n```\n\n- Delete interface list:\n\n```csharp\ncubeProgrammerApi.DeleteInterfaceList();\n```\n\n## License\nThe project is under Microsoft Reciprocal License [(MS-RL)](http://www.opensource.org/licenses/MS-RL)\n\n## Dependencies\n\nList of technologies, frameworks and libraries used for implementation:\n\n- [Microsoft.Extensions.Logging.Abstractions](https://www.nuget.org/packages/Microsoft.Extensions.Logging.Abstractions)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-society%2Fksociety.sharpcubeprogrammer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-society%2Fksociety.sharpcubeprogrammer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-society%2Fksociety.sharpcubeprogrammer/lists"}