Skip to content

Commit

Permalink
Merge pull request #55 from K-Society/experimental
Browse files Browse the repository at this point in the history
Experimental
  • Loading branch information
maniglia authored Oct 31, 2023
2 parents 55999e4 + f13670f commit 470dce2
Show file tree
Hide file tree
Showing 14 changed files with 383 additions and 60 deletions.
17 changes: 16 additions & 1 deletion KSociety.SharpCubeProgrammer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{4EE1
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Programming", "src\01\Samples\Programming\Programming.csproj", "{22183711-7C44-40E7-B3CE-2B2CECBDE80D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProgrammerConsoleApplication", "src\01\ProgrammerConsoleApplication\ProgrammerConsoleApplication.vcxproj", "{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -39,14 +41,16 @@ Global
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Debug|x64.ActiveCfg = Debug|x64
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Debug|x64.Build.0 = Debug|x64
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Debug|x86.ActiveCfg = Debug|x86
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Debug|x86.Build.0 = Debug|x86
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Release|x64.ActiveCfg = Release|x64
{3B3765AD-E869-4D7E-8274-F63380F177B7}.Release|x86.ActiveCfg = Release|x86
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Debug|Any CPU.ActiveCfg = Debug|x64
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Debug|x64.ActiveCfg = Debug|x64
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Debug|x64.Build.0 = Debug|x64
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Debug|x86.ActiveCfg = Debug|Win32
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Debug|x86.Build.0 = Debug|Win32
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Release|Any CPU.ActiveCfg = Release|Win32
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Release|Any CPU.Build.0 = Release|Win32
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Release|x64.ActiveCfg = Release|x64
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Release|x64.Build.0 = Release|x64
{52455EFE-41B6-4C8B-97C0-DB796FE725B5}.Release|x86.ActiveCfg = Release|Win32
Expand All @@ -63,9 +67,19 @@ Global
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Debug|x64.ActiveCfg = Debug|x64
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Debug|x64.Build.0 = Debug|x64
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Debug|x86.ActiveCfg = Debug|x86
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Debug|x86.Build.0 = Debug|x86
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Release|x64.ActiveCfg = Release|x64
{22183711-7C44-40E7-B3CE-2B2CECBDE80D}.Release|x86.ActiveCfg = Release|x86
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|Any CPU.ActiveCfg = Debug|x64
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|Any CPU.Build.0 = Debug|x64
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|x64.ActiveCfg = Debug|x64
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|x64.Build.0 = Debug|x64
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|x86.ActiveCfg = Debug|Win32
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Debug|x86.Build.0 = Debug|Win32
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Release|Any CPU.ActiveCfg = Release|Win32
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Release|x64.ActiveCfg = Release|x64
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA}.Release|x86.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -76,6 +90,7 @@ Global
{9FA670EF-B88A-4C77-AC07-1BE7D36110CA} = {3D922D26-1A7F-4021-89BD-AF5DDCB99CDB}
{4EE1D5AC-4198-4753-A277-FA7F730B5184} = {3D922D26-1A7F-4021-89BD-AF5DDCB99CDB}
{22183711-7C44-40E7-B3CE-2B2CECBDE80D} = {4EE1D5AC-4198-4753-A277-FA7F730B5184}
{8709E86A-F53A-4CED-B485-5D8A40FE9CCA} = {3D922D26-1A7F-4021-89BD-AF5DDCB99CDB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7D151E62-C748-4733-BFAC-CDAD83F0B9A8}
Expand Down
59 changes: 45 additions & 14 deletions src/01/KSociety.SharpCubeProgrammer/Enum/CubeProgrammerError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,50 +27,81 @@ public enum CubeProgrammerError
/// </summary>
CubeprogrammerErrorConnection = -3,

/** No such file */
/// <summary>
/// No such file.
/// </summary>
CubeprogrammerErrorNoFile = -4,

/** Operation not supported or unimplemented on this interface */
/// <summary>
/// Operation not supported or unimplemented on this interface.
/// </summary>
CubeprogrammerErrorNotSupported = -5,

/** Interface not supported or unimplemented on this platform */
/// <summary>
/// Interface not supported or unimplemented on this platform.
/// </summary>
CubeprogrammerErrorInterfaceNotSupported = -6,

/** Insufficient memory */
/// <summary>
/// Insufficient memory.
/// </summary>
CubeprogrammerErrorNoMem = -7,

/** Wrong parameters */
/// <summary>
/// Wrong parameters.
/// </summary>
CubeprogrammerErrorWrongParam = -8,

/** Memory read failure */
/// <summary>
/// Memory read failure.
/// </summary>
CubeprogrammerErrorReadMem = -9,

/** Memory write failure */
/// <summary>
/// Memory write failure.
/// </summary>
CubeprogrammerErrorWriteMem = -10,

/** Memory erase failure */
/// <summary>
/// Memory erase failure.
/// </summary>
CubeprogrammerErrorEraseMem = -11,

/** File format not supported for this kind of device */
/// <summary>
/// File format not supported for this kind of device.
/// </summary>
CubeprogrammerErrorUnsupportedFileFormat = -12,

/** Refresh required **/
/// <summary>
/// Refresh required.
/// </summary>
CubeprogrammerErrorRefreshRequired = -13,

/** Refresh required **/
/// <summary>
/// Refresh required.
/// </summary>
CubeprogrammerErrorNoSecurity = -14,

/** Changing frequency problem **/
/// <summary>
/// Changing frequency problem.
/// </summary>
CubeprogrammerErrorChangeFreq = -15,

/** RDP Enabled error **/
/// <summary>
/// RDP Enabled error.
/// </summary>
CubeprogrammerErrorRdpEnabled = -16,

/* NB: Remember to update CUBEPROGRAMMER_ERROR_COUNT below. */

/** Other error */
/// <summary>
/// Other error.
/// </summary>
CubeprogrammerErrorOther = -99,

/// <summary>
/// Device Not Connected.
/// </summary>
CubeprogrammerErrorDeviceNotConnected = -545,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<None Include="..\..\..\Programmer\version" Pack="true" PackagePath="build\native\Programmer" Visible="false" Link="dll\version" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\x64\*.dll" Pack="true" PackagePath="build\native\x64\Programmer" Visible="false" Exclude="**\STLinkUSBDriver.dll" Link="dll\x64\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\x64\STLinkUSBDriver.dll" Pack="true" PackagePath="build\native\x64" Visible="false" Link="dll\x64\STLinkUSBDriver.dll" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\x64\Release\*.dll" Pack="true" PackagePath="build\native\x64\Programmer" Visible="false" Link="dll\x64\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\build\Programmer\bin\x64\Release\*.dll" Pack="true" PackagePath="build\native\x64\Programmer" Visible="false" Link="dll\x64\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\x86\*.dll" Pack="true" PackagePath="build\native\x86\Programmer" Visible="false" Exclude="**\STLinkUSBDriver.dll" Link="dll\x86\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\x86\STLinkUSBDriver.dll" Pack="true" PackagePath="build\native\x86" Visible="false" Link="dll\x86\STLinkUSBDriver.dll" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Win32\Release\*.dll" Pack="true" PackagePath="build\native\x86\Programmer" Visible="false" Link="dll\x86\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\build\Programmer\bin\Win32\Release\*.dll" Pack="true" PackagePath="build\native\x86\Programmer" Visible="false" Link="dll\x86\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Data_Base\*.*" Pack="true" PackagePath="contentFiles\Data_Base" Visible="false" Link="st\Data_Base\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
<None Include="..\..\..\Programmer\FlashLoader\*.*" Pack="true" PackagePath="contentFiles\FlashLoader" Visible="false" Link="st\Programmer\FlashLoader\%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/01/Programmer/Programmer.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ extern "C" PROGRAMMER_API int AntiRollBack();

extern "C" PROGRAMMER_API int StartFus();

extern "C" PROGRAMMER_API int UnlockChip();
extern "C" PROGRAMMER_API int UnlockChip();
19 changes: 16 additions & 3 deletions src/01/Programmer/Programmer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@
<LinkIncremental />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<LinkIncremental />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand All @@ -90,12 +92,23 @@
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<SupportJustMyCode>false</SupportJustMyCode>
<Optimization>MaxSpeed</Optimization>
<OmitFramePointers />
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalLibraryDirectories>$(SolutionDir)Programmer\$(PlatformTarget);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>CubeProgrammer_API.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ProjectReference>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand Down Expand Up @@ -213,4 +226,4 @@
<Error Condition="!Exists('..\..\..\packages\Nerdbank.GitVersioning.3.6.133\build\Nerdbank.GitVersioning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Nerdbank.GitVersioning.3.6.133\build\Nerdbank.GitVersioning.props'))" />
<Error Condition="!Exists('..\..\..\packages\Nerdbank.GitVersioning.3.6.133\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Nerdbank.GitVersioning.3.6.133\build\Nerdbank.GitVersioning.targets'))" />
</Target>
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// ProgrammerConsoleApplication.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include "../Programmer/Programmer.h"

int main()
{
std::cout << "Hello World!\n";
debugConnectParameters* stLinkList;
debugConnectParameters debugParameters;
generalInf* genInfo;
int getStlinkListNb = GetStLinkList(&stLinkList, 0);

if (getStlinkListNb == 0)
{
std::cout << "No STLINK available\n";
return 0;
}
else {
std::cout << "\n-------- Connected ST-LINK Probes List --------";
for (int i = 0; i < getStlinkListNb; i++)
{
//logMessage(Normal, "\nST-LINK Probe %d :\n", i);
std::cout << "\n ST-LINK Probe " << i << " :\n" << std::endl;
//logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
std::cout << " ST-LINK SN : " << stLinkList[i].serialNumber << " \n" << std::endl;
//logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
std::cout << " ST-LINK FW : " << stLinkList[i].firmwareVersion << " \n" << std::endl;
}

std::cout << "-----------------------------------------------\n\n";
}

for (int index = 0; index < getStlinkListNb; index++) {

//logMessage(Title, "\n--------------------- ");
//logMessage(Title, "\n ST-LINK Probe : %d ", index);
//logMessage(Title, "\n--------------------- \n\n");

debugParameters = stLinkList[index];
debugParameters.connectionMode = UNDER_RESET_MODE;
debugParameters.shared = 0;
debugParameters.speed = 1;

/* Target connect */
int connectStlinkFlag = ConnectStLink(debugParameters);
if (connectStlinkFlag != 0) {
//logMessage(Error, "Establishing connection with the device failed\n");

std::cout << "Establishing connection with the device failed: " << connectStlinkFlag << " \n" << std::endl;
Disconnect();
continue;
}
else {
std::cout << "\n--- Device Connected --- \n" ;
//logMessage(GreenInfo, "\n--- Device %d Connected --- \n", index);
}

/* Display device informations */
genInfo = GetDeviceGeneralInf();
//logMessage(Normal, "\nDevice name : %s ", genInfo->name);
//logMessage(Normal, "\nDevice type : %s ", genInfo->type);
//logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);

}

Disconnect();

return 1;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Loading

0 comments on commit 470dce2

Please sign in to comment.