STM32CubeProgrammer API: STM32CubeProgrammer API Documentation

STM32CubeProgrammer API
  • Main Page
  • Modules
  • Data Structures
  • Files
  • Examples
STM32CubeProgrammer API Documentation

Introduction

In addition to the graphical user interface and the commandline interface, STM32CubeProgrammer offers a C++ API that you could use to develop your own application and benefit of wide range of features to program STM32 microcontrollers memories (such as Flash, RAM, and OTP) either over debug interface or bootloder interface (USB DFU, UART, I²C, SPI and CAN).

This documentation details all types and functions API to use STM32CubeProgrammer functionalities.

STM32CubeProgrammer API package

The API package is based on the following resources that are ready for use :

File | Description
CubeProgrammer_API.h | header file contains functions declarations and macro definitions to be used by the CubeProgrammer_API.dll.
DeviceDataStructure.h | header file contains macro definitions to be shared between several functions.
CubeProgrammer_API.dll/.so/.dylib | Dynamic Link Library file contains a library of functions and other informations that can be accessed by windows, linux and MacOs programs.
CubeProgrammer_API.lib | import library for use with MSVC compiler.

Application System requirements

We offer various examples developed for use with Visual Studio and Qt Creator IDEs:

  • Visual Studio project for windows applications under MSVC compiler.
  • Qt project for Windows, Linux and MacOs applications under MinGW compiler.
    Note
    The attached examples are tested on STM32F429, STM32L4R9 and STM32L452RE Nucleo Boards.

Windows build settings

To ensure the correct environment for the provided examples, some constraints must be taken into account

Visual studio

The code was developed with Microsoft Visual Studio Community 2017 version 15.6.6 with Windows SDK version : 10.0.16299.0 and it was tested also on Microsoft Visual Studio 2010

  • Verify that the api's lib directory is the default working directory.
  • The debug command is to execute the application that is resided in the output directory.
  • Insert the Additional Include Directories:
    \n
  • Indicate the output name and path.
  • Insert the Additional Library Directories.
  • Insert the Additional Dependencies, The CubeProgrammer_API import library "CubeProgrammer_API.lib" must be added to Linker input
    \n
    Note
    The provided Visual studio project is already configured like the description above and you can change it carefully according to your use case.

Qt creator

The Qt projects are developed with Qt Creator 4.7.1, Qt 5.11.2 and MinGW 32 bit compiler and also it can be compiled by MinGW x64.
The shadow build option must be disable to inform Qt that the build should be located in the original Qt project directory.

Note
Verify that the following DLLs are placed to /lib in the api package directory :
CubeProgrammer_API.dll | FileManager.dll | STLinkUSBDriver.dll
HSM_P11_Lib.dll | libeay32.dll | libgcc_s_dw2-1.dll
stlibp11_SAM.dll | libstdc++-6.dll | libwinpthread-1.dll
mfc120.dll | msvcp120.dll | msvcr120.dll
Qt5Core.dll | Qt5SerialPort.dll | Qt5Xml.dll

Linux build settings

To correctly build the Qt project in linux platform, you should follow the next 3 steps:

  1. Select the build configuration in Projects field of the main view.
  2. Disable the Shadow build option.
  3. Go to build environment, add the System Environment variable LD_LIBRARY_PATH and set the path to ../../../../lib
    \n
Note
Verify that the following Shared Objects are placed to /lib in the STM32CubeProgrammer package directory :
libCubeProgrammer_API.so | libCubeProgrammer_API.so.1 | libSTLinkUSBDriver.so | libFileManager.so.1
libhsmp11.so | libQt5SerialPort.so.5 | libQtXml.so.5 | libQt5Core.so.5
libicudata.so.56 libicui18n.so.56 libicuuc.so.56 -

MacOS buiild settings

To get the default api folder that is integrated into the STM32CubeProgrammer package already installed, go to
/Application/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/contents/MacOs/api

Note
Verify that the following Mach Objects are placed to /Application/STMicroelectronics/STM32Cube/STM32CubeProgrammer/STM32CubeProgrammer.app/contents/MacOs/bin in the STM32CubeProgrammer package directory:
libCubeProgrammer_API.dylib | libCubeProgrammer_API.1.dylib | libCubeProgrammer_API.1.0.dylib | libCubeProgrammer_API.1.0.0.dylib
libFileManager.dylib | libFileManager.1.dylib | libFileManager.1.0.dylib | libFileManager.1.0.0.dylib
libSTLinkUSBDriver.dylib | libhsmp11.dylib | libstP11_SAM.dylib | libusb-1.0.0.dylib
QtSerialPort.framework QtXml.framework QtCore.framework -
Generated by doxygen 1.9.6


STM32CubeProgrammer API: Modules

  • Data Structures
  • Files
  • Examples
Modules
Here is a list of all modules:
STLINK
Bootloader
General
OB
Loaders
STM32WB
STM32MP
HSM


STM32CubeProgrammer API: STLINK

Functions
STLINK

Functions

int | getStLinkList (debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s).
int | getStLinkEnumerationList (debugConnectParameters **stlink_list, int shared)
This routine allows to get ST-LINK conneted probe(s) without connecting and intruse the target.
int | connectStLink (debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces.
int | reset (debugResetMode rstMode)
This routine used to apply a target reset.

Detailed Description

STLINK module groups debug ports JTAG/SWD functions together.

Function Documentation

◆ connectStLink()

int connectStLink ( debugConnectParameters debugParameters )

This routine allows to start connection to device through SWD or JTAG interfaces.

Parameters
debugParameters : Indicates customized configuration for ST-LINK connection, It is recommended to check [debugConnectParameters] fields before connection.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples
HSM_Example, STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ getStLinkEnumerationList()

int getStLinkEnumerationList | ( | debugConnectParameters ** | stlink_list,
 |  | int | shared
 | ) |  |

This routine allows to get ST-LINK conneted probe(s) without connecting and intruse the target.

Parameters
stLinkList | : Filled with the connected ST-LINK list and its default configurations.
shared | : Enable shared mode allowing connection of two or more instances to the same ST-LINK probe.
Returns
Number of the ST-LINK probes already exists.
Warning
The Share option is useful only with ST-LINK Server.
Note
At the end of usage, deleteInterfaceList must have been called.

◆ getStLinkList()

int getStLinkList | ( | debugConnectParameters ** | stLinkList,
 |  | int | shared
 | ) |  |

This routine allows to get ST-LINK conneted probe(s).

Parameters
stLinkList | : Filled with the connected ST-LINK list and its default configurations.
shared | : Enable shared mode allowing connection of two or more instances to the same ST-LINK probe.
Returns
Number of the ST-LINK probes already exists.
Warning
The Share option is useful only with ST-LINK Server.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples
HSM_Example, STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ reset()

int reset ( debugResetMode rstMode )

This routine used to apply a target reset.

Note
Reset operation is only available with JTAG/SWD debug interface.
Parameters
rstMode : Indicates the reset type Soft/Hard/Core debugResetMode.
Returns
0 if the reset operation finished successfully, otherwise an error occurred.
Examples
STLINK_Example1, and STLINK_Example3.


STM32CubeProgrammer API: Bootloader

Functions
Bootloader

Functions

int | getUsartList (usartConnectParameters **usartList)
This routine allows to get connected serial ports.
int | connectUsartBootloader (usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface.
int | sendByteUart (int byte)
This routine allows to send a single byte through the USART interface.
int | getDfuDeviceList (dfuDeviceInfo **dfuList, int iPID, int iVID)
This routine allows to get connected DFU devices.
int | connectDfuBootloader (char *usbIndex)
This routine allows to start a simple connection through USB DFU interface.
int | connectDfuBootloader2 (dfuConnectParameters dfuParameters)
This routine allows to start connection to device through USB DFU interface.
int | connectSpiBootloader (spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface.
int | connectCanBootloader (canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface.
int | connectI2cBootloader (i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface.

Detailed Description

Bootloader module is a way to group Serial interfaces USB/UART/SPI/I2C/CAN functions together.

Function Documentation

◆ connectCanBootloader()

int connectCanBootloader ( canConnectParameters canParameters )

This routine allows to start connection to device through CAN interface.

Parameters
canParameters : Indicates customized configuration for CAN connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Warning
To have CAN full support, you must have St-Link firmware version at least v3JxMxB2.
Examples
CAN_Bootloader.

◆ connectDfuBootloader()

int connectDfuBootloader ( char * usbIndex )

This routine allows to start a simple connection through USB DFU interface.

Parameters
usbIndex : Indicates the index of DFU ports already connected.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples
MPU_SSP, TSV_Flashing, and USB_Bootloader.

◆ connectDfuBootloader2()

int connectDfuBootloader2 ( dfuConnectParameters dfuParameters )

This routine allows to start connection to device through USB DFU interface.

Parameters
dfuConnectParameters : Indicates the dfu connection parameters
Returns
0 if the connection successfully established, otherwise an error occurred.
Note
It's recommanded to use this routine to disable readout protection when connecting a MCU based device.

◆ connectI2cBootloader()

int connectI2cBootloader ( i2cConnectParameters i2cParameters )

This routine allows to start connection to device through I2C interface.

Parameters
i2cParameters : Indicates customized configuration for I2C connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples
I2C_Bootloader.

◆ connectSpiBootloader()

int connectSpiBootloader ( spiConnectParameters spiParameters )

This routine allows to start connection to device through SPI interface.

Parameters
spiParameters : Indicates customized configuration for SPI connection
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples
SPI_Bootloader.

◆ connectUsartBootloader()

int connectUsartBootloader ( usartConnectParameters usartParameters )

This routine allows to start connection to device through USART interface.

Parameters
usartParameters : Indicates customized configuration for USART connection.
Returns
0 if the connection successfully established, otherwise an error occurred.
Examples
UART_Bootloader.

◆ getDfuDeviceList()

int getDfuDeviceList | ( | dfuDeviceInfo ** | dfuList,
 |  | int | iPID,
 |  | int | iVID
 | ) |  |

This routine allows to get connected DFU devices.

Parameters
dfuList | : Receive DFU devices list and its default configurations.
iPID | : Indicate the Product ID to be used for DFU interface.
iVID | : Indicate the Vendor ID to be used for DFU interface.
Returns
Number of DFU devices already connected.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples
MPU_SSP, TSV_Flashing, and USB_Bootloader.

◆ getUsartList()

int getUsartList ( usartConnectParameters ** usartList )

This routine allows to get connected serial ports.

Parameters
usartList : Receive serial ports list and its default configurations.
Returns
Number of serial ports already connected.
Note
At the end of usage, deleteInterfaceList must have been called.
Examples
UART_Bootloader.

◆ sendByteUart()

int sendByteUart ( int byte )

This routine allows to send a single byte through the USART interface.

Parameters
byte : The data to be written
Returns
0 if the sending operation correctly achieved, otherwise an error occurred.


STM32CubeProgrammer API: General

Functions
General

Functions

void | setDisplayCallbacks (displayCallBacks c)
This routine allows to choose your custom display.
void | setVerbosityLevel (int level)
This routine allows to choose the verbosity level for display.
int | checkDeviceConnection ()
This routine allows to check connection status [maintained or lost].
generalInf * getDeviceGeneralInf ()
This routine allows to get general device informations.
int | readMemory (unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initialized.
int | writeMemory (unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initialized.
int | editSector (unsigned int address, char *data, unsigned int size)
This routine allows to write sector data on the user interface with the configration already initialized.
int | downloadFile (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec, tsv, elf, axf, out, stm32, ext.
int | execute (unsigned int address)
This routine allows to run the application.
int | massErase (char *sFlashMemName=nullptr)
This routine allows to erase the whole Flash memory.
int | sectorErase (unsigned int sectors[], unsigned int sectorNbr, char *sFlashMemName=nullptr)
This routine allows to erase specific sectors of the Flash memory.
int | readUnprotect ()
This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects.
int | tzenRegression ()
This routine allows the TZEN Option Byte regression.
int | getTargetInterfaceType ()
This routine allows to know the interface what is in use.
volatile int * | getCancelPointer ()
This routine allows to drop the current read/write operation.
void * | fileOpen (const wchar_t *filePath)
This routine allows to open and get data from any supported file extension.
void | freeFileData (fileData_C *data)
This routine allows to clean up the handled file data.
void | freeLibraryMemory (void *ptr)
This routine allows to free a specific memory region, typically used after readMemory().
int | verify (fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content.
int | saveFileToFile (fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file.
int | saveMemoryToFile (int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file.
void | disconnect ()
This routine allows to clean up and disconnect the current connected target.
void | deleteInterfaceList ()
This routine allows to clear the list of each created interface.
void | automaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.
void | serialNumberingAutomaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run, int enableSerialNumbering, int serialAddress, int serialSize, char *serialInitialData)
This routine allows to enter and make an automatic process for memory management with serial numbering through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.
int | getStorageStructure (storageStructure **deviceStorageStruct)
This routine allows to get Flash storage information.

Detailed Description

General module groups general purposes functions used by any interface.

Function Documentation

◆ automaticMode()

void automaticMode | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | skipErase,
 |  | unsigned int | verify,
 |  | int | isMassErase,
 |  | char * | obCommand,
 |  | int | run
 | ) |  |

This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.

Parameters
filePath | : Indicates the full file path.
address | : The address to start downloading from.
skipErase | : If we have a blank device, we can skip erasing memory before programming [skipErase=0].
verify | : Add verification step after downloading.
isMassErase | : Erase the whole Flash memory.
obCommand | : Indicates the option bytes commands to be loaded "-ob [optionbyte=value] [optionbyte=value]..."
run | : Start the application.
Warning
Connection to target must be established before performing automatic mode.

◆ checkDeviceConnection()

int checkDeviceConnection ( )

This routine allows to check connection status [maintained or lost].

Returns
1 if the device is already connected, otherwise the connection to device is lost.

◆ deleteInterfaceList()

void deleteInterfaceList ( )

This routine allows to clear the list of each created interface.

Note
The list is filled by #getStlinkList, getDfuDeviceList or getUsartList.
Examples
MPU_SSP, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ disconnect()

void disconnect ( )

This routine allows to clean up and disconnect the current connected target.

Note
This routine disconnect the target and delete the loaded Flash Loaders.
Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ downloadFile()

int downloadFile | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | skipErase,
 |  | unsigned int | verify,
 |  | const wchar_t * | binPath
 | ) |  |

This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec, tsv, elf, axf, out, stm32, ext.

Parameters
filePath | : Indicates the full path of the considered file.
address | : The address to start downloading from.
skipErase | : In case to win in term time and if we have a blank device, we can skip erasing memory before programming [skipErase=0].
verify | : To add verification step after downloading.
binPath | : Path of the binary file.
Returns
0 if the downloading operation correctly finished, otherwise an error occurred.
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ editSector()

int editSector | ( | unsigned int | address,
 |  | char * | data,
 |  | unsigned int | size
 | ) |  |

This routine allows to write sector data on the user interface with the configration already initialized.

Parameters
address | : The address to start writing from.
data | : Pointer to the data buffer.
size | : It indicates the size for write data.
Returns
0 if the writing operation correctly finished, otherwise an error occurred.
Warning
Unlike ST-LINK interface, the Bootloader interface can access only to some specific memory regions.
Data size should not exceed sector size.

◆ execute()

int execute ( unsigned int address )

This routine allows to run the application.

Parameters
address : The address to start executing from. In most cases, the program will run from the Flash memory starting from 0x08000000.
Returns
0 if the execution correctly started, otherwise an error occurred.
Examples
STLINK_Example2.

◆ fileOpen()

void * fileOpen ( const wchar_t * filePath )

This routine allows to open and get data from any supported file extension.

Parameters
filePath : Indicates the full path of the considered file.
Returns
Pointer to fileData_C if the file has hex, bin, srec or elf as extension, otherwise a null pointer to indicate that the file type is not supported.

◆ freeFileData()

void freeFileData ( fileData_C * data )

This routine allows to clean up the handled file data.

Parameters
data

◆ freeLibraryMemory()

void freeLibraryMemory ( void * ptr )

This routine allows to free a specific memory region, typically used after readMemory().

Parameters
ptr : The input pointer address.
Note
it's crucial to ensure that the data is no longer in use after you free the memory.
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, and UART_Bootloader.

◆ getCancelPointer()

volatile int * getCancelPointer ( )

This routine allows to drop the current read/write operation.

Returns
0 if there is no call for stop operation, otherwise 1.

◆ getDeviceGeneralInf()

generalInf * getDeviceGeneralInf ( )

This routine allows to get general device informations.

Returns
Structure GeneralInf in which the informations are stored.
Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ getStorageStructure()

int getStorageStructure ( storageStructure ** deviceStorageStruct )

This routine allows to get Flash storage information.

Parameters
deviceStorageStruct : The data strcurure to load memory sectors information.
Returns
0 if the operation was acheived successfully, otherwise an error occurred.

◆ getTargetInterfaceType()

int getTargetInterfaceType ( )

This routine allows to know the interface what is in use.

Returns
The target interface type targetInterfaceType, otherwise -1.

◆ massErase()

int massErase ( char * sFlashMemName = nullptr )

This routine allows to erase the whole Flash memory.

Returns
0 if the operation finished successfully, otherwise an error was occurred.
Note
Depending on the device, this routine can take a particular period of time.
Examples
STLINK_Example1.

◆ readMemory()

int readMemory | ( | unsigned int | address,
 |  | unsigned char ** | data,
 |  | unsigned int | size
 | ) |  |

This routine allows to receive memory data on the used interface with the configration already initialized.

Parameters
address | : The address to start reading from.
data | : Pointer to the data buffer.
size | : It indicates the size for read data.
Returns
0 if the reading operation correctly finished, otherwise an error occurred.
Warning
Unlike ST-LINK interface, the Bootloader interface can access only to some specific memory regions.
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example2, UART_Bootloader, and USB_Bootloader.

◆ readUnprotect()

int readUnprotect ( )

This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects.

Returns
0 if the disabling correctly accomplished, otherwise an error occurred.
Note
Depending on the device used, this routine take a specific time.
Examples
STLINK_Example3.

◆ saveFileToFile()

int saveFileToFile | ( | fileData_C * | fileData,
 |  | const wchar_t * | sFileName
 | ) |  |

This routine allows to save the data file content to another file.

Parameters
fileData | : Input file name.
sFileName | : Output file name.
Returns
0 if the output file was created successfully, otherwise an error occurred.

◆ saveMemoryToFile()

int saveMemoryToFile | ( | int | address,
 |  | int | size,
 |  | const wchar_t * | sFileName
 | ) |  |

This routine allows to save Flash memory content to file.

Parameters
address | : The address to start saving from.
size | : Data size to be saved.
sFileName | : Indicates the file name.
Returns
0 if the data copy was acheived successfully, otherwise an error occurred.
Note
The file name must finish with an extension ".hex", ".bin" or ".srec"

◆ sectorErase()

int sectorErase | ( | unsigned int | sectors[],
 |  | unsigned int | sectorNbr,
 |  | char * | sFlashMemName = nullptr
 | ) |  |

This routine allows to erase specific sectors of the Flash memory.

Parameters
sectors | : Indicates the indexs of the specific sectors to be erased.
sectorNbr | : The number of chosen sectors.
Returns
0 if the operation finished successfully, otherwise an error occurred.
Note
Each circuit has a specific number of Flash memory sectors.
Examples
STLINK_Example1.

◆ serialNumberingAutomaticMode()

void serialNumberingAutomaticMode | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | skipErase,
 |  | unsigned int | verify,
 |  | int | isMassErase,
 |  | char * | obCommand,
 |  | int | run,
 |  | int | enableSerialNumbering,
 |  | int | serialAddress,
 |  | int | serialSize,
 |  | char * | serialInitialData
 | ) |  |

This routine allows to enter and make an automatic process for memory management with serial numbering through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.

Parameters
filePath | : Indicates the full file path.
address | : The address to start downloading from.
skipErase | : If we have a blank device, we can skip erasing memory before programming [skipErase=0].
verify | : Add verification step after downloading.
isMassErase | : Erase the whole Flash memory.
obCommand | : Indicates the option bytes commands to be loaded "-ob [optionbyte=value] [optionbyte=value]..."
run | : Start the application.
enableSerialNumbering | : enables the serial numbering.
serialAddress | : the address where the inital data and the subsequent increments will be made.
serialSize | : size for the serial numbering.
serialInitialData | : intial data used for the serial numbering that will be incremented.
Warning
Connection to target must be established before performing automatic mode with serial numbering.

◆ setDisplayCallbacks()

void setDisplayCallbacks ( displayCallBacks c )

This routine allows to choose your custom display.

Parameters
c : Fill the struct to customize the display tool.
Note
This function must be called first of all to ensure the display management.
Examples
main.

◆ setVerbosityLevel()

void setVerbosityLevel ( int level )

This routine allows to choose the verbosity level for display.

Parameters
level : Indicates the verbosity number 0, 1 or 3.
Examples
main.

◆ tzenRegression()

int tzenRegression ( )

This routine allows the TZEN Option Byte regression.

Returns
0 if the disabling correctly accomplished, otherwise an error occurred.
Note
Depending on the device used, this routine take a specific time.

◆ verify()

int verify | ( | fileData_C * | fileData,
 |  | unsigned int | address
 | ) |  |

This routine allows to verfiy if the indicated file data is identical to Flash memory content.

Parameters
fileData | : Input file name.
address | : The address to start verifying from, it's considered only if the file has .bin or .binary as extension.
Returns
0 if the file data matching Flash memory content, otherwise an error occurred or the data is mismatched.

◆ writeMemory()

int writeMemory | ( | unsigned int | address,
 |  | char * | data,
 |  | unsigned int | size
 | ) |  |

This routine allows to write memory data on the user interface with the configration already initialized.

Parameters
address | : The address to start writing from.
data | : Pointer to the data buffer.
size | : It indicates the size for write data.
Returns
0 if the writing operation correctly finished, otherwise an error occurred.
Warning
Unlike ST-LINK interface, the Bootloader interface can access only to some specific memory regions.
Examples
STLINK_Example1.


STM32CubeProgrammer API: OB

Functions
OB

Functions

int | sendOptionBytesCmd (char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements.
peripheral_C * initOptionBytesInterface ()
This routine allows to get option bytes values of the connected target.
peripheral_C * | fastRomInitOptionBytesInterface (uint16_t deviceId)
int | obDisplay ()
This routine allows to display the Option bytes.

Detailed Description

OB module groups option bytes functions used by any interface.

Function Documentation

◆ fastRomInitOptionBytesInterface()

peripheral_C * fastRomInitOptionBytesInterface ( uint16_t deviceId )

◆ initOptionBytesInterface()

peripheral_C * initOptionBytesInterface ( )

This routine allows to get option bytes values of the connected target.

Returns
Structure #Peripheral_C in which the option bytes descriptions are stored.
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ obDisplay()

int obDisplay ( )

This routine allows to display the Option bytes.

Returns
0 if the programming display correctly done, otherwise an error occurred.

◆ sendOptionBytesCmd()

int sendOptionBytesCmd ( char * command )

This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements.

Parameters
command : Indicates the command to execute.
Returns
0 if the programming Option Byte correctly executed, otherwise an error occurred.
Note
The command must written as: -ob [optionbyte=value] [optionbyte=value] ...
int ob = sendOptionBytesCmd("–ob rdp=0x0 BOR_LEV=0");
sendOptionBytesCmd
int sendOptionBytesCmd(char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user de...
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example3, UART_Bootloader, and USB_Bootloader.


STM32CubeProgrammer API: Loaders

Functions
Loaders

Functions

void | setLoadersPath (const char *path)
This routine allows to specify the location of Flash Loader.
void | setExternalLoaderPath (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded.
void | setExternalLoaderOBL (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded via OBL interfaces.
int | getExternalLoaders (const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in the mentioned path.
void | removeExternalLoader (const char *path)
This routine allows to unload an external Loaders.
void | deleteLoaders ()
This routine allows to delete all target Flash Loaders.

Detailed Description

Loaders module groups loaders functions.

Function Documentation

◆ deleteLoaders()

void deleteLoaders ( )

This routine allows to delete all target Flash Loaders.

◆ getExternalLoaders()

int getExternalLoaders | ( | const char * | path,
 |  | externalStorageInfo ** | externalStorageNfo
 | ) |  |

This routine allows to get available external Loaders in the mentioned path.

Parameters
path | : Indicates the full path containing ExternalLoader folder.
externalStorageNfo | : Structure in which we get storage information.
Returns
1 if the External loaders cannot be loaded from the path, otherwise 0.
Warning
All external Loader files should have the extension "stldr".

◆ removeExternalLoader()

void removeExternalLoader ( const char * path )

This routine allows to unload an external Loaders.

Parameters
path : Indicates the full path of the external Loader file ready for unloading.

◆ setExternalLoaderOBL()

void setExternalLoaderOBL | ( | const char * | path,
 |  | externalLoader ** | externalLoaderInfo
 | ) |  |

This routine allows to specify the path of the external Loaders to be loaded via OBL interfaces.

Parameters
path | : Indicates the full path of the folder containing external Loaders.
externalLoaderInfo | : Structure in which the external Loaders informations are stored.

◆ setExternalLoaderPath()

void setExternalLoaderPath | ( | const char * | path,
 |  | externalLoader ** | externalLoaderInfo
 | ) |  |

This routine allows to specify the path of the external Loaders to be loaded.

Parameters
path | : Indicates the full path of the folder containing external Loaders.
externalLoaderInfo | : Structure in which the external Loaders informations are stored.

◆ setLoadersPath()

void setLoadersPath ( const char * path )

This routine allows to specify the location of Flash Loader.

Parameters
path : Indicates the full path of the considered folder.
Examples
main.


STM32CubeProgrammer API: STM32WB

Functions
STM32WB

Functions

int | getUID64 (unsigned char **data)
This routine allows to read the device unique identifier.
int | firmwareDelete ()
This routine allows to erase the BLE stack firmware.
int | firmwareUpgrade (const wchar_t *filePath, unsigned int address, unsigned int firstInstall, unsigned int startStack, unsigned int verify)
This routine allows to make upgrade of BLE stack firmware or FUS firmware.
int | startWirelessStack ()
This routine allows to start the programmed Stack.
int | updateAuthKey (const wchar_t *filePath)
This routine allows to start the programmed Stack.
int | authKeyLock ()
This routine allows to lock the authentication key and once locked, it is no longer possible to change it.
int | writeUserKey (const wchar_t *filePath, unsigned char keyType)
This routine allows to write a customized user key.
int | antiRollBack ()
This routine allows to activate the AntiRollBack.
int | startFus ()
This routine allows to start and establish a communication with the FUS operator.
int | unlockchip ()
This routine allows to set default option Bytes.

Detailed Description

Specific APIs used exclusively for STM32WB series to manage BLE Stack and they are available only through USB DFU and UART bootloader interfaces, except for the “firmwareDelete" and the “firmwareUpgrade", available through USB DFU, UART and SWD interfaces. Connection under Reset is mandatory.

Function Documentation

◆ antiRollBack()

int antiRollBack ( )

This routine allows to activate the AntiRollBack.

Returns
true if the activation was done successfully, otherwise an error occurred.

◆ authKeyLock()

int authKeyLock ( )

This routine allows to lock the authentication key and once locked, it is no longer possible to change it.

Returns
0 if the lock step was performed successfully, otherwise an error occurred.

◆ firmwareDelete()

int firmwareDelete ( )

This routine allows to erase the BLE stack firmware.

Returns
0 if the operation was acheived successfully, otherwise an error occurred.

◆ firmwareUpgrade()

int firmwareUpgrade | ( | const wchar_t * | filePath,
 |  | unsigned int | address,
 |  | unsigned int | firstInstall,
 |  | unsigned int | startStack,
 |  | unsigned int | verify
 | ) |  |

This routine allows to make upgrade of BLE stack firmware or FUS firmware.

Parameters
filePath | : Indicates the full path of the firmware to be programmed.
address | : Start address of download.
firstInstall | : 1 if it is the first installation, otherwise 0, to ignore the firmware delete operation.
startStack | : Starts the stack after programming.
verify | : Verify if the download operation is achieved successfully before starting the upgrade.
Returns
true if the operation was acheived successfully, otherwise an error occurred.

◆ getUID64()

int getUID64 ( unsigned char ** data )

This routine allows to read the device unique identifier.

Parameters
data : Pointer to the data buffer.

◆ startFus()

int startFus ( )

This routine allows to start and establish a communication with the FUS operator.

Returns
true if the FUS operator was started successfully, otherwise an error occurred.
Note
Availbale only for ST-LINK interfaces.

◆ startWirelessStack()

int startWirelessStack ( )

This routine allows to start the programmed Stack.

Returns
true if the Stack was started successfully, otherwise an error occurred.

◆ unlockchip()

int unlockchip ( )

This routine allows to set default option Bytes.

◆ updateAuthKey()

int updateAuthKey ( const wchar_t * filePath )

This routine allows to start the programmed Stack.

Parameters
filePath : Indicates the full path of the key file.
Note
This is the public key generated by STM32TrustedPackageCreator when signing the firmware using -sign command.
Returns
true if the update was performed successfully, otherwise an error occurred.

◆ writeUserKey()

int writeUserKey | ( | const wchar_t * | filePath,
 |  | unsigned char | keyType
 | ) |  |

This routine allows to write a customized user key.

Parameters
filePath | : Indicates the full path of the key file.
keyType | : String indicating the key type to be used "Simple", "Master", "Encrypted".
Returns
0 if the write was performed successfully, otherwise an error occurred.


STM32CubeProgrammer API: STM32MP

Functions
STM32MP

Functions

int programSsp (const wchar_t *sspFile, const wchar_t *licenseFile, const wchar_t *tfaFile, int hsmSlotId)
This routine aims to launch the Secure Secret Provisioning.

Detailed Description

Specific APIs used exclusively for STM32MP devices. The connection is available only through USB DFU and UART interfaces,

Function Documentation

◆ programSsp()

int programSsp | ( | const wchar_t * | sspFile,
 |  | const wchar_t * | licenseFile,
 |  | const wchar_t * | tfaFile,
 |  | int | hsmSlotId
 | ) |  |

This routine aims to launch the Secure Secret Provisioning.

Parameters
sspFile | : Indicates the full path of the ssp file [Use STM32TrustedPackageCreator to generate a ssp image].
licenseFile | : Indicates the full path of the license file. If you are trying to start the SSP without HSM, the hsmSlotId should be 0.
tfaFile | : Indicates the full path of the tfa-ssp file.
hsmSlotId | : Indicates the HSM slot ID.
Returns
0 if the SSP was finished successfully, otherwise an error occurred.
Note
If you are trying to start the SSP with HSM, the licenseFile parametre should be empty.
Examples
MPU_SSP.


STM32CubeProgrammer API: HSM

Functions
HSM

Functions

const char * | getHsmFirmwareID (int hsmSlotId)
getHsmFirmwareID: this routine aims to get the HSM Firmware Identifier.
unsigned long | getHsmCounter (int hsmSlotId)
getHsmCounter: this routine aims to get the current HSM counter.
const char * | getHsmState (int hsmSlotId)
getHsmState: this routine aims to get the HSM State.
const char * | getHsmVersion (int hsmSlotId)
getHsmVersion: this routine aims to get the HSM version.
const char * | getHsmType (int hsmSlotId)
getHsmType: this routine aims to get the HSM type.
int | getHsmLicense (int hsmSlotId, const wchar_t *outLicensePath)
getHsmLicense: this routine aims to get and save the HSM license into a binary file.

Detailed Description

Specific APIs used exclusively for STM32 devices to manage the Hardware Secure Module.

Function Documentation

◆ getHsmCounter()

unsigned long getHsmCounter ( int hsmSlotId )

getHsmCounter: this routine aims to get the current HSM counter.

Parameters
hsmSlotId The slot index of the plugud-in HSM
Returns
Counter value
Examples
HSM_Example.

◆ getHsmFirmwareID()

const char * getHsmFirmwareID ( int hsmSlotId )

getHsmFirmwareID: this routine aims to get the HSM Firmware Identifier.

Parameters
hsmSlotId The slot index of the plugud-in HSM
Returns
string that contains the HSM Firmware Identifier.
Examples
HSM_Example.

◆ getHsmLicense()

int getHsmLicense | ( | int | hsmSlotId,
 |  | const wchar_t * | outLicensePath
 | ) |  |

getHsmLicense: this routine aims to get and save the HSM license into a binary file.

Parameters
hsmSlotId | The slot index of the plugud-in HSM
outLicensePath | path of the output binary file.
Returns
0 if the operation was finished successfully, otherwise an error occurred.
Note
Connection to target must be established before performing this routine.
Examples
HSM_Example.

◆ getHsmState()

const char * getHsmState ( int hsmSlotId )

getHsmState: this routine aims to get the HSM State.

Parameters
hsmSlotId The slot index of the plugud-in HSM
Returns
string with possible values: ST_STATE , OEM_STATE, OPERATIONAL_STATE , UNKNOWN_STATE
Examples
HSM_Example.

◆ getHsmType()

const char * getHsmType ( int hsmSlotId )

getHsmType: this routine aims to get the HSM type.

Parameters
hsmSlotId The slot index of the plugud-in HSM
Returns
string with possible values: SFI. SMU. SSP...
Examples
HSM_Example.

◆ getHsmVersion()

const char * getHsmVersion ( int hsmSlotId )

getHsmVersion: this routine aims to get the HSM version.

Parameters
hsmSlotId The slot index of the plugud-in HSM
Returns
string with possible values: 1 , 2
Examples
HSM_Example.


STM32CubeProgrammer API: Data Structures

  • Data Structure Index
  • Data Fields
Data Structures
Here are the data structures with brief descriptions:
C bank_C | Get option bytes banks internal descriptions
C bankSector | This stucture indicates the sectors parameters
C bit_C | This stucture will be filled by values which characterize the device's option bytes
C bitCoefficient_C | This stucture indicates the coefficients to access to the adequate option bit
C bitValue_C | This stucture describes the option Bit value
C canConnectParameters | Specify the CAN connect parameters
C category_C | Get option bytes banks categories descriptions
C debugConnectParameters | Get device characterization and specify connection parameters through ST-LINK interface
C deviceBank | This stucture defines the memory sectors for each bank
C deviceSector | Get device sectors basic informations
C dfuConnectParameters | Specify the USB DFU connect parameters
C dfuDeviceInfo | Get DFU device informations
C displayCallBacks | Functions must be implemented to personalize the display of messages
C externalLoader | Get external Loader parameters to launch the process of programming an external flash memory
C externalStorageInfo | Get external storage informations useful for external Loader
C fileData_C |
C FileData_C | Get file required informations
C frequencies | Get supported frequencies for JTAG and SWD ineterfaces
C generalInf |
C GeneralInf | Get device general informations
C i2cConnectParameters | Specify the I2C connect parameters
C peripheral_C | Get peripheral option bytes general informations
C segmentData_C |
C spiConnectParameters | Specify the SPI connect parameters
C storageStructure | This stucture describes sotrage characterization
C usartConnectParameters | Specify the USART connect parameters


STM32CubeProgrammer API: bank_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
bank_C Struct Reference

Get option bytes banks internal descriptions. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | size
unsigned int | address
unsigned char | access
unsigned int | categoriesNbr
category_C ** categories

Detailed Description

Get option bytes banks internal descriptions.

Note
STLINK and Bootloader interfaces have different addresses to access to option bytes registres.

Field Documentation

◆ access

unsigned char access

Bank access Read/Write.

◆ address

unsigned int address

Bank starting address.

◆ categories

category_C** categories

Get bank categories descriptions #Category_C.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ categoriesNbr

unsigned int categoriesNbr

Number of option bytes categories.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ size

unsigned int size

Bank size.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bankSector Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
bankSector Struct Reference

This stucture indicates the sectors parameters. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | index
unsigned int | size
unsigned int | address

Detailed Description

This stucture indicates the sectors parameters.

Field Documentation

◆ address

unsigned int address

Sector starting address.

◆ index

unsigned int index

Index of the sector.

◆ size

unsigned int size

Sector size.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bit_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
bit_C Struct Reference

This stucture will be filled by values which characterize the device's option bytes. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [64]
char | description [1000]
unsigned int | wordOffset
unsigned int | bitOffset
unsigned int | bitWidth
unsigned char | access
unsigned int | valuesNbr
bitValue_C ** values
bitCoefficient_C equation
unsigned char * | reference
unsigned int | bitValue

Detailed Description

This stucture will be filled by values which characterize the device's option bytes.

Note
See product reference manual for more details.

Field Documentation

◆ access

unsigned char access

Access Read/Write.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitOffset

unsigned int bitOffset

Bit offset.

◆ bitValue

unsigned int bitValue
Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitWidth

unsigned int bitWidth

Number of bits build the option.

◆ description

char description[1000]

Config description.

◆ equation

bitCoefficient_C equation

Bits equation, #BitCoefficient_C.

◆ name

char name[64]

Bit name such as RDP, BOR_LEV, nBOOT0...

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ reference

unsigned char* reference

◆ values

bitValue_C** values

Bits value, #BitValue_C.

◆ valuesNbr

unsigned int valuesNbr

Number of possible values.

◆ wordOffset

unsigned int wordOffset

Word offset.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bitCoefficient_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
bitCoefficient_C Struct Reference

This stucture indicates the coefficients to access to the adequate option bit. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | multiplier
unsigned int | offset

Detailed Description

This stucture indicates the coefficients to access to the adequate option bit.

Field Documentation

◆ multiplier

unsigned int multiplier

Bit multiplier.

◆ offset

unsigned int offset

Bit offset.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: bitValue_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
bitValue_C Struct Reference

This stucture describes the option Bit value. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int | value
char | description [1000]

Detailed Description

This stucture describes the option Bit value.

Field Documentation

◆ description

char description[1000]

Option bit description.

◆ value

unsigned int value

Option bit value.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: canConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
canConnectParameters Struct Reference

Specify the CAN connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

int | br
int | mode
int | ide
int | rtr
int | fifo
int | fm
int | fs
int | fe
char | fbn

Detailed Description

Specify the CAN connect parameters.

Note
Not all configurations are supported by STM32 Bootloader, such as CAN type is STANDARD and the filter should be always activated.
Recommended CAN parameters : br=125000, mode=0, ide=0, rtr=0, fifo=0, fm=0, fs=1, fe=1, fbn=0
Examples
CAN_Bootloader.

Field Documentation

◆ br

int br

Baudrate and speed transmission 125KHz, 250KHz, 500KHz...

Examples
CAN_Bootloader.

◆ fbn

char fbn

Filter bank number: 0 to 13.

Examples
CAN_Bootloader.

◆ fe

int fe

Filter activation: DISABLE or ENABLE.

Examples
CAN_Bootloader.

◆ fifo

int fifo

Memory of received messages: FIFO0 or FIFO1.

Examples
CAN_Bootloader.

◆ fm

int fm

Filter mode: MASK or LIST.

Examples
CAN_Bootloader.

◆ fs

int fs

Filter scale: 16 or 32.

Examples
CAN_Bootloader.

◆ ide

int ide

CAN type: STANDARD or EXTENDED.

Examples
CAN_Bootloader.

◆ mode

int mode

CAN mode: NORMAL, LOOPBACK...,

Examples
CAN_Bootloader.

◆ rtr

int rtr

Frame format: DATA or REMOTE.

Examples
CAN_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: category_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
category_C Struct Reference

Get option bytes banks categories descriptions. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [100]
unsigned int | bitsNbr
bit_C ** bits

Detailed Description

Get option bytes banks categories descriptions.

Field Documentation

◆ bits

bit_C** bits

Get internal bits descriptions.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ bitsNbr

unsigned int bitsNbr

Get bits number of the considered category.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ name

char name[100]

Get category name such as Read Out Protection, BOR Level...

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: debugConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
debugConnectParameters Struct Reference

Get device characterization and specify connection parameters through ST-LINK interface. More...

#include <CubeProgrammer_API.h>

Data Fields

debugPort dbgPort
int | index
char | serialNumber [33]
char | firmwareVersion [20]
char | targetVoltage [5]
int | accessPortNumber
int | accessPort
debugConnectMode connectionMode
debugResetMode resetMode
int | isOldFirmware
frequencies freq
int | frequency
int | isBridge
int | shared
char | board [100]
int | DBG_Sleep
int | speed

Detailed Description

Get device characterization and specify connection parameters through ST-LINK interface.

Examples
HSM_Example, STLINK_Example1, STLINK_Example2, and STLINK_Example3.

Field Documentation

◆ accessPort

int accessPort

Select access port controller.

◆ accessPortNumber

int accessPortNumber

Number of available access port.

◆ board

char board[100]

board Name

◆ connectionMode

debugConnectMode connectionMode

Select the debug CONNECT mode debugConnectMode.

Examples
HSM_Example, STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ DBG_Sleep

int DBG_Sleep

◆ dbgPort

debugPort dbgPort

Select the type of debug interface debugPort.

◆ firmwareVersion

char firmwareVersion[20]

Firmware version.

◆ freq

frequencies freq

Supported frequencies frequencies.

◆ frequency

int frequency

Select specific frequency.

◆ index

int index

Select one of the debug ports connected.

◆ isBridge

int isBridge

Indicates if it's Bridge device or not.

◆ isOldFirmware

int isOldFirmware

Check Old ST-LINK firmware version.

◆ resetMode

debugResetMode resetMode

Select the debug RESET mode debugResetMode.

◆ serialNumber

char serialNumber[33]

ST-LINK serial number.

◆ shared

int shared

Select connection type, if it's shared, use ST-LINK Server.

Examples
HSM_Example, STLINK_Example1, STLINK_Example2, and STLINK_Example3.

◆ speed

int speed

Select speed flashing of Cortex M33 series.

◆ targetVoltage

char targetVoltage[5]

Operate voltage.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: deviceBank Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
deviceBank Struct Reference

This stucture defines the memory sectors for each bank. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int sectorsNumber
bankSector * sectors

Detailed Description

This stucture defines the memory sectors for each bank.

Field Documentation

◆ sectors

bankSector* sectors

Sectors specifications #Bank_Sector.

◆ sectorsNumber

unsigned int sectorsNumber

Number of sectors of the considered bank.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: deviceSector Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
deviceSector Struct Reference

Get device sectors basic informations. More...

#include <CubeProgrammer_API.h>

Data Fields

uint32_t | sectorNum
uint32_t | sectorSize

Detailed Description

Get device sectors basic informations.

Field Documentation

◆ sectorNum

uint32_t sectorNum

Number of Sectors.

◆ sectorSize

uint32_t sectorSize

Sector Size in BYTEs.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: dfuConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
dfuConnectParameters Struct Reference

Specify the USB DFU connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

char * | usb_index
char | rdu
char | tzenreg

Detailed Description

Specify the USB DFU connect parameters.

Field Documentation

◆ rdu

char rdu

request a read unprotect: value in {0,1}.

◆ tzenreg

char tzenreg

request a TZEN regression: value in {0,1}.

◆ usb_index

char* usb_index
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: dfuDeviceInfo Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
dfuDeviceInfo Struct Reference

Get DFU device informations . More...

#include <CubeProgrammer_API.h>

Data Fields

char | usbIndex [10]
int | busNumber
int | addressNumber
char | productId [100]
char | serialNumber [100]
unsigned int | dfuVersion

Detailed Description

Get DFU device informations .

Examples
MPU_SSP, TSV_Flashing, and USB_Bootloader.

Field Documentation

◆ addressNumber

int addressNumber

Address number.

◆ busNumber

int busNumber

Bus number.

◆ dfuVersion

unsigned int dfuVersion

DFU version.

◆ productId

char productId[100]

Product number.

◆ serialNumber

char serialNumber[100]

Serial number.

◆ usbIndex

char usbIndex[10]

USB index.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: displayCallBacks Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
displayCallBacks Struct Reference

Functions must be implemented to personalize the display of messages. More...

#include <CubeProgrammer_API.h>

Data Fields

void(* | initProgressBar )()
void(* | logMessage )(int msgType, const wchar_t *str)
void(* | loadBar )(int x, int n)

Detailed Description

Functions must be implemented to personalize the display of messages.

Examples
main.

Field Documentation

◆ initProgressBar

void(* initProgressBar) ()

Add a progress bar.

Examples
main.

◆ loadBar

void(* loadBar) (int x, int n)

Display the loading of read/write process.

Examples
main.

◆ logMessage

void(* logMessage) (int msgType, const wchar_t *str)

Display internal messages according to verbosity level.

Examples
main.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: externalLoader Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
externalLoader Struct Reference

Get external Loader parameters to launch the process of programming an external flash memory. More...

#include <CubeProgrammer_API.h>

Data Fields

char | filePath [200]
char | deviceName [100]
int | deviceType
uint32_t | deviceStartAddress
uint32_t | deviceSize
uint32_t | pageSize
uint32_t | sectorsTypeNbr
deviceSector * sectors

Detailed Description

Get external Loader parameters to launch the process of programming an external flash memory.

Field Documentation

◆ deviceName

char deviceName[100]

Device Name and Description.

◆ deviceSize

uint32_t deviceSize

Total Size of Device.

◆ deviceStartAddress

uint32_t deviceStartAddress

Default Device Start Address.

◆ deviceType

int deviceType

Device Type: ONCHIP, EXT8BIT, EXT16BIT, ...

◆ filePath

char filePath[200]

FlashLoader file path.

◆ pageSize

uint32_t pageSize

Programming Page Size.

◆ sectors

deviceSector* sectors

Device sectors.

◆ sectorsTypeNbr

uint32_t sectorsTypeNbr

Type number.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: externalStorageInfo Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
externalStorageInfo Struct Reference

Get external storage informations useful for external Loader. More...

#include <CubeProgrammer_API.h>

Data Fields

unsigned int externalLoaderNbr
externalLoader * externalLoader

Detailed Description

Get external storage informations useful for external Loader.

Field Documentation

◆ externalLoader

externalLoader* externalLoader

◆ externalLoaderNbr

unsigned int externalLoaderNbr
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: fileData_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
fileData_C Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

int | Type
int | segmentsNbr
segmentData_C * segments

Field Documentation

◆ segments

segmentData_C* segments

Segments description.

◆ segmentsNbr

int segmentsNbr

Number of required segments.

◆ Type

int Type

File extension type.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: FileData_C Struct Reference

  • Data Structure Index
  • Data Fields
FileData_C Struct Reference

Get file required informations. More...

#include <CubeProgrammer_API.h>

Detailed Description

Get file required informations.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: frequencies Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
frequencies Struct Reference

Get supported frequencies for JTAG and SWD ineterfaces. More...

#include <CubeProgrammer_API.h>

Data Fields

unsigned int | jtagFreq [12]
unsigned int | jtagFreqNumber
unsigned int | swdFreq [12]
unsigned int | swdFreqNumber

Detailed Description

Get supported frequencies for JTAG and SWD ineterfaces.

Field Documentation

◆ jtagFreq

unsigned int jtagFreq[12]

JTAG frequency.

◆ jtagFreqNumber

unsigned int jtagFreqNumber

Get JTAG supported frequencies.

◆ swdFreq

unsigned int swdFreq[12]

SWD frequency.

◆ swdFreqNumber

unsigned int swdFreqNumber

Get SWD supported frequencies.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: generalInf Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
generalInf Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

unsigned short | deviceId
int | flashSize
int | bootloaderVersion
char | type [4]
char | cpu [20]
char | name [100]
char | series [100]
char | description [150]
char | revisionId [8]
char | board [100]

Detailed Description

Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

Field Documentation

◆ board

char board[100]

Board Rpn.

◆ bootloaderVersion

int bootloaderVersion

Bootloader version

◆ cpu

char cpu[20]

Cortex CPU.

Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ description

char description[150]

Take notice.

◆ deviceId

unsigned short deviceId

Device ID.

◆ flashSize

int flashSize

Flash memory size.

◆ name

char name[100]

Device name.

Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.

◆ revisionId

char revisionId[8]

Revision ID.

◆ series

char series[100]

Device serie.

◆ type

char type[4]

Device MCU or MPU.

Examples
CAN_Bootloader, HSM_Example, I2C_Bootloader, MPU_SSP, SPI_Bootloader, STLINK_Example1, STLINK_Example2, STLINK_Example3, TSV_Flashing, UART_Bootloader, and USB_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: GeneralInf Struct Reference

  • Data Structure Index
  • Data Fields
GeneralInf Struct Reference

Get device general informations. More...

#include <CubeProgrammer_API.h>

Detailed Description

Get device general informations.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: i2cConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
i2cConnectParameters Struct Reference

Specify the I2C connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

int | add
int | br
int | sm
int | am
int | af
int | df
char | dnf
int | rt
int | ft

Detailed Description

Specify the I2C connect parameters.

Warning
The Bootloader Slave address varies depending on the device (see AN2606).
Note
Not all configurations are supported by STM32 Bootloader, such as address in 7 bits form, analog filter: ENABLE, digital filter: DISABLE.
Recommended I2C parameters : add=0x??, br=400, sm=1, am=0, af=1, df=0, dnf=0, rt=0, ft=0
Examples
I2C_Bootloader.

Field Documentation

◆ add

int add

Device address in hex format.

Examples
I2C_Bootloader.

◆ af

int af

Analog filter: DISABLE or ENABLE.

Examples
I2C_Bootloader.

◆ am

int am

Address Mode: 7 or 10 bits.

Examples
I2C_Bootloader.

◆ br

int br

Baudrate and speed transmission : 100 or 400 KHz.

Examples
I2C_Bootloader.

◆ df

int df

Digital filter: DISABLE or ENABLE.

Examples
I2C_Bootloader.

◆ dnf

char dnf

Digital noise filter: 0 to 15.

Examples
I2C_Bootloader.

◆ ft

int ft

Fall time: 0-300 for STANDARD speed mode and 0-300 for FAST.

Examples
I2C_Bootloader.

◆ rt

int rt

Rise time: 0-1000 for STANDARD speed mode and 0-300 for FAST.

Examples
I2C_Bootloader.

◆ sm

int sm

Speed Mode: STANDARD or FAST.

Examples
I2C_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: peripheral_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
peripheral_C Struct Reference

Get peripheral option bytes general informations. More...

#include <DeviceDataStructure.h>

Data Fields

char | name [64]
char | description [1000]
unsigned int | banksNbr
bank_C ** banks

Detailed Description

Get peripheral option bytes general informations.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

Field Documentation

◆ banks

bank_C** banks

Get banks descriptions #Bank_C.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ banksNbr

unsigned int banksNbr

Number of existed banks.

Examples
CAN_Bootloader, I2C_Bootloader, SPI_Bootloader, STLINK_Example1, STLINK_Example3, UART_Bootloader, and USB_Bootloader.

◆ description

char description[1000]

Peripheral description.

◆ name

char name[64]

Peripheral name.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: segmentData_C Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
segmentData_C Struct Reference

#include <CubeProgrammer_API.h>

Data Fields

int | address
int | size
unsigned char * | data

Field Documentation

◆ address

int address

Segment start address.

◆ data

unsigned char* data

Memory segment data.

◆ size

int size

Memory segment size.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: spiConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
spiConnectParameters Struct Reference

Specify the SPI connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

uint32_t | baudrate
uint16_t | crcPol
int | direction
int | cpha
int | cpol
int | crc
int | firstBit
int | frameFormat
int | dataSize
int | mode
int | nss
int | nssPulse
int | delay

Detailed Description

Specify the SPI connect parameters.

Note
Recommended SPI parameters : baudrate=375, crcPol=7, direction=0, cpha=0, cpol=0, crc=0, firstBit=1, frameFormat=0, dataSize=1, mode=1, nss=1, nssPulse=1, delay=1
Examples
SPI_Bootloader.

Field Documentation

◆ baudrate

uint32_t baudrate

Speed transmission 187, 375, 750, 1500, 3000, 6000, 12000 KHz.

Examples
SPI_Bootloader.

◆ cpha

int cpha

1Edge or 2Edge.

Examples
SPI_Bootloader.

◆ cpol

int cpol

LOW or HIGH.

Examples
SPI_Bootloader.

◆ crc

int crc

DISABLE or ENABLE.

Examples
SPI_Bootloader.

◆ crcPol

uint16_t crcPol

crc polynom value.

Examples
SPI_Bootloader.

◆ dataSize

int dataSize

Size of frame data: 16bit or 8bit .

Examples
SPI_Bootloader.

◆ delay

int delay

Delay of few microseconds, No Delay or Delay, at least 4us delay is inserted

Examples
SPI_Bootloader.

◆ direction

int direction

2LFullDuplex/2LRxOnly/1LRx/1LTx.

Examples
SPI_Bootloader.

◆ firstBit

int firstBit

First bit: LSB or MSB.

Examples
SPI_Bootloader.

◆ frameFormat

int frameFormat

Frame format: Motorola or TI.

Examples
SPI_Bootloader.

◆ mode

int mode

Operating mode: Slave or Master.

Examples
SPI_Bootloader.

◆ nss

int nss

Selection: Soft or Hard.

Examples
SPI_Bootloader.

◆ nssPulse

int nssPulse

NSS pulse: No Pulse or Pulse.

Examples
SPI_Bootloader.
The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: storageStructure Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
storageStructure Struct Reference

This stucture describes sotrage characterization. More...

#include <DeviceDataStructure.h>

Data Fields

unsigned int banksNumber
deviceBank * banks

Detailed Description

This stucture describes sotrage characterization.

Field Documentation

◆ banks

deviceBank* banks

Banks sectors definition #Device_Bank.

◆ banksNumber

unsigned int banksNumber

Number of exsisted banks.

The documentation for this struct was generated from the following file:
  • files/DeviceDataStructure.h


STM32CubeProgrammer API: usartConnectParameters Struct Reference

  • Data Structure Index
  • Data Fields
Data Fields
usartConnectParameters Struct Reference

Specify the USART connect parameters. More...

#include <CubeProgrammer_API.h>

Data Fields

char | portName [100]
unsigned int | baudrate
usartParity parity
unsigned char | dataBits
float | stopBits
usartFlowControl flowControl
int | statusRTS
int | statusDTR
unsigned char | noinitBits
char | rdu
char | tzenreg

Detailed Description

Specify the USART connect parameters.

Examples
UART_Bootloader.

Field Documentation

◆ baudrate

unsigned int baudrate

Speed transmission: 115200, 9600...

◆ dataBits

unsigned char dataBits

Data bit: value in {6, 7, 8}.

◆ flowControl

usartFlowControl flowControl

Flow control: value in usartFlowControl.

◆ noinitBits

unsigned char noinitBits

Set No Init bits: value in {0,1}.

◆ parity

usartParity parity

Parity bit: value in usartParity.

◆ portName

char portName[100]

Interface identifier: COM1, COM2, /dev/ttyS0...

◆ rdu

char rdu

request a read unprotect: value in {0,1}.

◆ statusDTR

int statusDTR

DTR: Value in {0,1}.

◆ statusRTS

int statusRTS

RTS: Value in {0,1}.

◆ stopBits

float stopBits

Stop bit: value in {1, 1.5, 2}.

◆ tzenreg

char tzenreg

request a TZEN regression: value in {0,1}.

The documentation for this struct was generated from the following file:
  • files/CubeProgrammer_API.h


STM32CubeProgrammer API: Data Structure Index

  • Data Structure Index
  • Data Fields
Data Structure Index
B | C | D | E | F | G | I | P | S | U
B
bank_C
bankSector
bit_C
bitCoefficient_C
bitValue_C
C
canConnectParameters
category_C
D
debugConnectParameters
deviceBank
deviceSector
dfuConnectParameters
dfuDeviceInfo
displayCallBacks
E
externalLoader
externalStorageInfo
F
fileData_C
FileData_C
frequencies
G
generalInf
GeneralInf
I
i2cConnectParameters
P
peripheral_C
S
segmentData_C
spiConnectParameters
storageStructure
U
usartConnectParameters


STM32CubeProgrammer API: Data Fields

  • Data Structure Index
  • Data Fields
  • All
  • Variables
  • a
  • b
  • c
  • d
  • e
  • f
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
Here is a list of all struct and union fields with links to the structures/unions they belong to:

- a -

  • access : bank_C, bit_C
  • accessPort : debugConnectParameters
  • accessPortNumber : debugConnectParameters
  • add : i2cConnectParameters
  • address : bank_C, bankSector, segmentData_C
  • addressNumber : dfuDeviceInfo
  • af : i2cConnectParameters
  • am : i2cConnectParameters

- b -

  • banks : peripheral_C, storageStructure
  • banksNbr : peripheral_C
  • banksNumber : storageStructure
  • baudrate : spiConnectParameters, usartConnectParameters
  • bitOffset : bit_C
  • bits : category_C
  • bitsNbr : category_C
  • bitValue : bit_C
  • bitWidth : bit_C
  • board : debugConnectParameters, generalInf
  • bootloaderVersion : generalInf
  • br : canConnectParameters, i2cConnectParameters
  • busNumber : dfuDeviceInfo

- c -

  • categories : bank_C
  • categoriesNbr : bank_C
  • connectionMode : debugConnectParameters
  • cpha : spiConnectParameters
  • cpol : spiConnectParameters
  • cpu : generalInf
  • crc : spiConnectParameters
  • crcPol : spiConnectParameters

- d -

  • data : segmentData_C
  • dataBits : usartConnectParameters
  • dataSize : spiConnectParameters
  • DBG_Sleep : debugConnectParameters
  • dbgPort : debugConnectParameters
  • delay : spiConnectParameters
  • description : bit_C, bitValue_C, generalInf, peripheral_C
  • deviceId : generalInf
  • deviceName : externalLoader
  • deviceSize : externalLoader
  • deviceStartAddress : externalLoader
  • deviceType : externalLoader
  • df : i2cConnectParameters
  • dfuVersion : dfuDeviceInfo
  • direction : spiConnectParameters
  • dnf : i2cConnectParameters

- e -

  • equation : bit_C
  • externalLoader : externalStorageInfo
  • externalLoaderNbr : externalStorageInfo

- f -

  • fbn : canConnectParameters
  • fe : canConnectParameters
  • fifo : canConnectParameters
  • filePath : externalLoader
  • firmwareVersion : debugConnectParameters
  • firstBit : spiConnectParameters
  • flashSize : generalInf
  • flowControl : usartConnectParameters
  • fm : canConnectParameters
  • frameFormat : spiConnectParameters
  • freq : debugConnectParameters
  • frequency : debugConnectParameters
  • fs : canConnectParameters
  • ft : i2cConnectParameters

- i -

  • ide : canConnectParameters
  • index : bankSector, debugConnectParameters
  • initProgressBar : displayCallBacks
  • isBridge : debugConnectParameters
  • isOldFirmware : debugConnectParameters

- j -

  • jtagFreq : frequencies
  • jtagFreqNumber : frequencies

- l -

  • loadBar : displayCallBacks
  • logMessage : displayCallBacks

- m -

  • mode : canConnectParameters, spiConnectParameters
  • multiplier : bitCoefficient_C

- n -

  • name : bit_C, category_C, generalInf, peripheral_C
  • noinitBits : usartConnectParameters
  • nss : spiConnectParameters
  • nssPulse : spiConnectParameters

- o -

  • offset : bitCoefficient_C

- p -

  • pageSize : externalLoader
  • parity : usartConnectParameters
  • portName : usartConnectParameters
  • productId : dfuDeviceInfo

- r -

  • rdu : dfuConnectParameters, usartConnectParameters
  • reference : bit_C
  • resetMode : debugConnectParameters
  • revisionId : generalInf
  • rt : i2cConnectParameters
  • rtr : canConnectParameters

- s -

  • sectorNum : deviceSector
  • sectors : deviceBank, externalLoader
  • sectorSize : deviceSector
  • sectorsNumber : deviceBank
  • sectorsTypeNbr : externalLoader
  • segments : fileData_C
  • segmentsNbr : fileData_C
  • serialNumber : debugConnectParameters, dfuDeviceInfo
  • series : generalInf
  • shared : debugConnectParameters
  • size : bank_C, bankSector, segmentData_C
  • sm : i2cConnectParameters
  • speed : debugConnectParameters
  • statusDTR : usartConnectParameters
  • statusRTS : usartConnectParameters
  • stopBits : usartConnectParameters
  • swdFreq : frequencies
  • swdFreqNumber : frequencies

- t -

  • targetVoltage : debugConnectParameters
  • Type : fileData_C
  • type : generalInf
  • tzenreg : dfuConnectParameters, usartConnectParameters

- u -

  • usb_index : dfuConnectParameters
  • usbIndex : dfuDeviceInfo

- v -

  • value : bitValue_C
  • values : bit_C
  • valuesNbr : bit_C

- w -

  • wordOffset : bit_C


STM32CubeProgrammer API: Data Fields - Variables

  • Data Structure Index
  • Data Fields
  • All
  • Variables
  • a
  • b
  • c
  • d
  • e
  • f
  • i
  • j
  • l
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w

- a -

  • access : bank_C, bit_C
  • accessPort : debugConnectParameters
  • accessPortNumber : debugConnectParameters
  • add : i2cConnectParameters
  • address : bank_C, bankSector, segmentData_C
  • addressNumber : dfuDeviceInfo
  • af : i2cConnectParameters
  • am : i2cConnectParameters

- b -

  • banks : peripheral_C, storageStructure
  • banksNbr : peripheral_C
  • banksNumber : storageStructure
  • baudrate : spiConnectParameters, usartConnectParameters
  • bitOffset : bit_C
  • bits : category_C
  • bitsNbr : category_C
  • bitValue : bit_C
  • bitWidth : bit_C
  • board : debugConnectParameters, generalInf
  • bootloaderVersion : generalInf
  • br : canConnectParameters, i2cConnectParameters
  • busNumber : dfuDeviceInfo

- c -

  • categories : bank_C
  • categoriesNbr : bank_C
  • connectionMode : debugConnectParameters
  • cpha : spiConnectParameters
  • cpol : spiConnectParameters
  • cpu : generalInf
  • crc : spiConnectParameters
  • crcPol : spiConnectParameters

- d -

  • data : segmentData_C
  • dataBits : usartConnectParameters
  • dataSize : spiConnectParameters
  • DBG_Sleep : debugConnectParameters
  • dbgPort : debugConnectParameters
  • delay : spiConnectParameters
  • description : bit_C, bitValue_C, generalInf, peripheral_C
  • deviceId : generalInf
  • deviceName : externalLoader
  • deviceSize : externalLoader
  • deviceStartAddress : externalLoader
  • deviceType : externalLoader
  • df : i2cConnectParameters
  • dfuVersion : dfuDeviceInfo
  • direction : spiConnectParameters
  • dnf : i2cConnectParameters

- e -

  • equation : bit_C
  • externalLoader : externalStorageInfo
  • externalLoaderNbr : externalStorageInfo

- f -

  • fbn : canConnectParameters
  • fe : canConnectParameters
  • fifo : canConnectParameters
  • filePath : externalLoader
  • firmwareVersion : debugConnectParameters
  • firstBit : spiConnectParameters
  • flashSize : generalInf
  • flowControl : usartConnectParameters
  • fm : canConnectParameters
  • frameFormat : spiConnectParameters
  • freq : debugConnectParameters
  • frequency : debugConnectParameters
  • fs : canConnectParameters
  • ft : i2cConnectParameters

- i -

  • ide : canConnectParameters
  • index : bankSector, debugConnectParameters
  • initProgressBar : displayCallBacks
  • isBridge : debugConnectParameters
  • isOldFirmware : debugConnectParameters

- j -

  • jtagFreq : frequencies
  • jtagFreqNumber : frequencies

- l -

  • loadBar : displayCallBacks
  • logMessage : displayCallBacks

- m -

  • mode : canConnectParameters, spiConnectParameters
  • multiplier : bitCoefficient_C

- n -

  • name : bit_C, category_C, generalInf, peripheral_C
  • noinitBits : usartConnectParameters
  • nss : spiConnectParameters
  • nssPulse : spiConnectParameters

- o -

  • offset : bitCoefficient_C

- p -

  • pageSize : externalLoader
  • parity : usartConnectParameters
  • portName : usartConnectParameters
  • productId : dfuDeviceInfo

- r -

  • rdu : dfuConnectParameters, usartConnectParameters
  • reference : bit_C
  • resetMode : debugConnectParameters
  • revisionId : generalInf
  • rt : i2cConnectParameters
  • rtr : canConnectParameters

- s -

  • sectorNum : deviceSector
  • sectors : deviceBank, externalLoader
  • sectorSize : deviceSector
  • sectorsNumber : deviceBank
  • sectorsTypeNbr : externalLoader
  • segments : fileData_C
  • segmentsNbr : fileData_C
  • serialNumber : debugConnectParameters, dfuDeviceInfo
  • series : generalInf
  • shared : debugConnectParameters
  • size : bank_C, bankSector, segmentData_C
  • sm : i2cConnectParameters
  • speed : debugConnectParameters
  • statusDTR : usartConnectParameters
  • statusRTS : usartConnectParameters
  • stopBits : usartConnectParameters
  • swdFreq : frequencies
  • swdFreqNumber : frequencies

- t -

  • targetVoltage : debugConnectParameters
  • Type : fileData_C
  • type : generalInf
  • tzenreg : dfuConnectParameters, usartConnectParameters

- u -

  • usb_index : dfuConnectParameters
  • usbIndex : dfuDeviceInfo

- v -

  • value : bitValue_C
  • values : bit_C
  • valuesNbr : bit_C

- w -

  • wordOffset : bit_C


STM32CubeProgrammer API: File List

  • File List
  • Globals
File List
Here is a list of all files with brief descriptions:
[detail level 12]
▼ files
CAN_Example.cpp
CubeProgrammer_API.h
DeviceDataStructure.h
DisplayManager.cpp
Example1.cpp
Example2.cpp
Example3.cpp
Example_WB.cpp
HSM_Example.cpp
I2C_Example.cpp
main.cpp
MPU_SSP.cpp
SPI_Example.cpp
TSV_Flashing.cpp
UART_Example.cpp
USB_Example.cpp
USB_Example_WB.cpp


STM32CubeProgrammer API: files Directory Reference

  • File List
  • Globals
  • files
files Directory Reference

Files

file | CAN_Example.cpp
file | CubeProgrammer_API.h [code]
file | DeviceDataStructure.h [code]
file | DisplayManager.cpp
file | Example1.cpp
file | Example2.cpp
file | Example3.cpp
file | Example_WB.cpp
file | HSM_Example.cpp
file | I2C_Example.cpp
file | main.cpp
file | MPU_SSP.cpp
file | SPI_Example.cpp
file | TSV_Flashing.cpp
file | UART_Example.cpp
file | USB_Example.cpp
file | USB_Example_WB.cpp


STM32CubeProgrammer API: files/CAN_Example.cpp File Reference

  • File List
  • Globals
  • files
CAN_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through CAN Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via CAN interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : CAN_Bootloader


STM32CubeProgrammer API: files/CubeProgrammer_API.h File Reference

  • File List
  • Globals
  • files
Data Structures | Macros | Typedefs | Enumerations | Functions
CubeProgrammer_API.h File Reference
#include <stdint.h>
#include "DeviceDataStructure.h"

Go to the source code of this file.

Data Structures

struct | dfuDeviceInfo
Get DFU device informations . More...
struct | usartConnectParameters
Specify the USART connect parameters. More...
struct | dfuConnectParameters
Specify the USB DFU connect parameters. More...
struct | spiConnectParameters
Specify the SPI connect parameters. More...
struct | canConnectParameters
Specify the CAN connect parameters. More...
struct | i2cConnectParameters
Specify the I2C connect parameters. More...
struct | frequencies
Get supported frequencies for JTAG and SWD ineterfaces. More...
struct | debugConnectParameters
Get device characterization and specify connection parameters through ST-LINK interface. More...
struct | displayCallBacks
Functions must be implemented to personalize the display of messages. More...
struct | segmentData_C
struct | fileData_C
struct | generalInf
struct | deviceSector
Get device sectors basic informations. More...
struct | externalLoader
Get external Loader parameters to launch the process of programming an external flash memory. More...
struct | externalStorageInfo
Get external storage informations useful for external Loader. More...

Macros

#define CP_EXPORTS

Typedefs

typedef enum usartParity | usartParity
typedef enum usartFlowControl | usartFlowControl
typedef struct dfuDeviceInfo | dfuDeviceInfo
typedef struct usartConnectParameters | usartConnectParameters
typedef struct dfuConnectParameters | dfuConnectParameters
typedef struct spiConnectParameters | spiConnectParameters
typedef struct canConnectParameters | canConnectParameters
typedef struct i2cConnectParameters | i2cConnectParameters
typedef enum debugResetMode | debugResetMode
typedef enum debugConnectMode | debugConnectMode
typedef enum debugPort | debugPort
typedef struct frequencies | frequencies
typedef struct debugConnectParameters | debugConnectParameters
typedef enum targetInterfaceType | targetInterfaceType
typedef struct displayCallBacks | displayCallBacks
typedef struct segmentData_C | segmentData_C
typedef struct fileData_C | fileData_C
typedef struct generalInf | generalInf
typedef struct deviceSector | deviceSector
typedef struct externalLoader | externalLoader
typedef struct externalStorageInfo | externalStorageInfo

Enumerations

enum cubeProgrammerVerbosityLevel {
CUBEPROGRAMMER_VER_LEVEL_NONE = 0 , CUBEPROGRAMMER_VER_LEVEL_ONE = 1 , CUBEPROGRAMMER_VER_LEVEL_TWO = 2 , CUBEPROGRAMMER_VER_LEVEL_DEBUG = 3 ,
CUBEPROGRAMMER_NO_PROGRESS_BAR = 4
}
List of verbosity levels. More...
enum cubeProgrammerError {
CUBEPROGRAMMER_NO_ERROR = 0 , CUBEPROGRAMMER_ERROR_NOT_CONNECTED = -1 , CUBEPROGRAMMER_ERROR_NO_DEVICE = -2 , CUBEPROGRAMMER_ERROR_CONNECTION = -3 ,
CUBEPROGRAMMER_ERROR_NO_FILE = -4 , CUBEPROGRAMMER_ERROR_NOT_SUPPORTED = -5 , CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED = -6 , CUBEPROGRAMMER_ERROR_NO_MEM = -7 ,
CUBEPROGRAMMER_ERROR_WRONG_PARAM = -8 , CUBEPROGRAMMER_ERROR_READ_MEM = -9 , CUBEPROGRAMMER_ERROR_WRITE_MEM = -10 , CUBEPROGRAMMER_ERROR_ERASE_MEM = -11 ,
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT = -12 , CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED = -13 , CUBEPROGRAMMER_ERROR_NO_SECURITY = -14 , CUBEPROGRAMMER_ERROR_CHANGE_FREQ = -15 ,
CUBEPROGRAMMER_ERROR_RDP_ENABLED = -16 , CUBEPROGRAMMER_ERROR_OTHER = -99
}
List of errors that can be occured. More...
enum | flashSize { Flash_Size_1KB = (1024) , Flash_Size_512KB = (512*1024) , Flash_Size_256KB = (256*1024) }
enum wbFunctionArguments {
FIRST_INSTALL_ACTIVE = 1 , FIRST_INSTALL_NOT_ACTIVE = 0 , START_STACK_ACTIVE =1 , START_STACK_NOT_ACTIVE =1 ,
VERIFY_FILE_DOWLOAD_FILE =1 , DO_NOT_VERIFY_DOWLOAD_FILE =0
}
enum | usartParity { EVEN = 0 , ODD = 1 , NONE = 2 }
The parity bit in the data frame of the USART communication tells the receiving device if there is any error in the data bits. More...
enum | usartFlowControl { OFF = 0 , HARDWARE = 1 , SOFTWARE = 2 }
UART Flow Control is a method for devices to communicate with each other over UART without the risk of losing data. More...
enum | debugResetMode { SOFTWARE_RESET , HARDWARE_RESET , CORE_RESET }
Choose the way to apply a system reset. More...
enum debugConnectMode {
NORMAL_MODE , HOTPLUG_MODE , UNDER_RESET_MODE , POWER_DOWN_MODE ,
PRE_RESET_MODE , hwRstPulse_MODE
}
Choose the appropriate mode for connection. More...
enum | debugPort { JTAG = 0 , SWD = 1 }
Select the debug port interface for connection. More...
enum targetInterfaceType {
STLINK_INTERFACE = 0 , USART_INTERFACE = 1 , USB_INTERFACE = 2 , SPI_INTERFACE = 3 ,
I2C_INTERFACE = 4 , CAN_INTERFACE = 5 , JLINK_INTERFACE = 6
}
Indicates the supported interfaces. More...

Functions

int | getStLinkList (debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s).
int | getStLinkEnumerationList (debugConnectParameters **stlink_list, int shared)
This routine allows to get ST-LINK conneted probe(s) without connecting and intruse the target.
int | connectStLink (debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces.
int | reset (debugResetMode rstMode)
This routine used to apply a target reset.
int | getUsartList (usartConnectParameters **usartList)
This routine allows to get connected serial ports.
int | connectUsartBootloader (usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface.
int | sendByteUart (int byte)
This routine allows to send a single byte through the USART interface.
int | getDfuDeviceList (dfuDeviceInfo **dfuList, int iPID, int iVID)
This routine allows to get connected DFU devices.
int | connectDfuBootloader (char *usbIndex)
This routine allows to start a simple connection through USB DFU interface.
int | connectDfuBootloader2 (dfuConnectParameters dfuParameters)
This routine allows to start connection to device through USB DFU interface.
int | connectSpiBootloader (spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface.
int | connectCanBootloader (canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface.
int | connectI2cBootloader (i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface.
void | setDisplayCallbacks (displayCallBacks c)
This routine allows to choose your custom display.
void | setVerbosityLevel (int level)
This routine allows to choose the verbosity level for display.
int | checkDeviceConnection ()
This routine allows to check connection status [maintained or lost].
generalInf * getDeviceGeneralInf ()
This routine allows to get general device informations.
int | readMemory (unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initialized.
int | writeMemory (unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initialized.
int | editSector (unsigned int address, char *data, unsigned int size)
This routine allows to write sector data on the user interface with the configration already initialized.
int | downloadFile (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex, bin, srec, tsv, elf, axf, out, stm32, ext.
int | execute (unsigned int address)
This routine allows to run the application.
int | massErase (char *sFlashMemName=nullptr)
This routine allows to erase the whole Flash memory.
int | sectorErase (unsigned int sectors[], unsigned int sectorNbr, char *sFlashMemName=nullptr)
This routine allows to erase specific sectors of the Flash memory.
int | readUnprotect ()
This routine allows to disable the readout protection. If the memory is not protected, a message appears to indicate that the device is not under Readout protection and the command has no effects.
int | tzenRegression ()
This routine allows the TZEN Option Byte regression.
int | getTargetInterfaceType ()
This routine allows to know the interface what is in use.
volatile int * | getCancelPointer ()
This routine allows to drop the current read/write operation.
void * | fileOpen (const wchar_t *filePath)
This routine allows to open and get data from any supported file extension.
void | freeFileData (fileData_C *data)
This routine allows to clean up the handled file data.
void | freeLibraryMemory (void *ptr)
This routine allows to free a specific memory region, typically used after readMemory().
int | verify (fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content.
int | saveFileToFile (fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file.
int | saveMemoryToFile (int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file.
void | disconnect ()
This routine allows to clean up and disconnect the current connected target.
void | deleteInterfaceList ()
This routine allows to clear the list of each created interface.
void | automaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.
void | serialNumberingAutomaticMode (const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run, int enableSerialNumbering, int serialAddress, int serialSize, char *serialInitialData)
This routine allows to enter and make an automatic process for memory management with serial numbering through JTAG/SWD, UART, DFU, SPI, CAN and I²C interfaces.
int | getStorageStructure (storageStructure **deviceStorageStruct)
This routine allows to get Flash storage information.
int | sendOptionBytesCmd (char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user depending on the application requirements.
peripheral_C * initOptionBytesInterface ()
This routine allows to get option bytes values of the connected target.
peripheral_C * | fastRomInitOptionBytesInterface (uint16_t deviceId)
int | obDisplay ()
This routine allows to display the Option bytes.
void | setLoadersPath (const char *path)
This routine allows to specify the location of Flash Loader.
void | setExternalLoaderPath (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded.
void | setExternalLoaderOBL (const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded via OBL interfaces.
int | getExternalLoaders (const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in the mentioned path.
void | removeExternalLoader (const char *path)
This routine allows to unload an external Loaders.
void | deleteLoaders ()
This routine allows to delete all target Flash Loaders.
int | getUID64 (unsigned char **data)
This routine allows to read the device unique identifier.
int | firmwareDelete ()
This routine allows to erase the BLE stack firmware.
int | firmwareUpgrade (const wchar_t *filePath, unsigned int address, unsigned int firstInstall, unsigned int startStack, unsigned int verify)
This routine allows to make upgrade of BLE stack firmware or FUS firmware.
int | startWirelessStack ()
This routine allows to start the programmed Stack.
int | updateAuthKey (const wchar_t *filePath)
This routine allows to start the programmed Stack.
int | authKeyLock ()
This routine allows to lock the authentication key and once locked, it is no longer possible to change it.
int | writeUserKey (const wchar_t *filePath, unsigned char keyType)
This routine allows to write a customized user key.
int | antiRollBack ()
This routine allows to activate the AntiRollBack.
int | startFus ()
This routine allows to start and establish a communication with the FUS operator.
int | unlockchip ()
This routine allows to set default option Bytes.
int | programSsp (const wchar_t *sspFile, const wchar_t *licenseFile, const wchar_t *tfaFile, int hsmSlotId)
This routine aims to launch the Secure Secret Provisioning.
const char * | getHsmFirmwareID (int hsmSlotId)
getHsmFirmwareID: this routine aims to get the HSM Firmware Identifier.
unsigned long | getHsmCounter (int hsmSlotId)
getHsmCounter: this routine aims to get the current HSM counter.
const char * | getHsmState (int hsmSlotId)
getHsmState: this routine aims to get the HSM State.
const char * | getHsmVersion (int hsmSlotId)
getHsmVersion: this routine aims to get the HSM version.
const char * | getHsmType (int hsmSlotId)
getHsmType: this routine aims to get the HSM type.
int | getHsmLicense (int hsmSlotId, const wchar_t *outLicensePath)
getHsmLicense: this routine aims to get and save the HSM license into a binary file.

Macro Definition Documentation

◆ CP_EXPORTS

#define CP_EXPORTS

Typedef Documentation

◆ canConnectParameters

typedef struct canConnectParameters canConnectParameters

◆ debugConnectMode

typedef enum debugConnectMode debugConnectMode

◆ debugConnectParameters

typedef struct debugConnectParameters debugConnectParameters

◆ debugPort

typedef enum debugPort debugPort

◆ debugResetMode

typedef enum debugResetMode debugResetMode

◆ deviceSector

typedef struct deviceSector deviceSector

◆ dfuConnectParameters

typedef struct dfuConnectParameters dfuConnectParameters

◆ dfuDeviceInfo

typedef struct dfuDeviceInfo dfuDeviceInfo

◆ displayCallBacks

typedef struct displayCallBacks displayCallBacks

◆ externalLoader

typedef struct externalLoader externalLoader

◆ externalStorageInfo

typedef struct externalStorageInfo externalStorageInfo

◆ fileData_C

typedef struct fileData_C fileData_C

◆ frequencies

typedef struct frequencies frequencies

◆ generalInf

typedef struct generalInf generalInf

◆ i2cConnectParameters

typedef struct i2cConnectParameters i2cConnectParameters

◆ segmentData_C

typedef struct segmentData_C segmentData_C

◆ spiConnectParameters

typedef struct spiConnectParameters spiConnectParameters

◆ targetInterfaceType

typedef enum targetInterfaceType targetInterfaceType

◆ usartConnectParameters

typedef struct usartConnectParameters usartConnectParameters

◆ usartFlowControl

typedef enum usartFlowControl usartFlowControl

◆ usartParity

typedef enum usartParity usartParity

Enumeration Type Documentation

◆ cubeProgrammerError

enum cubeProgrammerError

List of errors that can be occured.

Enumerator
CUBEPROGRAMMER_NO_ERROR | Success (no error)
CUBEPROGRAMMER_ERROR_NOT_CONNECTED | Device not connected
CUBEPROGRAMMER_ERROR_NO_DEVICE | Device not found
CUBEPROGRAMMER_ERROR_CONNECTION | Device connection error
CUBEPROGRAMMER_ERROR_NO_FILE | No such file
CUBEPROGRAMMER_ERROR_NOT_SUPPORTED | Operation not supported or unimplemented on this interface
CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED | Interface not supported or unimplemented on this plateform
CUBEPROGRAMMER_ERROR_NO_MEM | Insufficient memory
CUBEPROGRAMMER_ERROR_WRONG_PARAM | Wrong parameters
CUBEPROGRAMMER_ERROR_READ_MEM | Memory read failure
CUBEPROGRAMMER_ERROR_WRITE_MEM | Memory write failure
CUBEPROGRAMMER_ERROR_ERASE_MEM | Memory erase failure
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT | File format not supported for this kind of device
CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED | Refresh required
CUBEPROGRAMMER_ERROR_NO_SECURITY | Refresh required
CUBEPROGRAMMER_ERROR_CHANGE_FREQ | Changing frequency problem
CUBEPROGRAMMER_ERROR_RDP_ENABLED | RDP Enabled error
CUBEPROGRAMMER_ERROR_OTHER | Other error

◆ cubeProgrammerVerbosityLevel

enum cubeProgrammerVerbosityLevel

List of verbosity levels.

Enumerator
CUBEPROGRAMMER_VER_LEVEL_NONE | no messages ever printed by the library
CUBEPROGRAMMER_VER_LEVEL_ONE | warning, error and success messages are printed (default)
CUBEPROGRAMMER_VER_LEVEL_TWO | error roots informational messages are printed
CUBEPROGRAMMER_VER_LEVEL_DEBUG | debug and informational messages are printed
CUBEPROGRAMMER_NO_PROGRESS_BAR | no progress bar is printed in the output of the library

◆ debugConnectMode

enum debugConnectMode

Choose the appropriate mode for connection.

Enumerator
NORMAL_MODE | Connect with normal mode, the target is reset then halted while the type of reset is selected using the [debugResetMode].
HOTPLUG_MODE | Connect with hotplug mode, this option allows the user to connect to the target without halt or reset.
UNDER_RESET_MODE | Connect with under reset mode, option allows the user to connect to the target using a reset vector catch before executing any instruction.
POWER_DOWN_MODE | Connect with power down mode.
PRE_RESET_MODE | Connect with pre reset mode.
hwRstPulse_MODE | Connect with hwRstPulse mode.

◆ debugPort

enum debugPort

Select the debug port interface for connection.

Enumerator
JTAG | JTAG debug port.
SWD | SWD debug port.

◆ debugResetMode

enum debugResetMode

Choose the way to apply a system reset.

Enumerator
SOFTWARE_RESET | Apply a reset by the software.
HARDWARE_RESET | Apply a reset by the hardware.
CORE_RESET | Apply a reset by the internal core peripheral.

◆ flashSize

enum flashSize
Enumerator
Flash_Size_1KB
Flash_Size_512KB
Flash_Size_256KB

◆ targetInterfaceType

enum targetInterfaceType

Indicates the supported interfaces.

Enumerator
STLINK_INTERFACE | STLINK used as connection interface.
USART_INTERFACE | USART used as connection interface.
USB_INTERFACE | USB DFU used as connection interface.
SPI_INTERFACE | SPI used as connection interface.
I2C_INTERFACE | I2C used as connection interface.
CAN_INTERFACE | CAN used as connection interface.
JLINK_INTERFACE | JLINK used as connection interface.

◆ usartFlowControl

enum usartFlowControl

UART Flow Control is a method for devices to communicate with each other over UART without the risk of losing data.

Enumerator
OFF | No flow control.
HARDWARE | Hardware flow control : RTS/CTS.
SOFTWARE | Software flow control : Transmission is started and stopped by sending special characters.

◆ usartParity

enum usartParity

The parity bit in the data frame of the USART communication tells the receiving device if there is any error in the data bits.

Enumerator
EVEN | Even parity bit.
ODD | Odd parity bit.
NONE | No check parity.

◆ wbFunctionArguments

enum wbFunctionArguments
Enumerator
FIRST_INSTALL_ACTIVE
FIRST_INSTALL_NOT_ACTIVE
START_STACK_ACTIVE
START_STACK_NOT_ACTIVE
VERIFY_FILE_DOWLOAD_FILE
DO_NOT_VERIFY_DOWLOAD_FILE


STM32CubeProgrammer API: files/DeviceDataStructure.h File Reference

  • File List
  • Globals
  • files
Data Structures | Macros | Typedefs
DeviceDataStructure.h File Reference

Go to the source code of this file.

Data Structures

struct | bankSector
This stucture indicates the sectors parameters. More...
struct | deviceBank
This stucture defines the memory sectors for each bank. More...
struct | storageStructure
This stucture describes sotrage characterization. More...
struct | bitCoefficient_C
This stucture indicates the coefficients to access to the adequate option bit. More...
struct | bitValue_C
This stucture describes the option Bit value. More...
struct | bit_C
This stucture will be filled by values which characterize the device's option bytes. More...
struct | category_C
Get option bytes banks categories descriptions. More...
struct | bank_C
Get option bytes banks internal descriptions. More...
struct | peripheral_C
Get peripheral option bytes general informations. More...

Macros

#define | R_ACCESS 0x0
#define | W_ACCESS 0x1
#define | RW_ACCESS 0x2
#define | RWE_ACCESS 0x3

Typedefs

typedef struct bankSector | bankSector
typedef struct deviceBank | deviceBank
typedef struct storageStructure | storageStructure
typedef struct bitCoefficient_C | bitCoefficient_C
typedef struct bitValue_C | bitValue_C
typedef struct bit_C | bit_C
typedef struct category_C | category_C
typedef struct bank_C | bank_C
typedef struct peripheral_C | peripheral_C

Macro Definition Documentation

◆ R_ACCESS

#define R_ACCESS 0x0

◆ RW_ACCESS

#define RW_ACCESS 0x2

◆ RWE_ACCESS

#define RWE_ACCESS 0x3

◆ W_ACCESS

#define W_ACCESS 0x1

Typedef Documentation

◆ bank_C

typedef struct bank_C bank_C

◆ bankSector

typedef struct bankSector bankSector

◆ bit_C

typedef struct bit_C bit_C

◆ bitCoefficient_C

typedef struct bitCoefficient_C bitCoefficient_C

◆ bitValue_C

typedef struct bitValue_C bitValue_C

◆ category_C

typedef struct category_C category_C

◆ deviceBank

typedef struct deviceBank deviceBank

◆ peripheral_C

typedef struct peripheral_C peripheral_C

◆ storageStructure

typedef struct storageStructure storageStructure


STM32CubeProgrammer API: files/DisplayManager.cpp File Reference

  • File List
  • Globals
  • files
DisplayManager.cpp File Reference

Detailed Description

This example of functions allows to personalize the display messages.

  • Implement Init Progress Bar function to add a progress bar.
  • Implement load Bar function to animate the loading process 0% to 100%.
  • Implement DisplayMessage function to ensure the display of internal DLL messages.
  • Implement logMessage function to personalize the display (user messages).

Go to the source code : DisplayManager


STM32CubeProgrammer API: files/Example1.cpp File Reference

  • File List
  • Globals
  • files
Example1.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • Mass erase.
    • Single word edition (-w32).
    • Read 64 bytes from 0x08000000.
    • Sector erase.
    • Read 64 bytes from 0x08000000 .
    • System Reset.

Go to the source code : STLINK_Example1


STM32CubeProgrammer API: files/Example2.cpp File Reference

  • File List
  • Globals
  • files
Example2.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • File programming + verification step.
    • Read 256 bytes from the address 0x08000000.
    • Run application.

Go to the source code : STLINK_Example2


STM32CubeProgrammer API: files/Example3.cpp File Reference

  • File List
  • Globals
  • files
Example3.cpp File Reference

Detailed Description

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each ST-LINK probes and execute the following operations:
    • File programming + verification step.
    • Set RDP level.
    • Display option bytes.
    • Disable readout protection.
    • Display option bytes.
    • System Reset.

Go to the source code : STLINK_Example3


STM32CubeProgrammer API: files/Example_WB.cpp File Reference

  • File List
  • Globals
  • files
Example_WB.cpp File Reference


STM32CubeProgrammer API: files/HSM_Example.cpp File Reference

  • File List
  • Globals
  • files
HSM_Example.cpp File Reference

Detailed Description

This example allows to execute some operations with the STM32 HSM.

  1. Detect plugged-in HSM cards.
  2. Get the HSM Firmware ID, counter, State, type and version
  3. Get the HSM license after device connection

Go to the source code : HSM_Example_Info


STM32CubeProgrammer API: files/I2C_Example.cpp File Reference

  • File List
  • Globals
  • files
I2C_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through I2C Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via I2C interface by indicating the slave address.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : I2C_Bootloader


STM32CubeProgrammer API: files/main.cpp File Reference

  • File List
  • Globals
  • files
main.cpp File Reference

Detailed Description

The examples provided by the documentation are written for documentation to take inspiration for use cases. This code is the main program that allows to choose and execute the preferred example and to execute some operations to the internal STM32 Flash memory.

  • Set the Loader path.
  • Associate display manager functions.
  • Call examples functions.
  • Close all connected ST-LINK probes.

Go to the source code : main


STM32CubeProgrammer API: files/MPU_SSP.cpp File Reference

  • File List
  • Globals
  • files
MPU_SSP.cpp File Reference

Detailed Description

This example allows to connect to a STM32 MPU based device through USB interface and launch the SSP process.

  • Connect to the device via USB interface.
  • Start the SSP programming
  • Disconnect if an error occured.

Go to the source code : USB_Bootloader


STM32CubeProgrammer API: files/SPI_Example.cpp File Reference

  • File List
  • Globals
  • files
SPI_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through SPI Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via SPI interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : SPI_Bootloader


STM32CubeProgrammer API: files/TSV_Flashing.cpp File Reference

  • File List
  • Globals
  • files
TSV_Flashing.cpp File Reference

Detailed Description

This example allows to connect to a STM32 MPU based device through USB interface and start the flashing service.

  • Connect to the device via USB interface.
  • TSV file programming.
  • Disconnect

Go to the source code : USB_Bootloader


STM32CubeProgrammer API: files/UART_Example.cpp File Reference

  • File List
  • Globals
  • files
UART_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through UART Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via UART.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : UART_Bootloader


STM32CubeProgrammer API: files/USB_Example.cpp File Reference

  • File List
  • Globals
  • files
USB_Example.cpp File Reference

Detailed Description

This example allows to connect to the target through USB Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via USB interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : USB_Bootloader


STM32CubeProgrammer API: files/USB_Example_WB.cpp File Reference

  • File List
  • Globals
  • files
USB_Example_WB.cpp File Reference

Detailed Description

This example allows to connect to the target through USB Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via USB interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.

Go to the source code : USB_Bootloader


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • a
  • b
  • c
  • d
  • e
  • f
  • g
  • h
  • i
  • j
  • m
  • n
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w
Here is a list of all functions, variables, defines, enums, and typedefs with links to the files they belong to:

- a -

  • antiRollBack() : CubeProgrammer_API.h
  • authKeyLock() : CubeProgrammer_API.h
  • automaticMode() : CubeProgrammer_API.h

- b -

  • bank_C : DeviceDataStructure.h
  • bankSector : DeviceDataStructure.h
  • bit_C : DeviceDataStructure.h
  • bitCoefficient_C : DeviceDataStructure.h
  • bitValue_C : DeviceDataStructure.h

- c -

  • CAN_INTERFACE : CubeProgrammer_API.h
  • canConnectParameters : CubeProgrammer_API.h
  • category_C : DeviceDataStructure.h
  • checkDeviceConnection() : CubeProgrammer_API.h
  • connectCanBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader2() : CubeProgrammer_API.h
  • connectI2cBootloader() : CubeProgrammer_API.h
  • connectSpiBootloader() : CubeProgrammer_API.h
  • connectStLink() : CubeProgrammer_API.h
  • connectUsartBootloader() : CubeProgrammer_API.h
  • CORE_RESET : CubeProgrammer_API.h
  • CP_EXPORTS : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CHANGE_FREQ : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CONNECTION : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_ERASE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_DEVICE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_FILE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_SECURITY : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_CONNECTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_OTHER : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_RDP_ENABLED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_READ_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRITE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRONG_PARAM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_ERROR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_PROGRESS_BAR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_DEBUG : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_NONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_ONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_TWO : CubeProgrammer_API.h
  • cubeProgrammerError : CubeProgrammer_API.h
  • cubeProgrammerVerbosityLevel : CubeProgrammer_API.h

- d -

  • debugConnectMode : CubeProgrammer_API.h
  • debugConnectParameters : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • deleteInterfaceList() : CubeProgrammer_API.h
  • deleteLoaders() : CubeProgrammer_API.h
  • deviceBank : DeviceDataStructure.h
  • deviceSector : CubeProgrammer_API.h
  • dfuConnectParameters : CubeProgrammer_API.h
  • dfuDeviceInfo : CubeProgrammer_API.h
  • disconnect() : CubeProgrammer_API.h
  • displayCallBacks : CubeProgrammer_API.h
  • DO_NOT_VERIFY_DOWLOAD_FILE : CubeProgrammer_API.h
  • downloadFile() : CubeProgrammer_API.h

- e -

  • editSector() : CubeProgrammer_API.h
  • EVEN : CubeProgrammer_API.h
  • execute() : CubeProgrammer_API.h
  • externalLoader : CubeProgrammer_API.h
  • externalStorageInfo : CubeProgrammer_API.h

- f -

  • fastRomInitOptionBytesInterface() : CubeProgrammer_API.h
  • fileData_C : CubeProgrammer_API.h
  • fileOpen() : CubeProgrammer_API.h
  • firmwareDelete() : CubeProgrammer_API.h
  • firmwareUpgrade() : CubeProgrammer_API.h
  • FIRST_INSTALL_ACTIVE : CubeProgrammer_API.h
  • FIRST_INSTALL_NOT_ACTIVE : CubeProgrammer_API.h
  • Flash_Size_1KB : CubeProgrammer_API.h
  • Flash_Size_256KB : CubeProgrammer_API.h
  • Flash_Size_512KB : CubeProgrammer_API.h
  • flashSize : CubeProgrammer_API.h
  • freeFileData() : CubeProgrammer_API.h
  • freeLibraryMemory() : CubeProgrammer_API.h
  • frequencies : CubeProgrammer_API.h

- g -

  • generalInf : CubeProgrammer_API.h
  • getCancelPointer() : CubeProgrammer_API.h
  • getDeviceGeneralInf() : CubeProgrammer_API.h
  • getDfuDeviceList() : CubeProgrammer_API.h
  • getExternalLoaders() : CubeProgrammer_API.h
  • getHsmCounter() : CubeProgrammer_API.h
  • getHsmFirmwareID() : CubeProgrammer_API.h
  • getHsmLicense() : CubeProgrammer_API.h
  • getHsmState() : CubeProgrammer_API.h
  • getHsmType() : CubeProgrammer_API.h
  • getHsmVersion() : CubeProgrammer_API.h
  • getStLinkEnumerationList() : CubeProgrammer_API.h
  • getStLinkList() : CubeProgrammer_API.h
  • getStorageStructure() : CubeProgrammer_API.h
  • getTargetInterfaceType() : CubeProgrammer_API.h
  • getUID64() : CubeProgrammer_API.h
  • getUsartList() : CubeProgrammer_API.h

- h -

  • HARDWARE : CubeProgrammer_API.h
  • HARDWARE_RESET : CubeProgrammer_API.h
  • HOTPLUG_MODE : CubeProgrammer_API.h
  • hwRstPulse_MODE : CubeProgrammer_API.h

- i -

  • I2C_INTERFACE : CubeProgrammer_API.h
  • i2cConnectParameters : CubeProgrammer_API.h
  • initOptionBytesInterface() : CubeProgrammer_API.h

- j -

  • JLINK_INTERFACE : CubeProgrammer_API.h
  • JTAG : CubeProgrammer_API.h

- m -

  • massErase() : CubeProgrammer_API.h

- n -

  • NONE : CubeProgrammer_API.h
  • NORMAL_MODE : CubeProgrammer_API.h

- o -

  • obDisplay() : CubeProgrammer_API.h
  • ODD : CubeProgrammer_API.h
  • OFF : CubeProgrammer_API.h

- p -

  • peripheral_C : DeviceDataStructure.h
  • POWER_DOWN_MODE : CubeProgrammer_API.h
  • PRE_RESET_MODE : CubeProgrammer_API.h
  • programSsp() : CubeProgrammer_API.h

- r -

  • R_ACCESS : DeviceDataStructure.h
  • readMemory() : CubeProgrammer_API.h
  • readUnprotect() : CubeProgrammer_API.h
  • removeExternalLoader() : CubeProgrammer_API.h
  • reset() : CubeProgrammer_API.h
  • RW_ACCESS : DeviceDataStructure.h
  • RWE_ACCESS : DeviceDataStructure.h

- s -

  • saveFileToFile() : CubeProgrammer_API.h
  • saveMemoryToFile() : CubeProgrammer_API.h
  • sectorErase() : CubeProgrammer_API.h
  • segmentData_C : CubeProgrammer_API.h
  • sendByteUart() : CubeProgrammer_API.h
  • sendOptionBytesCmd() : CubeProgrammer_API.h
  • serialNumberingAutomaticMode() : CubeProgrammer_API.h
  • setDisplayCallbacks() : CubeProgrammer_API.h
  • setExternalLoaderOBL() : CubeProgrammer_API.h
  • setExternalLoaderPath() : CubeProgrammer_API.h
  • setLoadersPath() : CubeProgrammer_API.h
  • setVerbosityLevel() : CubeProgrammer_API.h
  • SOFTWARE : CubeProgrammer_API.h
  • SOFTWARE_RESET : CubeProgrammer_API.h
  • SPI_INTERFACE : CubeProgrammer_API.h
  • spiConnectParameters : CubeProgrammer_API.h
  • START_STACK_ACTIVE : CubeProgrammer_API.h
  • START_STACK_NOT_ACTIVE : CubeProgrammer_API.h
  • startFus() : CubeProgrammer_API.h
  • startWirelessStack() : CubeProgrammer_API.h
  • STLINK_INTERFACE : CubeProgrammer_API.h
  • storageStructure : DeviceDataStructure.h
  • SWD : CubeProgrammer_API.h

- t -

  • targetInterfaceType : CubeProgrammer_API.h
  • tzenRegression() : CubeProgrammer_API.h

- u -

  • UNDER_RESET_MODE : CubeProgrammer_API.h
  • unlockchip() : CubeProgrammer_API.h
  • updateAuthKey() : CubeProgrammer_API.h
  • USART_INTERFACE : CubeProgrammer_API.h
  • usartConnectParameters : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h
  • USB_INTERFACE : CubeProgrammer_API.h

- v -

  • verify() : CubeProgrammer_API.h
  • VERIFY_FILE_DOWLOAD_FILE : CubeProgrammer_API.h

- w -

  • W_ACCESS : DeviceDataStructure.h
  • wbFunctionArguments : CubeProgrammer_API.h
  • writeMemory() : CubeProgrammer_API.h
  • writeUserKey() : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • a
  • c
  • d
  • e
  • f
  • g
  • i
  • m
  • o
  • p
  • r
  • s
  • t
  • u
  • v
  • w

- a -

  • antiRollBack() : CubeProgrammer_API.h
  • authKeyLock() : CubeProgrammer_API.h
  • automaticMode() : CubeProgrammer_API.h

- c -

  • checkDeviceConnection() : CubeProgrammer_API.h
  • connectCanBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader() : CubeProgrammer_API.h
  • connectDfuBootloader2() : CubeProgrammer_API.h
  • connectI2cBootloader() : CubeProgrammer_API.h
  • connectSpiBootloader() : CubeProgrammer_API.h
  • connectStLink() : CubeProgrammer_API.h
  • connectUsartBootloader() : CubeProgrammer_API.h

- d -

  • deleteInterfaceList() : CubeProgrammer_API.h
  • deleteLoaders() : CubeProgrammer_API.h
  • disconnect() : CubeProgrammer_API.h
  • downloadFile() : CubeProgrammer_API.h

- e -

  • editSector() : CubeProgrammer_API.h
  • execute() : CubeProgrammer_API.h

- f -

  • fastRomInitOptionBytesInterface() : CubeProgrammer_API.h
  • fileOpen() : CubeProgrammer_API.h
  • firmwareDelete() : CubeProgrammer_API.h
  • firmwareUpgrade() : CubeProgrammer_API.h
  • freeFileData() : CubeProgrammer_API.h
  • freeLibraryMemory() : CubeProgrammer_API.h

- g -

  • getCancelPointer() : CubeProgrammer_API.h
  • getDeviceGeneralInf() : CubeProgrammer_API.h
  • getDfuDeviceList() : CubeProgrammer_API.h
  • getExternalLoaders() : CubeProgrammer_API.h
  • getHsmCounter() : CubeProgrammer_API.h
  • getHsmFirmwareID() : CubeProgrammer_API.h
  • getHsmLicense() : CubeProgrammer_API.h
  • getHsmState() : CubeProgrammer_API.h
  • getHsmType() : CubeProgrammer_API.h
  • getHsmVersion() : CubeProgrammer_API.h
  • getStLinkEnumerationList() : CubeProgrammer_API.h
  • getStLinkList() : CubeProgrammer_API.h
  • getStorageStructure() : CubeProgrammer_API.h
  • getTargetInterfaceType() : CubeProgrammer_API.h
  • getUID64() : CubeProgrammer_API.h
  • getUsartList() : CubeProgrammer_API.h

- i -

  • initOptionBytesInterface() : CubeProgrammer_API.h

- m -

  • massErase() : CubeProgrammer_API.h

- o -

  • obDisplay() : CubeProgrammer_API.h

- p -

  • programSsp() : CubeProgrammer_API.h

- r -

  • readMemory() : CubeProgrammer_API.h
  • readUnprotect() : CubeProgrammer_API.h
  • removeExternalLoader() : CubeProgrammer_API.h
  • reset() : CubeProgrammer_API.h

- s -

  • saveFileToFile() : CubeProgrammer_API.h
  • saveMemoryToFile() : CubeProgrammer_API.h
  • sectorErase() : CubeProgrammer_API.h
  • sendByteUart() : CubeProgrammer_API.h
  • sendOptionBytesCmd() : CubeProgrammer_API.h
  • serialNumberingAutomaticMode() : CubeProgrammer_API.h
  • setDisplayCallbacks() : CubeProgrammer_API.h
  • setExternalLoaderOBL() : CubeProgrammer_API.h
  • setExternalLoaderPath() : CubeProgrammer_API.h
  • setLoadersPath() : CubeProgrammer_API.h
  • setVerbosityLevel() : CubeProgrammer_API.h
  • startFus() : CubeProgrammer_API.h
  • startWirelessStack() : CubeProgrammer_API.h

- t -

  • tzenRegression() : CubeProgrammer_API.h

- u -

  • unlockchip() : CubeProgrammer_API.h
  • updateAuthKey() : CubeProgrammer_API.h

- v -

  • verify() : CubeProgrammer_API.h

- w -

  • writeMemory() : CubeProgrammer_API.h
  • writeUserKey() : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • bank_C : DeviceDataStructure.h
  • bankSector : DeviceDataStructure.h
  • bit_C : DeviceDataStructure.h
  • bitCoefficient_C : DeviceDataStructure.h
  • bitValue_C : DeviceDataStructure.h
  • canConnectParameters : CubeProgrammer_API.h
  • category_C : DeviceDataStructure.h
  • debugConnectMode : CubeProgrammer_API.h
  • debugConnectParameters : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • deviceBank : DeviceDataStructure.h
  • deviceSector : CubeProgrammer_API.h
  • dfuConnectParameters : CubeProgrammer_API.h
  • dfuDeviceInfo : CubeProgrammer_API.h
  • displayCallBacks : CubeProgrammer_API.h
  • externalLoader : CubeProgrammer_API.h
  • externalStorageInfo : CubeProgrammer_API.h
  • fileData_C : CubeProgrammer_API.h
  • frequencies : CubeProgrammer_API.h
  • generalInf : CubeProgrammer_API.h
  • i2cConnectParameters : CubeProgrammer_API.h
  • peripheral_C : DeviceDataStructure.h
  • segmentData_C : CubeProgrammer_API.h
  • spiConnectParameters : CubeProgrammer_API.h
  • storageStructure : DeviceDataStructure.h
  • targetInterfaceType : CubeProgrammer_API.h
  • usartConnectParameters : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • cubeProgrammerError : CubeProgrammer_API.h
  • cubeProgrammerVerbosityLevel : CubeProgrammer_API.h
  • debugConnectMode : CubeProgrammer_API.h
  • debugPort : CubeProgrammer_API.h
  • debugResetMode : CubeProgrammer_API.h
  • flashSize : CubeProgrammer_API.h
  • targetInterfaceType : CubeProgrammer_API.h
  • usartFlowControl : CubeProgrammer_API.h
  • usartParity : CubeProgrammer_API.h
  • wbFunctionArguments : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • c
  • d
  • e
  • f
  • h
  • i
  • j
  • n
  • o
  • p
  • s
  • u
  • v

- c -

  • CAN_INTERFACE : CubeProgrammer_API.h
  • CORE_RESET : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CHANGE_FREQ : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_CONNECTION : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_ERASE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_DEVICE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_FILE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NO_SECURITY : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_CONNECTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_NOT_SUPPORTED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_OTHER : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_RDP_ENABLED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_READ_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRITE_MEM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_ERROR_WRONG_PARAM : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_ERROR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_NO_PROGRESS_BAR : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_DEBUG : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_NONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_ONE : CubeProgrammer_API.h
  • CUBEPROGRAMMER_VER_LEVEL_TWO : CubeProgrammer_API.h

- d -

  • DO_NOT_VERIFY_DOWLOAD_FILE : CubeProgrammer_API.h

- e -

  • EVEN : CubeProgrammer_API.h

- f -

  • FIRST_INSTALL_ACTIVE : CubeProgrammer_API.h
  • FIRST_INSTALL_NOT_ACTIVE : CubeProgrammer_API.h
  • Flash_Size_1KB : CubeProgrammer_API.h
  • Flash_Size_256KB : CubeProgrammer_API.h
  • Flash_Size_512KB : CubeProgrammer_API.h

- h -

  • HARDWARE : CubeProgrammer_API.h
  • HARDWARE_RESET : CubeProgrammer_API.h
  • HOTPLUG_MODE : CubeProgrammer_API.h
  • hwRstPulse_MODE : CubeProgrammer_API.h

- i -

  • I2C_INTERFACE : CubeProgrammer_API.h

- j -

  • JLINK_INTERFACE : CubeProgrammer_API.h
  • JTAG : CubeProgrammer_API.h

- n -

  • NONE : CubeProgrammer_API.h
  • NORMAL_MODE : CubeProgrammer_API.h

- o -

  • ODD : CubeProgrammer_API.h
  • OFF : CubeProgrammer_API.h

- p -

  • POWER_DOWN_MODE : CubeProgrammer_API.h
  • PRE_RESET_MODE : CubeProgrammer_API.h

- s -

  • SOFTWARE : CubeProgrammer_API.h
  • SOFTWARE_RESET : CubeProgrammer_API.h
  • SPI_INTERFACE : CubeProgrammer_API.h
  • START_STACK_ACTIVE : CubeProgrammer_API.h
  • START_STACK_NOT_ACTIVE : CubeProgrammer_API.h
  • STLINK_INTERFACE : CubeProgrammer_API.h
  • SWD : CubeProgrammer_API.h

- u -

  • UNDER_RESET_MODE : CubeProgrammer_API.h
  • USART_INTERFACE : CubeProgrammer_API.h
  • USB_INTERFACE : CubeProgrammer_API.h

- v -

  • VERIFY_FILE_DOWLOAD_FILE : CubeProgrammer_API.h


STM32CubeProgrammer API: Globals

  • File List
  • Globals
  • All
  • Functions
  • Typedefs
  • Enumerations
  • Enumerator
  • Macros
  • CP_EXPORTS : CubeProgrammer_API.h
  • R_ACCESS : DeviceDataStructure.h
  • RW_ACCESS : DeviceDataStructure.h
  • RWE_ACCESS : DeviceDataStructure.h
  • W_ACCESS : DeviceDataStructure.h


STM32CubeProgrammer API: Examples

Examples
Here is a list of all examples:
  • CAN_Bootloader
  • DisplayManager
  • STLINK_Example1
  • STLINK_Example2
  • STLINK_Example3
  • HSM_Example
  • I2C_Bootloader
  • main
  • MPU_SSP
  • SPI_Bootloader
  • TSV_Flashing
  • UART_Bootloader
  • USB_Bootloader


STM32CubeProgrammer API: CAN_Bootloader

CAN_Bootloader

This example allows to connect to the target through CAN Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via CAN interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <CAN_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int CAN_Example(void) {
    logMessage(Title, "\n+++ CAN Bootloader Example +++\n\n");
    generalInf* genInfo;
    canConnectParameters canParam;
    canParam.br = 125000;
    canParam.mode = 0;
    canParam.ide = 0;
    canParam.rtr = 0;
    canParam.fifo = 0;
    canParam.fm = 0;
    canParam.fs = 1;
    canParam.fe = 1;
    canParam.fbn = 0;
    /* Target connect */
    int canConnectFlag = connectCanBootloader(canParam);
    if (canConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* 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);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = nullptr;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }
    CubeProgrammer_API.h
    connectCanBootloader
    int connectCanBootloader(canConnectParameters canParameters)
    This routine allows to start connection to device through CAN interface.
    readMemory
    int readMemory(unsigned int address, unsigned char **data, unsigned int size)
    This routine allows to receive memory data on the used interface with the configration already initia...
    freeLibraryMemory
    void freeLibraryMemory(void *ptr)
    This routine allows to free a specific memory region, typically used after readMemory().
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    initOptionBytesInterface
    peripheral_C * initOptionBytesInterface()
    This routine allows to get option bytes values of the connected target.
    sendOptionBytesCmd
    int sendOptionBytesCmd(char *command)
    This routine allows program the given Option Byte. The option bytes are configured by the end user de...
    bank_C::categories
    category_C ** categories
    Definition: DeviceDataStructure.h:132
    bank_C::categoriesNbr
    unsigned int categoriesNbr
    Definition: DeviceDataStructure.h:131
    bit_C::access
    unsigned char access
    Definition: DeviceDataStructure.h:100
    bit_C::bitValue
    unsigned int bitValue
    Definition: DeviceDataStructure.h:105
    bit_C::name
    char name[64]
    Definition: DeviceDataStructure.h:95
    canConnectParameters
    Specify the CAN connect parameters.
    Definition: CubeProgrammer_API.h:332
    canConnectParameters::fifo
    int fifo
    Definition: CubeProgrammer_API.h:337
    canConnectParameters::mode
    int mode
    Definition: CubeProgrammer_API.h:334
    canConnectParameters::fe
    int fe
    Definition: CubeProgrammer_API.h:340
    canConnectParameters::fbn
    char fbn
    Definition: CubeProgrammer_API.h:341
    canConnectParameters::ide
    int ide
    Definition: CubeProgrammer_API.h:335
    canConnectParameters::fs
    int fs
    Definition: CubeProgrammer_API.h:339
    canConnectParameters::fm
    int fm
    Definition: CubeProgrammer_API.h:338
    canConnectParameters::br
    int br
    Definition: CubeProgrammer_API.h:333
    canConnectParameters::rtr
    int rtr
    Definition: CubeProgrammer_API.h:336
    category_C::bitsNbr
    unsigned int bitsNbr
    Definition: DeviceDataStructure.h:116
    category_C::bits
    bit_C ** bits
    Definition: DeviceDataStructure.h:117
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510
    peripheral_C
    Get peripheral option bytes general informations.
    Definition: DeviceDataStructure.h:141
    peripheral_C::banks
    bank_C ** banks
    Definition: DeviceDataStructure.h:145
    peripheral_C::banksNbr
    unsigned int banksNbr
    Definition: DeviceDataStructure.h:144


STM32CubeProgrammer API: DisplayManager

DisplayManager

This example of functions allows to personalize the display messages.

  • Implement Init Progress Bar function to add a progress bar.
  • Implement load Bar function to animate the loading process 0% to 100%.
  • Implement DisplayMessage function to ensure the display of internal DLL messages.
  • Implement logMessage function to personalize the display (user messages).
    /
    #define _CRT_SECURE_NO_WARNINGS // will disable warnings to use vsprintf instead vsprintf_s
    #include <stdio.h>
    #include <DisplayManager.h>
    #include <stdarg.h>
    #include <string>
    #include <iostream>
    #ifdef _WIN32
    #include <windows.h>
    HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);;
    CONSOLE_SCREEN_BUFFER_INFO SBInfo, CurSBInfo;
    #endif
    #define WIDH 50
    using namespace std;
    unsigned int verbosityLevel;
    unsigned int Progress = 0;
    void InitPBar()
    {
    #ifdef _WIN32
    if (verbosityLevel == VERBOSITY_LEVEL_1)
    {
    for (int idx = 0; idx < WIDH; idx++)
    {
    console = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(console, LIGHTGREY);
    putc(177, stdout);
    }
    GetConsoleScreenBufferInfo(console, &SBInfo);
    printf(" %d%c", Progress,'%');
    SetConsoleTextAttribute(console, LIGHTCYAN);
    putc('\r', stdout);
    Progress = 0;
    }
    #endif
    }
    void lBar(int currProgress, int total)
    {
    unsigned int alreadyLoaded = 0;
    if (total == 0) return;
    if (currProgress > total)
    currProgress = total;
    /*Calculuate the ratio of complete-to-incomplete.*/
    float ratio = currProgress / (float)total;
    unsigned int counter = (unsigned int)ratio * WIDH;
    if ((counter > alreadyLoaded) && (verbosityLevel == VERBOSITY_LEVEL_1))
    {
    #ifdef _WIN32
    SetConsoleTextAttribute(console, FOREGROUND_GREEN);
    for (DWORD Idx = Progress; Idx < (counter - alreadyLoaded); Idx++)
    {
    putc(219, stdout);
    }
    Progress = counter;
    GetConsoleScreenBufferInfo(console, &CurSBInfo);
    SetConsoleCursorPosition(console, SBInfo.dwCursorPosition);
    printf(" %d%%", (int)(ratio * 100));
    SetConsoleCursorPosition(console, CurSBInfo.dwCursorPosition);
    #else
    printf("\033[00;32m");
    printf("[");
    for (int i = 0; i < counter; i++)
    {
    printf("=");
    }
    for (int i = counter; i < WIDH; i++)
    {
    printf(" ");
    }
    // draw the percentage progress
    printf("] %3d%% \r", (int)(ratio * 100)); /* Move to the first column*/
    printf("\033[39;49m");
    #endif
    }
    alreadyLoaded = counter;
    }
    void DisplayMessage(int msgType, const wchar_t* str)
    {
    #ifdef _WIN32
    switch (msgType)
    {
    default:
    case Normal:
    SetConsoleTextAttribute(console, WHITE);
    break;
    case GreenInfo:
    SetConsoleTextAttribute(console, GREEN);
    break;
    case Info:
    SetConsoleTextAttribute(console, LIGHTGREY);
    break;
    case Title:
    SetConsoleTextAttribute(console, LIGHTCYAN);
    break;
    case Error:
    SetConsoleTextAttribute(console, RED);
    break;
    case Warning:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case ErrorNoPopup:
    SetConsoleTextAttribute(console, RED);
    break;
    case WarningNoPopup:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case Verbosity_1:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_2:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_3:
    SetConsoleTextAttribute(console, CYAN);
    break;
    }
    if ((msgType != Verbosity_1 && msgType != Verbosity_2 && msgType != Verbosity_3) || ((msgType == Verbosity_1 && verbosityLevel >= VERBOSITY_LEVEL_1) || (msgType == Verbosity_2 && verbosityLevel >= VERBOSITY_LEVEL_2) || (msgType == Verbosity_3 && verbosityLevel == VERBOSITY_LEVEL_3))) {
    wprintf(L"%ls\n", str);
    }
    SetConsoleTextAttribute(console, WHITE);
    #else
    if (verbosityLevel == VERBOSITY_LEVEL_1)
    {
    if ((msgType == Verbosity_1 && verbosityLevel >= 1))
    printf("\033[39;36m");
    if ((msgType == Verbosity_2 && verbosityLevel >= 2))
    printf("\033[39;36m");
    if ((msgType == Verbosity_3 && verbosityLevel >= 3))
    printf("\033[39;36m");
    switch (msgType)
    {
    case GreenInfo:
    printf("\033[00;32m");
    break;
    case Info:
    printf("\e[90m");
    break;
    case Normal:
    printf("\033[39;49m");
    break;
    case Warning:
    printf("\033[00;33m");
    break;
    case Error:
    printf("\033[00;31m");
    break;
    case Title:
    printf("\e[36m\033[01m");
    break;
    }
    }
    if ((msgType != Verbosity_1 && msgType != Verbosity_2 && msgType != Verbosity_3) || ((msgType == Verbosity_1 && verbosityLevel >= 1) || (msgType == Verbosity_2 && verbosityLevel >= 2) || (msgType == Verbosity_3 && verbosityLevel == 3)))
    {
    std::wcout << str << std::endl;
    }
    printf("\033[39;49m");
    #endif
    }
    void logMessage(int msgType, const char* str, ...)
    {
    #ifdef _WIN32
    switch (msgType)
    {
    default:
    case Normal:
    SetConsoleTextAttribute(console, WHITE);
    break;
    case GreenInfo:
    SetConsoleTextAttribute(console, GREEN);
    break;
    case Info:
    SetConsoleTextAttribute(console, LIGHTGREY);
    break;
    case Title:
    SetConsoleTextAttribute(console, LIGHTCYAN);
    break;
    case Error:
    SetConsoleTextAttribute(console, RED);
    break;
    case Warning:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case ErrorNoPopup:
    SetConsoleTextAttribute(console, RED);
    break;
    case WarningNoPopup:
    SetConsoleTextAttribute(console, YELLOW);
    break;
    case Verbosity_1:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_2:
    SetConsoleTextAttribute(console, CYAN);
    break;
    case Verbosity_3:
    SetConsoleTextAttribute(console, CYAN);
    break;
    }
    #else
    switch (msgType)
    {
    case GreenInfo:
    printf("\033[00;32m");
    break;
    case Info:
    printf("\e[90m");
    break;
    case Normal:
    printf("\033[39;49m");
    break;
    case Warning:
    printf("\033[00;33m");
    break;
    case Error:
    printf("\033[00;31m");
    break;
    case Title:
    printf("\e[36m\033[01m");
    break;
    }
    #endif
    va_list args;
    va_start(args, str);
    char buffer[256];
    vsprintf(buffer, str, args);
    printf("%s", buffer);
    va_end(args);
    #ifdef _WIN32
    SetConsoleTextAttribute(console, WHITE);
    #else
    printf("\033[39;49m");
    #endif
    }


STM32CubeProgrammer API: STLINK_Example1

STLINK_Example1

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • Mass erase.
    • Single word edition (-w32).
    • Read 64 bytes from 0x08000000.
    • Sector erase.
    • Read 64 bytes from 0x08000000 .
    • System Reset.
      /
      #include <stdio.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example1(void) {
      logMessage(Title, "\n+++ Example 1 +++\n\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\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 = HOTPLUG_MODE;
      debugParameters.shared = 0;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters);
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      disconnect();
      continue;
      }
      else {
      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);
      /* Apply mass Erase */
      int massEraseFlag = massErase();
      if (massEraseFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Single word edition */
      int size = 4;
      int startAddress = 0x08000000;
      char data[8] = { (char)0xAA, (char)0xAA, (char)0xBB, (char)0xBB, (char)0xCC, (char)0xCC, (char)0xDD, (char)0xDD };
      int writeMemoryFlag = writeMemory(startAddress, data, size);
      if (writeMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 64 bytes from 0x08000000 */
      unsigned char* dataStruct = 0;
      size = 64;
      int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      int i = 0, col=0;
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress + i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
      /* Sector Erase */
      unsigned int sectors[4] = { 0, 1, 2, 3 }; // we suppose that we have 4 sectors
      int sectorEraseFlag = sectorErase(sectors, 1); // we will erase just the first sector
      if (sectorEraseFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 64 bytes from 0x08000000 */
      i = 0, col = 0;
      size = 64;
      dataStruct = 0;
      readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress + i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
      /* Read Option bytes from target device memory */
      peripheral_C* ob;
      ob = initOptionBytesInterface();
      if (ob == 0)
      {
      disconnect();
      continue;
      }
      /* Display option bytes */
      for (unsigned int i = 0; i < ob->banksNbr; i++)
      {
      logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
      for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
      {
      logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
      for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
      {
      if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
      logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
      logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
      }
      }
      }
      }
      /* Apply a System Reset */
      int resetFlag = reset(SOFTWARE_RESET);
      if (resetFlag != 0)
      {
      logMessage(Error, "\nUnable to reset MCU!\n");
      disconnect();
      continue;
      }
      else
      logMessage(GreenInfo, "\nSystem Reset is performed\n");
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }
      CubeProgrammer_API.h
      HOTPLUG_MODE
      @ HOTPLUG_MODE
      Definition: CubeProgrammer_API.h:391
      SOFTWARE_RESET
      @ SOFTWARE_RESET
      Definition: CubeProgrammer_API.h:378
      massErase
      int massErase(char *sFlashMemName=nullptr)
      This routine allows to erase the whole Flash memory.
      readMemory
      int readMemory(unsigned int address, unsigned char **data, unsigned int size)
      This routine allows to receive memory data on the used interface with the configration already initia...
      freeLibraryMemory
      void freeLibraryMemory(void *ptr)
      This routine allows to free a specific memory region, typically used after readMemory().
      writeMemory
      int writeMemory(unsigned int address, char *data, unsigned int size)
      This routine allows to write memory data on the user interface with the configration already initiali...
      disconnect
      void disconnect()
      This routine allows to clean up and disconnect the current connected target.
      sectorErase
      int sectorErase(unsigned int sectors[], unsigned int sectorNbr, char *sFlashMemName=nullptr)
      This routine allows to erase specific sectors of the Flash memory.
      getDeviceGeneralInf
      generalInf * getDeviceGeneralInf()
      This routine allows to get general device informations.
      deleteInterfaceList
      void deleteInterfaceList()
      This routine allows to clear the list of each created interface.
      initOptionBytesInterface
      peripheral_C * initOptionBytesInterface()
      This routine allows to get option bytes values of the connected target.
      getStLinkList
      int getStLinkList(debugConnectParameters **stLinkList, int shared)
      This routine allows to get ST-LINK conneted probe(s).
      connectStLink
      int connectStLink(debugConnectParameters debugParameters)
      This routine allows to start connection to device through SWD or JTAG interfaces.
      reset
      int reset(debugResetMode rstMode)
      This routine used to apply a target reset.
      bank_C::categories
      category_C ** categories
      Definition: DeviceDataStructure.h:132
      bank_C::categoriesNbr
      unsigned int categoriesNbr
      Definition: DeviceDataStructure.h:131
      bit_C::access
      unsigned char access
      Definition: DeviceDataStructure.h:100
      bit_C::bitValue
      unsigned int bitValue
      Definition: DeviceDataStructure.h:105
      bit_C::name
      char name[64]
      Definition: DeviceDataStructure.h:95
      category_C::bitsNbr
      unsigned int bitsNbr
      Definition: DeviceDataStructure.h:116
      category_C::bits
      bit_C ** bits
      Definition: DeviceDataStructure.h:117
      debugConnectParameters
      Get device characterization and specify connection parameters through ST-LINK interface.
      Definition: CubeProgrammer_API.h:426
      debugConnectParameters::shared
      int shared
      Definition: CubeProgrammer_API.h:440
      debugConnectParameters::connectionMode
      debugConnectMode connectionMode
      Definition: CubeProgrammer_API.h:434
      generalInf
      Definition: CubeProgrammer_API.h:504
      generalInf::type
      char type[4]
      Definition: CubeProgrammer_API.h:508
      generalInf::cpu
      char cpu[20]
      Definition: CubeProgrammer_API.h:509
      generalInf::name
      char name[100]
      Definition: CubeProgrammer_API.h:510
      peripheral_C
      Get peripheral option bytes general informations.
      Definition: DeviceDataStructure.h:141
      peripheral_C::banks
      bank_C ** banks
      Definition: DeviceDataStructure.h:145
      peripheral_C::banksNbr
      unsigned int banksNbr
      Definition: DeviceDataStructure.h:144


STM32CubeProgrammer API: STLINK_Example2

STLINK_Example2

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • File programming + verification step.
    • Read 256 bytes from the address 0x08000000.
    • Run application.
      /
      #include <Example2.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example2(void) {
      logMessage(Title, "\n+++ Example 2 +++\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\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;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters);
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      disconnect();
      continue;
      }
      else {
      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);
      /* Download File + verification */
      #ifdef _WIN32
      const wchar_t* filePath = L"../test file/data.hex";
      #else
      const wchar_t* filePath = L"../api/test file/data.hex";
      #endif
      unsigned int isVerify = 1; //add verification step
      unsigned int isSkipErase = 0; // no skip erase
      int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
      if (downloadFileFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Reading 256 bytes from 0x08000000 */
      unsigned char* dataStruct = 0;
      int size = 256;
      int startAddress = 0x08000000;
      int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
      if (readMemoryFlag != 0)
      {
      disconnect();
      continue;
      }
      logMessage(Normal, "\nReading 32-bit memory content\n");
      logMessage(Normal, " Size : %d Bytes\n", size);
      logMessage(Normal, " Address: : 0x%08X\n", startAddress);
      int i = 0, col = 0;
      while ((i<size))
      {
      col = 0;
      logMessage(Normal, "\n0x%08X :", startAddress+i);
      while ((col<4) && (i<size))
      {
      logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
      col++;
      i += 4;
      }
      }
      logMessage(Normal, "\n");
      freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
      /* Run application */
      int executeFlag = execute(0x08000000);
      if (executeFlag != 0)
      {
      disconnect();
      continue;
      }
      /* The system will lose the connection with bootloader when it is in running mode */
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }
      CubeProgrammer_API.h
      UNDER_RESET_MODE
      @ UNDER_RESET_MODE
      Definition: CubeProgrammer_API.h:392
      execute
      int execute(unsigned int address)
      This routine allows to run the application.
      readMemory
      int readMemory(unsigned int address, unsigned char **data, unsigned int size)
      This routine allows to receive memory data on the used interface with the configration already initia...
      freeLibraryMemory
      void freeLibraryMemory(void *ptr)
      This routine allows to free a specific memory region, typically used after readMemory().
      downloadFile
      int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
      This routine allows to download data from a file to the memory. File formats that are supported : hex...
      disconnect
      void disconnect()
      This routine allows to clean up and disconnect the current connected target.
      getDeviceGeneralInf
      generalInf * getDeviceGeneralInf()
      This routine allows to get general device informations.
      deleteInterfaceList
      void deleteInterfaceList()
      This routine allows to clear the list of each created interface.
      getStLinkList
      int getStLinkList(debugConnectParameters **stLinkList, int shared)
      This routine allows to get ST-LINK conneted probe(s).
      connectStLink
      int connectStLink(debugConnectParameters debugParameters)
      This routine allows to start connection to device through SWD or JTAG interfaces.
      debugConnectParameters
      Get device characterization and specify connection parameters through ST-LINK interface.
      Definition: CubeProgrammer_API.h:426
      debugConnectParameters::shared
      int shared
      Definition: CubeProgrammer_API.h:440
      debugConnectParameters::connectionMode
      debugConnectMode connectionMode
      Definition: CubeProgrammer_API.h:434
      generalInf
      Definition: CubeProgrammer_API.h:504
      generalInf::type
      char type[4]
      Definition: CubeProgrammer_API.h:508
      generalInf::cpu
      char cpu[20]
      Definition: CubeProgrammer_API.h:509
      generalInf::name
      char name[100]
      Definition: CubeProgrammer_API.h:510


STM32CubeProgrammer API: STLINK_Example3

STLINK_Example3

This example allows to execute some operations to the internal STM32 Flash memory.

  1. Detect connected ST-LINK and display them.
  2. Loop on each St-LINK probes and execute the following operations:
    • File programming + verification step.
    • Set RDP level.
    • Display option bytes.
    • Disable readout protection.
    • Display option bytes.
    • System Reset.
      /
      #include <Example3.h>
      #include <DisplayManager.h>
      #include <CubeProgrammer_API.h>
      int Example3(void) {
      logMessage(Title, "\n+++ Example 3 +++\n");
      debugConnectParameters *stLinkList;
      debugConnectParameters debugParameters;
      generalInf* genInfo;
      int getStlinkListNb = getStLinkList(&stLinkList, 0);
      if (getStlinkListNb == 0)
      {
      logMessage(Error, "No STLINK available\n");
      return 0;
      }
      else {
      logMessage(Title, "\n-------- Connected ST-LINK Probes List --------");
      for (int i = 0; i < getStlinkListNb; i++)
      {
      logMessage(Normal, "\nST-LINK Probe %d :\n", i);
      logMessage(Info, " ST-LINK SN : %s \n", stLinkList[i].serialNumber);
      logMessage(Info, " ST-LINK FW : %s \n", stLinkList[i].firmwareVersion);
      }
      logMessage(Title, "-----------------------------------------------\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;
      /* Target connect */
      int connectStlinkFlag = connectStLink(debugParameters); //try to connect
      if (connectStlinkFlag != 0) {
      logMessage(Error, "Establishing connection with the device failed\n");
      continue;
      }
      else {
      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);
      logMessage(Normal, "\n");
      /* Download file + verification */
      #ifdef _WIN32
      const wchar_t* filePath = L"../test file/data.hex";
      #else
      const wchar_t* filePath = L"../api/test file/data.hex";
      #endif
      unsigned int isVerify = 1; //add verification step
      unsigned int isSkipErase = 0; // no skip erase
      int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
      if (downloadFileFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Set rdp option byte */
      int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob rdp=0xbb");
      if (sendOptionBytesCmdFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Display option bytes */
      peripheral_C* ob;
      ob = initOptionBytesInterface();
      if (ob == 0)
      {
      disconnect();
      continue;
      }
      for (unsigned int i = 0; i < ob->banksNbr; i++)
      {
      logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
      for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
      {
      logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
      for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
      {
      if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
      logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
      logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
      }
      }
      }
      }
      /* Disable readout protection */
      int readUnprotectFlag = readUnprotect();
      if (readUnprotectFlag != 0)
      {
      disconnect();
      continue;
      }
      /* Display option bytes */
      ob = initOptionBytesInterface();
      if (ob == 0)
      {
      disconnect();
      continue;
      }
      for (unsigned int i = 0; i < ob->banksNbr; i++)
      {
      logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
      for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
      {
      logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
      for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
      {
      if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
      logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
      logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
      }
      }
      }
      }
      /* Apply a System Reset */
      int resetFlag = reset(SOFTWARE_RESET);
      if (resetFlag != 0)
      {
      logMessage(Error, "\nUnable to reset MCU!\n");
      disconnect();
      continue;
      }
      else
      logMessage(GreenInfo, "\nSystem Reset is performed\n");
      /* Process successfully Done */
      disconnect();
      }
      deleteInterfaceList();
      return 1;
      }
      CubeProgrammer_API.h
      UNDER_RESET_MODE
      @ UNDER_RESET_MODE
      Definition: CubeProgrammer_API.h:392
      SOFTWARE_RESET
      @ SOFTWARE_RESET
      Definition: CubeProgrammer_API.h:378
      readUnprotect
      int readUnprotect()
      This routine allows to disable the readout protection. If the memory is not protected,...
      downloadFile
      int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
      This routine allows to download data from a file to the memory. File formats that are supported : hex...
      disconnect
      void disconnect()
      This routine allows to clean up and disconnect the current connected target.
      getDeviceGeneralInf
      generalInf * getDeviceGeneralInf()
      This routine allows to get general device informations.
      deleteInterfaceList
      void deleteInterfaceList()
      This routine allows to clear the list of each created interface.
      initOptionBytesInterface
      peripheral_C * initOptionBytesInterface()
      This routine allows to get option bytes values of the connected target.
      sendOptionBytesCmd
      int sendOptionBytesCmd(char *command)
      This routine allows program the given Option Byte. The option bytes are configured by the end user de...
      getStLinkList
      int getStLinkList(debugConnectParameters **stLinkList, int shared)
      This routine allows to get ST-LINK conneted probe(s).
      connectStLink
      int connectStLink(debugConnectParameters debugParameters)
      This routine allows to start connection to device through SWD or JTAG interfaces.
      reset
      int reset(debugResetMode rstMode)
      This routine used to apply a target reset.
      bank_C::categories
      category_C ** categories
      Definition: DeviceDataStructure.h:132
      bank_C::categoriesNbr
      unsigned int categoriesNbr
      Definition: DeviceDataStructure.h:131
      bit_C::access
      unsigned char access
      Definition: DeviceDataStructure.h:100
      bit_C::bitValue
      unsigned int bitValue
      Definition: DeviceDataStructure.h:105
      bit_C::name
      char name[64]
      Definition: DeviceDataStructure.h:95
      category_C::bitsNbr
      unsigned int bitsNbr
      Definition: DeviceDataStructure.h:116
      category_C::bits
      bit_C ** bits
      Definition: DeviceDataStructure.h:117
      debugConnectParameters
      Get device characterization and specify connection parameters through ST-LINK interface.
      Definition: CubeProgrammer_API.h:426
      debugConnectParameters::shared
      int shared
      Definition: CubeProgrammer_API.h:440
      debugConnectParameters::connectionMode
      debugConnectMode connectionMode
      Definition: CubeProgrammer_API.h:434
      generalInf
      Definition: CubeProgrammer_API.h:504
      generalInf::type
      char type[4]
      Definition: CubeProgrammer_API.h:508
      generalInf::cpu
      char cpu[20]
      Definition: CubeProgrammer_API.h:509
      generalInf::name
      char name[100]
      Definition: CubeProgrammer_API.h:510
      peripheral_C
      Get peripheral option bytes general informations.
      Definition: DeviceDataStructure.h:141
      peripheral_C::banks
      bank_C ** banks
      Definition: DeviceDataStructure.h:145
      peripheral_C::banksNbr
      unsigned int banksNbr
      Definition: DeviceDataStructure.h:144


STM32CubeProgrammer API: HSM_Example

HSM_Example

This example allows to execute some operations with the STM32 HSM.

  1. Detect plugged-in HSM cards.
  2. Get the HSM Firmware ID, counter, State, type and version
  3. Get the HSM license after device connection
    /
    #include <stdio.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    #include <iostream>
    constexpr int HSM_SLOT_INDEX = 1; /* HSM SLOT INDEX to select the plugged-in HSM */
    constexpr int STLINK_INDEX = 0; /* STLINK INDEX to select the connected STM32 device */
    int HSM_Example(void) {
    logMessage(Title, "\n+++ HSM Get Information +++\n\n");
    const char* fwIdentifier = getHsmFirmwareID(HSM_SLOT_INDEX);
    if (fwIdentifier == nullptr)
    return -1;
    unsigned long counterValue = getHsmCounter(HSM_SLOT_INDEX);
    const char* hsmState = getHsmState(HSM_SLOT_INDEX);
    if (hsmState == nullptr)
    return -1;
    const char* hsmVersion = getHsmVersion(HSM_SLOT_INDEX);
    if (hsmVersion == nullptr)
    return -1;
    const char* hsmType = getHsmType(HSM_SLOT_INDEX);
    if (hsmType == nullptr)
    return -1;
    logMessage(Title, "\n+++ HSM Generate License +++\n\n");
    /* Connection to target should be established before getting license */
    debugConnectParameters* stLinkList;
    debugConnectParameters debugParameters;
    generalInf* genInfo;
    int getStlinkListNb = getStLinkList(&stLinkList, 0);
    debugParameters = stLinkList[STLINK_INDEX];
    debugParameters.connectionMode = HOTPLUG_MODE;
    debugParameters.shared = 0;
    /* Target connect */
    int connectStlinkFlag = connectStLink(debugParameters);
    if (connectStlinkFlag != CUBEPROGRAMMER_NO_ERROR) {
    logMessage(Error, "Establishing connection with the device failed\n");
    disconnect();
    return -1;
    }
    /* Display device information */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Get HSM license and save the output file in the location ../test file/licenseFile.bin */
    int ret = getHsmLicense(HSM_SLOT_INDEX, L"../test file/licenseFile.bin");
    if (ret != CUBEPROGRAMMER_NO_ERROR)
    return -1;
    return 0;
    }
    CubeProgrammer_API.h
    CUBEPROGRAMMER_NO_ERROR
    @ CUBEPROGRAMMER_NO_ERROR
    Definition: CubeProgrammer_API.h:148
    HOTPLUG_MODE
    @ HOTPLUG_MODE
    Definition: CubeProgrammer_API.h:391
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    getStLinkList
    int getStLinkList(debugConnectParameters **stLinkList, int shared)
    This routine allows to get ST-LINK conneted probe(s).
    connectStLink
    int connectStLink(debugConnectParameters debugParameters)
    This routine allows to start connection to device through SWD or JTAG interfaces.
    getHsmType
    const char * getHsmType(int hsmSlotId)
    getHsmType: this routine aims to get the HSM type.
    getHsmCounter
    unsigned long getHsmCounter(int hsmSlotId)
    getHsmCounter: this routine aims to get the current HSM counter.
    getHsmFirmwareID
    const char * getHsmFirmwareID(int hsmSlotId)
    getHsmFirmwareID: this routine aims to get the HSM Firmware Identifier.
    getHsmVersion
    const char * getHsmVersion(int hsmSlotId)
    getHsmVersion: this routine aims to get the HSM version.
    getHsmState
    const char * getHsmState(int hsmSlotId)
    getHsmState: this routine aims to get the HSM State.
    getHsmLicense
    int getHsmLicense(int hsmSlotId, const wchar_t *outLicensePath)
    getHsmLicense: this routine aims to get and save the HSM license into a binary file.
    debugConnectParameters
    Get device characterization and specify connection parameters through ST-LINK interface.
    Definition: CubeProgrammer_API.h:426
    debugConnectParameters::shared
    int shared
    Definition: CubeProgrammer_API.h:440
    debugConnectParameters::connectionMode
    debugConnectMode connectionMode
    Definition: CubeProgrammer_API.h:434
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510


STM32CubeProgrammer API: I2C_Bootloader

I2C_Bootloader

This example allows to connect to the target through I2C Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via I2C interface by indicating the slave address.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <I2C_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    #define STM32L45xxx 0x4A // I2C Bootloader address for STM32L45xxx device
    #define STM32F42xxx 0x38
    #define STM32F72xxx 0x49
    #define STM32H74xxx 0x4E //...
    int I2C_Example(void) {
    logMessage(Title, "\n+++ I2C Bootloader Example +++\n\n");
    generalInf* genInfo;
    i2cConnectParameters i2cParam;
    i2cParam.add = STM32L45xxx ; //Bootloader address for STM32L452RE, an address must be inserted here, otherwise the connection cannot be established.
    i2cParam.br = 400;
    i2cParam.sm = 1;
    i2cParam.am = 0;
    i2cParam.af = 1;
    i2cParam.df = 0;
    i2cParam.dnf = 0;
    i2cParam.rt = 0;
    i2cParam.ft = 0;
    /* Target connect */
    int i2cConnectFlag = connectI2cBootloader(i2cParam);
    if (i2cConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device information */
    genInfo = getDeviceGeneralInf();
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }
    CubeProgrammer_API.h
    connectI2cBootloader
    int connectI2cBootloader(i2cConnectParameters i2cParameters)
    This routine allows to start connection to device through I2C interface.
    readMemory
    int readMemory(unsigned int address, unsigned char **data, unsigned int size)
    This routine allows to receive memory data on the used interface with the configration already initia...
    freeLibraryMemory
    void freeLibraryMemory(void *ptr)
    This routine allows to free a specific memory region, typically used after readMemory().
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    initOptionBytesInterface
    peripheral_C * initOptionBytesInterface()
    This routine allows to get option bytes values of the connected target.
    sendOptionBytesCmd
    int sendOptionBytesCmd(char *command)
    This routine allows program the given Option Byte. The option bytes are configured by the end user de...
    bank_C::categories
    category_C ** categories
    Definition: DeviceDataStructure.h:132
    bank_C::categoriesNbr
    unsigned int categoriesNbr
    Definition: DeviceDataStructure.h:131
    bit_C::access
    unsigned char access
    Definition: DeviceDataStructure.h:100
    bit_C::bitValue
    unsigned int bitValue
    Definition: DeviceDataStructure.h:105
    bit_C::name
    char name[64]
    Definition: DeviceDataStructure.h:95
    category_C::bitsNbr
    unsigned int bitsNbr
    Definition: DeviceDataStructure.h:116
    category_C::bits
    bit_C ** bits
    Definition: DeviceDataStructure.h:117
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510
    i2cConnectParameters
    Specify the I2C connect parameters.
    Definition: CubeProgrammer_API.h:354
    i2cConnectParameters::af
    int af
    Definition: CubeProgrammer_API.h:359
    i2cConnectParameters::ft
    int ft
    Definition: CubeProgrammer_API.h:363
    i2cConnectParameters::rt
    int rt
    Definition: CubeProgrammer_API.h:362
    i2cConnectParameters::dnf
    char dnf
    Definition: CubeProgrammer_API.h:361
    i2cConnectParameters::sm
    int sm
    Definition: CubeProgrammer_API.h:357
    i2cConnectParameters::df
    int df
    Definition: CubeProgrammer_API.h:360
    i2cConnectParameters::am
    int am
    Definition: CubeProgrammer_API.h:358
    i2cConnectParameters::br
    int br
    Definition: CubeProgrammer_API.h:356
    i2cConnectParameters::add
    int add
    Definition: CubeProgrammer_API.h:355
    peripheral_C
    Get peripheral option bytes general informations.
    Definition: DeviceDataStructure.h:141
    peripheral_C::banks
    bank_C ** banks
    Definition: DeviceDataStructure.h:145
    peripheral_C::banksNbr
    unsigned int banksNbr
    Definition: DeviceDataStructure.h:144


STM32CubeProgrammer API: main

main

The examples provided by the documentation are written for documentation to take inspiration for use cases. This code is the main program that allows to choose and execute the preferred example and to execute some operations to the internal STM32 Flash memory.

  • Set the Loader path.
  • Associate display manager functions.
  • Call examples functions.
  • Close all connected ST-LINK probes.
    /
    #include <iostream>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    #include <Example1.h>
    #include <Example2.h>
    #include <Example3.h>
    #include <Example_WB.h>
    #include <I2C_Example.h>
    #include <CAN_Example.h>
    #include <SPI_Example.h>
    #include <UART_Example.h>
    #include <USB_Example.h>
    #include <USB_Example_WB.h>
    #include <TSV_Flashing.h>
    #include <MPU_SSP.h>
    #include <HSM_Example.h>
    extern unsigned int verbosityLevel;
    int main()
    {
    int ret = 0;
    const char* loaderPath = "./.";
    displayCallBacks vsLogMsg;
    /* Set device loaders path that contains FlashLoader and ExternalLoader folders*/
    setLoadersPath(loaderPath);
    /* Set the progress bar and message display functions callbacks */
    vsLogMsg.logMessage = DisplayMessage;
    vsLogMsg.initProgressBar = InitPBar;
    vsLogMsg.loadBar = lBar;
    setDisplayCallbacks(vsLogMsg);
    /* Set DLL verbosity level */
    setVerbosityLevel(verbosityLevel = VERBOSITY_LEVEL_1);
    ret = Example1();
    //ret = Example2();
    //ret = Example3();
    //ret = Example_WB();
    //ret = I2C_Example();
    //ret = CAN_Example();
    //ret = SPI_Example();
    //ret = UART_Example();
    //ret = USB_Example();
    //ret = USB_Example_WB();
    //ret = TSV_Flashing();
    //ret = MPU_SSP();
    //ret = HSM_Example();
    std::cout << "\n" << "Press enter to continue...";
    std::cin.get() ;
    return ret;
    }
    CubeProgrammer_API.h
    setVerbosityLevel
    void setVerbosityLevel(int level)
    This routine allows to choose the verbosity level for display.
    setDisplayCallbacks
    void setDisplayCallbacks(displayCallBacks c)
    This routine allows to choose your custom display.
    setLoadersPath
    void setLoadersPath(const char *path)
    This routine allows to specify the location of Flash Loader.
    displayCallBacks
    Functions must be implemented to personalize the display of messages.
    Definition: CubeProgrammer_API.h:472
    displayCallBacks::loadBar
    void(* loadBar)(int x, int n)
    Definition: CubeProgrammer_API.h:475
    displayCallBacks::initProgressBar
    void(* initProgressBar)()
    Definition: CubeProgrammer_API.h:473
    displayCallBacks::logMessage
    void(* logMessage)(int msgType, const wchar_t *str)
    Definition: CubeProgrammer_API.h:474


STM32CubeProgrammer API: MPU_SSP

MPU_SSP

This example allows to connect to a STM32 MPU based device through USB interface and launch the SSP process.

  • Connect to the device via USB interface.
  • Start the SSP programming
  • Disconnect if an error occured.
    /
    #include <MPU_SSP.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int MPU_SSP(void) {
    logMessage(Title, "\n+++ MPU SSP +++\n\n");
    generalInf* genInfo;
    dfuDeviceInfo* dfuList;
    int getDfuListNb = getDfuDeviceList(&dfuList, 0xdf11, 0x0483);
    if (getDfuListNb == 0)
    {
    logMessage(Error, "No USB DFU available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- USB DFU List --------------\n");
    for (int i = 0; i < getDfuListNb; i++)
    {
    logMessage(Normal, "USB Port %d \n", i);
    logMessage(Info, " USB index : %s \n", dfuList[i].usbIndex);
    logMessage(Info, " USB SN : %s \n", dfuList[i].serialNumber);
    logMessage(Info, " DFU version : 0x%02X ", dfuList[i].dfuVersion);
    }
    logMessage(Title, "\n-----------------------------------------\n\n");
    }
    /* Target connect, choose the adequate USB port by indicating its index that is already mentioned in USB DFU List above */
    int usbConnectFlag = connectDfuBootloader(dfuList[0].usbIndex);
    if (usbConnectFlag != 0)
    {
    logMessage(Error, "Failed to establish connection !\n");
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device information */
    genInfo = getDeviceGeneralInf();
    if (genInfo == NULL)
    {
    logMessage(Error, "Failed to get device information");
    disconnect();
    deleteInterfaceList();
    return 0;
    }
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* SSP Input binaries */
    const wchar_t* sspFilePath = L""; //Indicate the SSP image path here.
    const wchar_t* tfaSspFilePath = L""; //Indicate the tfa ssp path here.
    /* licenseFile : is Empty since it is not required when using HSM.
    hsmSlotId = 0: try to change the index value in accordance with the OS settings. */
    int sspFlag = programSsp(sspFilePath, L"", tfaSspFilePath, 0);
    if (sspFlag != 0)
    {
    disconnect();
    deleteInterfaceList();
    return 0;
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }
    CubeProgrammer_API.h
    connectDfuBootloader
    int connectDfuBootloader(char *usbIndex)
    This routine allows to start a simple connection through USB DFU interface.
    getDfuDeviceList
    int getDfuDeviceList(dfuDeviceInfo **dfuList, int iPID, int iVID)
    This routine allows to get connected DFU devices.
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    deleteInterfaceList
    void deleteInterfaceList()
    This routine allows to clear the list of each created interface.
    programSsp
    int programSsp(const wchar_t *sspFile, const wchar_t *licenseFile, const wchar_t *tfaFile, int hsmSlotId)
    This routine aims to launch the Secure Secret Provisioning.
    dfuDeviceInfo
    Get DFU device informations .
    Definition: CubeProgrammer_API.h:261
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510


STM32CubeProgrammer API: SPI_Bootloader

SPI_Bootloader

This example allows to connect to the target through SPI Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via SPI interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <SPI_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int SPI_Example(void) {
    logMessage(Title, "\n+++ SPI Bootloader Example +++\n\n");
    generalInf* genInfo;
    spiConnectParameters spiParam;
    spiParam.baudrate = 375;
    spiParam.crcPol = 7;
    spiParam.direction = 0;
    spiParam.cpha = 0;
    spiParam.cpol = 0;
    spiParam.crc = 0;
    spiParam.firstBit = 1;
    spiParam.frameFormat = 0;
    spiParam.dataSize = 1;
    spiParam.mode = 1;
    spiParam.nss = 1;
    spiParam.nssPulse = 1;
    spiParam.delay = 1;
    /* Target connect */
    int spiConnectFlag = connectSpiBootloader(spiParam);
    if (spiConnectFlag != 0) {
    logMessage(Error, "Establishing connection with the device failed");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* 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);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    return 1;
    }
    CubeProgrammer_API.h
    connectSpiBootloader
    int connectSpiBootloader(spiConnectParameters spiParameters)
    This routine allows to start connection to device through SPI interface.
    readMemory
    int readMemory(unsigned int address, unsigned char **data, unsigned int size)
    This routine allows to receive memory data on the used interface with the configration already initia...
    freeLibraryMemory
    void freeLibraryMemory(void *ptr)
    This routine allows to free a specific memory region, typically used after readMemory().
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    initOptionBytesInterface
    peripheral_C * initOptionBytesInterface()
    This routine allows to get option bytes values of the connected target.
    sendOptionBytesCmd
    int sendOptionBytesCmd(char *command)
    This routine allows program the given Option Byte. The option bytes are configured by the end user de...
    bank_C::categories
    category_C ** categories
    Definition: DeviceDataStructure.h:132
    bank_C::categoriesNbr
    unsigned int categoriesNbr
    Definition: DeviceDataStructure.h:131
    bit_C::access
    unsigned char access
    Definition: DeviceDataStructure.h:100
    bit_C::bitValue
    unsigned int bitValue
    Definition: DeviceDataStructure.h:105
    bit_C::name
    char name[64]
    Definition: DeviceDataStructure.h:95
    category_C::bitsNbr
    unsigned int bitsNbr
    Definition: DeviceDataStructure.h:116
    category_C::bits
    bit_C ** bits
    Definition: DeviceDataStructure.h:117
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510
    peripheral_C
    Get peripheral option bytes general informations.
    Definition: DeviceDataStructure.h:141
    peripheral_C::banks
    bank_C ** banks
    Definition: DeviceDataStructure.h:145
    peripheral_C::banksNbr
    unsigned int banksNbr
    Definition: DeviceDataStructure.h:144
    spiConnectParameters
    Specify the SPI connect parameters.
    Definition: CubeProgrammer_API.h:307
    spiConnectParameters::crc
    int crc
    Definition: CubeProgrammer_API.h:313
    spiConnectParameters::frameFormat
    int frameFormat
    Definition: CubeProgrammer_API.h:315
    spiConnectParameters::nss
    int nss
    Definition: CubeProgrammer_API.h:318
    spiConnectParameters::mode
    int mode
    Definition: CubeProgrammer_API.h:317
    spiConnectParameters::cpol
    int cpol
    Definition: CubeProgrammer_API.h:312
    spiConnectParameters::nssPulse
    int nssPulse
    Definition: CubeProgrammer_API.h:319
    spiConnectParameters::delay
    int delay
    Definition: CubeProgrammer_API.h:320
    spiConnectParameters::firstBit
    int firstBit
    Definition: CubeProgrammer_API.h:314
    spiConnectParameters::direction
    int direction
    Definition: CubeProgrammer_API.h:310
    spiConnectParameters::dataSize
    int dataSize
    Definition: CubeProgrammer_API.h:316
    spiConnectParameters::cpha
    int cpha
    Definition: CubeProgrammer_API.h:311
    spiConnectParameters::crcPol
    uint16_t crcPol
    Definition: CubeProgrammer_API.h:309
    spiConnectParameters::baudrate
    uint32_t baudrate
    Definition: CubeProgrammer_API.h:308


STM32CubeProgrammer API: TSV_Flashing

TSV_Flashing

This example allows to connect to a STM32 MPU based device through USB interface and start the flashing service.

  • Connect to the device via USB interface.
  • TSV file programming.
  • Disconnect
    /
    #include <TSV_Flashing.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int TSV_Flashing(void) {
    logMessage(Title, "\n+++ TSV Flashing service [STM32MP15] +++\n\n");
    generalInf* genInfo;
    dfuDeviceInfo* dfuList;
    int getDfuListNb = getDfuDeviceList(&dfuList, 0xdf11, 0x0483);
    if (getDfuListNb == 0)
    {
    logMessage(Error, "No USB DFU available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- USB DFU List --------------\n");
    for (int i = 0; i < getDfuListNb; i++)
    {
    logMessage(Normal, "USB Port %d \n", i);
    logMessage(Info, " USB index : %s \n", dfuList[i].usbIndex);
    logMessage(Info, " USB SN : %s \n", dfuList[i].serialNumber);
    logMessage(Info, " DFU version : 0x%02X ", dfuList[i].dfuVersion);
    }
    logMessage(Title, "\n-----------------------------------------\n\n");
    }
    /* Target connect, choose the adequate USB port by indicating its index that is already mentioned in USB DFU List above */
    int usbConnectFlag = connectDfuBootloader(dfuList[0].usbIndex);
    if (usbConnectFlag != 0)
    {
    logMessage(Error, "Failed to establish connection !\n");
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* Display device information */
    genInfo = getDeviceGeneralInf();
    if (genInfo == NULL)
    {
    logMessage(Error, "Failed to get device information");
    }
    logMessage(Normal, "\nDevice name : %s ", genInfo->name);
    logMessage(Normal, "\nDevice type : %s ", genInfo->type);
    logMessage(Normal, "\nDevice CPU : %s \n", genInfo->cpu);
    /* Download binaries */
    #ifdef _WIN32
    const wchar_t* tsvFilePath = L"../test file/STM32MP/FlashLayout_sdcard_stm32mp157c-dk2-trusted.tsv";
    #else
    const wchar_t* tsvFilePath = L"../api/test file/STM32MP/FlashLayout_sdcard_stm32mp157c-dk2-trusted.tsv";
    #endif
    #ifdef _WIN32
    const wchar_t* binFilePath = L"../test file/STM32MP/";
    #else
    const wchar_t* binFilePath = L"../api/test file/STM32MP/";
    #endif
    unsigned int isVerify = 0;
    unsigned int isSkipErase = 1;
    int downloadFileFlag = downloadFile(tsvFilePath, 0, 0, 0, binFilePath);
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }
    CubeProgrammer_API.h
    connectDfuBootloader
    int connectDfuBootloader(char *usbIndex)
    This routine allows to start a simple connection through USB DFU interface.
    getDfuDeviceList
    int getDfuDeviceList(dfuDeviceInfo **dfuList, int iPID, int iVID)
    This routine allows to get connected DFU devices.
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    deleteInterfaceList
    void deleteInterfaceList()
    This routine allows to clear the list of each created interface.
    dfuDeviceInfo
    Get DFU device informations .
    Definition: CubeProgrammer_API.h:261
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510


STM32CubeProgrammer API: UART_Bootloader

UART_Bootloader

This example allows to connect to the target through UART Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via UART.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <UART_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int UART_Example(void) {
    logMessage(Title, "\n+++ UART Bootloader Example +++\n\n");
    generalInf* genInfo;
    usartConnectParameters *uartParam;
    int getUsartListFlag = getUsartList(&uartParam);
    if (getUsartListFlag == 0)
    {
    logMessage(Error, "NO Serial Port available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- Serial Port List --------------\n");
    for (int i = 0; i < getUsartListFlag; i++)
    {
    logMessage(Normal, "\nPort Name [%d] :", i);
    logMessage(Info, " %s ", uartParam[i].portName);
    }
    logMessage(Title, "\n---------------------------------------------\n\n");
    }
    /* Target connect, choose the adequate Serial port by indicating its index that is already mentioned in Serial Port List above */
    int uartConnectFlag = connectUsartBootloader(uartParam[0]);
    if (uartConnectFlag != 0)
    {
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* 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);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    freeLibraryMemory(dataStruct) ; // free the memory allocated by the function readMemory
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }
    CubeProgrammer_API.h
    connectUsartBootloader
    int connectUsartBootloader(usartConnectParameters usartParameters)
    This routine allows to start connection to device through USART interface.
    getUsartList
    int getUsartList(usartConnectParameters **usartList)
    This routine allows to get connected serial ports.
    readMemory
    int readMemory(unsigned int address, unsigned char **data, unsigned int size)
    This routine allows to receive memory data on the used interface with the configration already initia...
    freeLibraryMemory
    void freeLibraryMemory(void *ptr)
    This routine allows to free a specific memory region, typically used after readMemory().
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    deleteInterfaceList
    void deleteInterfaceList()
    This routine allows to clear the list of each created interface.
    initOptionBytesInterface
    peripheral_C * initOptionBytesInterface()
    This routine allows to get option bytes values of the connected target.
    sendOptionBytesCmd
    int sendOptionBytesCmd(char *command)
    This routine allows program the given Option Byte. The option bytes are configured by the end user de...
    bank_C::categories
    category_C ** categories
    Definition: DeviceDataStructure.h:132
    bank_C::categoriesNbr
    unsigned int categoriesNbr
    Definition: DeviceDataStructure.h:131
    bit_C::access
    unsigned char access
    Definition: DeviceDataStructure.h:100
    bit_C::bitValue
    unsigned int bitValue
    Definition: DeviceDataStructure.h:105
    bit_C::name
    char name[64]
    Definition: DeviceDataStructure.h:95
    category_C::bitsNbr
    unsigned int bitsNbr
    Definition: DeviceDataStructure.h:116
    category_C::bits
    bit_C ** bits
    Definition: DeviceDataStructure.h:117
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510
    peripheral_C
    Get peripheral option bytes general informations.
    Definition: DeviceDataStructure.h:141
    peripheral_C::banks
    bank_C ** banks
    Definition: DeviceDataStructure.h:145
    peripheral_C::banksNbr
    unsigned int banksNbr
    Definition: DeviceDataStructure.h:144
    usartConnectParameters
    Specify the USART connect parameters.
    Definition: CubeProgrammer_API.h:275


STM32CubeProgrammer API: USB_Bootloader

USB_Bootloader

This example allows to connect to the target through USB Bootloader interface and execute some operations to the internal STM32 Flash memory.

  • Connect to the device via USB interface.
  • File programming + verification step.
  • Read 64 bytes from 0x08000000.
  • Option bytes programming : BOR level.
  • Display option bytes.
    /
    #include <USB_Example.h>
    #include <DisplayManager.h>
    #include <CubeProgrammer_API.h>
    int USB_Example(void) {
    logMessage(Title, "\n+++ USB Bootloader Example +++\n\n");
    generalInf* genInfo;
    dfuDeviceInfo *dfuList;
    int getDfuListNb = getDfuDeviceList(&dfuList, 0xdf11, 0x0483);
    if (getDfuListNb == 0)
    {
    logMessage(Error, "No USB DFU available\n");
    return 0;
    }
    else {
    logMessage(Title, "\n------------- USB DFU List --------------\n");
    for (int i = 0; i < getDfuListNb; i++)
    {
    logMessage(Normal, "USB Port %d \n",i);
    logMessage(Info, " USB index : %s \n", dfuList[i].usbIndex);
    logMessage(Info, " USB SN : %s \n", dfuList[i].serialNumber);
    logMessage(Info, " DFU version : 0x%02X ", dfuList[i].dfuVersion);
    }
    logMessage(Title, "\n-----------------------------------------\n\n");
    }
    /* Target connect, choose the adequate USB port by indicating its index that is already mentioned in USB DFU List above */
    int usbConnectFlag = connectDfuBootloader(dfuList[0].usbIndex);
    if (usbConnectFlag != 0)
    {
    disconnect();
    return 0;
    }
    else {
    logMessage(GreenInfo, "\n--- Device Connected --- \n");
    }
    /* 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);
    /* Download File + verification */
    #ifdef _WIN32
    const wchar_t* filePath = L"../test file/data.hex";
    #else
    const wchar_t* filePath = L"../api/test file/data.hex";
    #endif
    unsigned int isVerify = 1; //add verification step
    unsigned int isSkipErase = 0; // no skip erase
    int downloadFileFlag = downloadFile(filePath, 0x08000000, isSkipErase, isVerify, L"");
    if (downloadFileFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Reading 64 bytes from 0x08000000 */
    int size = 64;
    int startAddress = 0x08000000;
    unsigned char* dataStruct = 0;
    int readMemoryFlag = readMemory(startAddress, &dataStruct, size);
    if (readMemoryFlag != 0)
    {
    disconnect();
    return 0;
    }
    logMessage(Normal, "\nReading 32-bit memory content\n");
    logMessage(Normal, " Size : %d Bytes\n", size);
    logMessage(Normal, " Address: : 0x%08X\n", startAddress);
    int i = 0, col = 0;
    while ((i<size))
    {
    col = 0;
    logMessage(Normal, "\n0x%08X :", startAddress + i);
    while ((col<4) && (i<size))
    {
    logMessage(Info, " %08X ", *(unsigned int *)(dataStruct + i));
    col++;
    i += 4;
    }
    }
    logMessage(Normal, "\n");
    /* Option bytes programming : BOR level */
    int sendOptionBytesCmdFlag = sendOptionBytesCmd((char*)"-ob BOR_LEV=1");
    if (sendOptionBytesCmdFlag != 0)
    {
    disconnect();
    return 0;
    }
    /* Get option bytes */
    peripheral_C* ob = initOptionBytesInterface();
    if (ob == 0)
    {
    disconnect();
    return 0;
    }
    /* Display option bytes */
    for (unsigned int i = 0; i < ob->banksNbr; i++)
    {
    logMessage(Normal, "OPTION BYTES BANK: %d\n", i);
    for (unsigned int j = 0; j < ob->banks[i]->categoriesNbr; j++)
    {
    logMessage(Title, "\t%s\n", ob->banks[i]->categories[j]);
    for (unsigned int k = 0; k < ob->banks[i]->categories[j]->bitsNbr; k++)
    {
    if (ob->banks[i]->categories[j]->bits[k]->access == 0 || ob->banks[i]->categories[j]->bits[k]->access == 2) {
    logMessage(Normal, "\t\t%s", ob->banks[i]->categories[j]->bits[k]->name);
    logMessage(Info, ": 0x%x\n", ob->banks[i]->categories[j]->bits[k]->bitValue);
    }
    }
    }
    }
    /* Process successfully Done */
    disconnect();
    deleteInterfaceList();
    return 1;
    }
    CubeProgrammer_API.h
    connectDfuBootloader
    int connectDfuBootloader(char *usbIndex)
    This routine allows to start a simple connection through USB DFU interface.
    getDfuDeviceList
    int getDfuDeviceList(dfuDeviceInfo **dfuList, int iPID, int iVID)
    This routine allows to get connected DFU devices.
    readMemory
    int readMemory(unsigned int address, unsigned char **data, unsigned int size)
    This routine allows to receive memory data on the used interface with the configration already initia...
    downloadFile
    int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
    This routine allows to download data from a file to the memory. File formats that are supported : hex...
    disconnect
    void disconnect()
    This routine allows to clean up and disconnect the current connected target.
    getDeviceGeneralInf
    generalInf * getDeviceGeneralInf()
    This routine allows to get general device informations.
    deleteInterfaceList
    void deleteInterfaceList()
    This routine allows to clear the list of each created interface.
    initOptionBytesInterface
    peripheral_C * initOptionBytesInterface()
    This routine allows to get option bytes values of the connected target.
    sendOptionBytesCmd
    int sendOptionBytesCmd(char *command)
    This routine allows program the given Option Byte. The option bytes are configured by the end user de...
    bank_C::categories
    category_C ** categories
    Definition: DeviceDataStructure.h:132
    bank_C::categoriesNbr
    unsigned int categoriesNbr
    Definition: DeviceDataStructure.h:131
    bit_C::access
    unsigned char access
    Definition: DeviceDataStructure.h:100
    bit_C::bitValue
    unsigned int bitValue
    Definition: DeviceDataStructure.h:105
    bit_C::name
    char name[64]
    Definition: DeviceDataStructure.h:95
    category_C::bitsNbr
    unsigned int bitsNbr
    Definition: DeviceDataStructure.h:116
    category_C::bits
    bit_C ** bits
    Definition: DeviceDataStructure.h:117
    dfuDeviceInfo
    Get DFU device informations .
    Definition: CubeProgrammer_API.h:261
    generalInf
    Definition: CubeProgrammer_API.h:504
    generalInf::type
    char type[4]
    Definition: CubeProgrammer_API.h:508
    generalInf::cpu
    char cpu[20]
    Definition: CubeProgrammer_API.h:509
    generalInf::name
    char name[100]
    Definition: CubeProgrammer_API.h:510
    peripheral_C
    Get peripheral option bytes general informations.
    Definition: DeviceDataStructure.h:141
    peripheral_C::banks
    bank_C ** banks
    Definition: DeviceDataStructure.h:145
    peripheral_C::banksNbr
    unsigned int banksNbr
    Definition: DeviceDataStructure.h:144


STM32CubeProgrammer API: files/CubeProgrammer_API.h Source File

  • File List
  • Globals
  • files
CubeProgrammer_API.h
Go to the documentation of this file.
1
2/*******************************************************************************
3 *
4 * Copyright (C) 2021 STMicroelectronics - All rights reserved
5 *
6 * This file is part of STM32CubeProgrammer project.
7 *
8 * Unauthorized copying of this file, via any medium is strictly prohibited
9 * Proprietary and confidential
10 *
11 ******************************************************************************/
12/* doxygen documentation */
99#ifndef CUBEPROGRAMMER_API_H
100#define CUBEPROGRAMMER_API_H
101
102#ifdef __cplusplus
103extern "C" {
104#endif
105
106#include <stdint.h>
107#include "DeviceDataStructure.h"
108
109#if (defined WIN32 || defined _WIN32 || defined WINCE)
110# define CP_EXPORTS __declspec(dllexport)
111#else
112# define CP_EXPORTS
113#endif
114
115
116/* -------------------------------------------------------------------------------------------- */
117/* Errors Enumerations */
118/* -------------------------------------------------------------------------------------------- */
119
124enum cubeProgrammerVerbosityLevel {
126 CUBEPROGRAMMER_VER_LEVEL_NONE = 0,
127
129 CUBEPROGRAMMER_VER_LEVEL_ONE = 1,
130
132 CUBEPROGRAMMER_VER_LEVEL_TWO = 2,
133
135 CUBEPROGRAMMER_VER_LEVEL_DEBUG = 3,
136
138 CUBEPROGRAMMER_NO_PROGRESS_BAR = 4, /* progress bars are printed only with verbosity level one */
139};
140
141
146enum cubeProgrammerError {
148 CUBEPROGRAMMER_NO_ERROR = 0,
149
151 CUBEPROGRAMMER_ERROR_NOT_CONNECTED = -1,
152
154 CUBEPROGRAMMER_ERROR_NO_DEVICE = -2,
155
157 CUBEPROGRAMMER_ERROR_CONNECTION = -3,
158
160 CUBEPROGRAMMER_ERROR_NO_FILE = -4,
161
163 CUBEPROGRAMMER_ERROR_NOT_SUPPORTED = -5,
164
166 CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED = -6,
167
169 CUBEPROGRAMMER_ERROR_NO_MEM = -7,
170
172 CUBEPROGRAMMER_ERROR_WRONG_PARAM = -8,
173
175 CUBEPROGRAMMER_ERROR_READ_MEM = -9,
176
178 CUBEPROGRAMMER_ERROR_WRITE_MEM = -10,
179
181 CUBEPROGRAMMER_ERROR_ERASE_MEM = -11,
182
184 CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT = -12,
185
187 CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED = -13,
188
190 CUBEPROGRAMMER_ERROR_NO_SECURITY = -14,
191
193 CUBEPROGRAMMER_ERROR_CHANGE_FREQ = -15,
194
196 CUBEPROGRAMMER_ERROR_RDP_ENABLED = -16,
197
198 /* NB: Remember to update CUBEPROGRAMMER_ERROR_COUNT below. */
199
201 CUBEPROGRAMMER_ERROR_OTHER = -99,
202};
203
204/* -------------------------------------------------------------------------------------------- */
205/* Flash Size Structures and Enumerations */
206/* -------------------------------------------------------------------------------------------- */
207
208enum flashSize {
209 Flash_Size_1KB = (1024),
210 Flash_Size_512KB = (512*1024),
211 Flash_Size_256KB = (256*1024),
212
213};
214
215/* -------------------------------------------------------------------------------------------- */
216/* STM32WB Structures and Enumerations */
217/* -------------------------------------------------------------------------------------------- */
218
219enum wbFunctionArguments {
220 FIRST_INSTALL_ACTIVE = 1,
221 FIRST_INSTALL_NOT_ACTIVE = 0,
222 START_STACK_ACTIVE=1,
223 START_STACK_NOT_ACTIVE=1,
224 VERIFY_FILE_DOWLOAD_FILE=1,
225 DO_NOT_VERIFY_DOWLOAD_FILE=0,
226};
227
228/* -------------------------------------------------------------------------------------------- */
229/* Bootloader Data Structures and Enumerations */
230/* -------------------------------------------------------------------------------------------- */
231
236typedef enum usartParity
237{
238 EVEN = 0,
239 ODD = 1,
240 NONE = 2,
241}usartParity;
242
243
248typedef enum usartFlowControl
249{
250 OFF = 0,
251 HARDWARE = 1,
252 SOFTWARE = 2,
253}usartFlowControl;
254
255
260typedef struct dfuDeviceInfo
261{
262 char usbIndex[10];
263 int busNumber;
264 int addressNumber;
265 char productId[100];
266 char serialNumber[100];
267 unsigned int dfuVersion;
268}dfuDeviceInfo;
269
274typedef struct usartConnectParameters
275{
276 char portName[100];
277 unsigned int baudrate;
278 usartParity parity;
279 unsigned char dataBits;
280 float stopBits;
281 usartFlowControl flowControl;
282 int statusRTS;
283 int statusDTR;
284 unsigned char noinitBits;
285 char rdu;
286 char tzenreg;
287}usartConnectParameters;
288
293typedef struct dfuConnectParameters
294{
295 char *usb_index;
296 char rdu;
297 char tzenreg;
298}dfuConnectParameters;
299
300
306typedef struct spiConnectParameters
307{
308 uint32_t baudrate ;
309 uint16_t crcPol ;
310 int direction ;
311 int cpha ;
312 int cpol ;
313 int crc ;
314 int firstBit ;
315 int frameFormat ;
316 int dataSize ;
317 int mode ;
318 int nss ;
319 int nssPulse ;
320 int delay ;
322} spiConnectParameters;
323
324
331typedef struct canConnectParameters
332{
333 int br ;
334 int mode ;
335 int ide ;
336 int rtr ;
337 int fifo ;
338 int fm ;
339 int fs ;
340 int fe ;
341 char fbn ;
343} canConnectParameters;
344
345
353typedef struct i2cConnectParameters
354{
355 int add ;
356 int br ;
357 int sm ;
358 int am ;
359 int af ;
360 int df ;
361 char dnf ;
362 int rt ;
363 int ft ;
365} i2cConnectParameters;
366
367
368/* -------------------------------------------------------------------------------------------- */
369/* STLINK Data Structures and Enumerations */
370/* -------------------------------------------------------------------------------------------- */
371
376typedef enum debugResetMode
377{
378 SOFTWARE_RESET,
379 HARDWARE_RESET,
380 CORE_RESET
381}debugResetMode;
382
383
388typedef enum debugConnectMode
389{
390 NORMAL_MODE,
391 HOTPLUG_MODE,
392 UNDER_RESET_MODE,
393 POWER_DOWN_MODE,
394 PRE_RESET_MODE,
395 hwRstPulse_MODE,
396}debugConnectMode;
401typedef enum debugPort
402{
403 JTAG = 0,
404 SWD = 1,
405}debugPort;
406
407
412typedef struct frequencies
413{
414 unsigned int jtagFreq[12];
415 unsigned int jtagFreqNumber;
416 unsigned int swdFreq[12];
417 unsigned int swdFreqNumber;
418}frequencies;
419
420
425typedef struct debugConnectParameters
426{
427 debugPort dbgPort;
428 int index;
429 char serialNumber[33];
430 char firmwareVersion[20];
431 char targetVoltage[5];
432 int accessPortNumber;
433 int accessPort;
434 debugConnectMode connectionMode;
435 debugResetMode resetMode;
436 int isOldFirmware;
437 frequencies freq;
438 int frequency;
439 int isBridge;
440 int shared;
441 char board[100];
442 int DBG_Sleep ;
443 int speed ;
444}debugConnectParameters;
445
446
447/* -------------------------------------------------------------------------------------------- */
448/* General Data Structures and Enumerations */
449/* -------------------------------------------------------------------------------------------- */
450
455typedef enum targetInterfaceType
456{
457 STLINK_INTERFACE = 0,
458 USART_INTERFACE = 1,
459 USB_INTERFACE = 2,
460 SPI_INTERFACE = 3,
461 I2C_INTERFACE = 4,
462 CAN_INTERFACE = 5,
463 JLINK_INTERFACE = 6
464}targetInterfaceType;
465
466
471typedef struct displayCallBacks
472{
473 void (*initProgressBar)();
474 void (*logMessage)(int msgType, const wchar_t* str);
475 void (*loadBar)(int x, int n);
476} displayCallBacks;
477
478
479typedef struct segmentData_C
480{
481 int address;
482 int size;
483 unsigned char* data;
484}segmentData_C ;
485
486
491typedef struct fileData_C
492{
493 int Type;
494 int segmentsNbr;
495 segmentData_C* segments;
496}fileData_C ;
497
498
503typedef struct generalInf
504{
505 unsigned short deviceId;
506 int flashSize;
507 int bootloaderVersion;
508 char type[4];
509 char cpu[20];
510 char name[100];
511 char series[100];
512 char description[150];
513 char revisionId[8];
514 char board[100];
515}generalInf ;
516
517
518/* -------------------------------------------------------------------------------------------- */
519/* Loaders Data Structures */
520/* -------------------------------------------------------------------------------------------- */
521
522
527typedef struct deviceSector
528{
529 uint32_t sectorNum;
530 uint32_t sectorSize;
531}deviceSector;
532
533
538typedef struct externalLoader{
539 char filePath[200];
540 char deviceName[100];
541 int deviceType;
542 uint32_t deviceStartAddress;
543 uint32_t deviceSize;
544 uint32_t pageSize;
545 // unsigned char EraseValue; /**< Content of Erased Memory. */
546 uint32_t sectorsTypeNbr;
547 deviceSector* sectors;
548}externalLoader;
549
550
555typedef struct externalStorageInfo
556{
557 unsigned int externalLoaderNbr;
558 externalLoader* externalLoader;
559}externalStorageInfo;
560
561
562/* -------------------------------------------------------------------------------------------- */
563/* STLINK functions */
564/* -------------------------------------------------------------------------------------------- */
565
579int getStLinkList(debugConnectParameters** stLinkList, int shared);
580
589int getStLinkEnumerationList(debugConnectParameters** stlink_list, int shared);
590
597int connectStLink(debugConnectParameters debugParameters);
598
599
606int reset(debugResetMode rstMode) ;
607
611/* -------------------------------------------------------------------------------------------- */
612/* Bootloader functions */
613/* -------------------------------------------------------------------------------------------- */
614
626int getUsartList(usartConnectParameters** usartList);
627
628
634int connectUsartBootloader(usartConnectParameters usartParameters);
635
636
642int sendByteUart(int byte);
643
644
653int getDfuDeviceList(dfuDeviceInfo** dfuList,int iPID, int iVID);
654
655
661int connectDfuBootloader(char* usbIndex);
662
669int connectDfuBootloader2(dfuConnectParameters dfuParameters);
670
676int connectSpiBootloader(spiConnectParameters spiParameters);
677
678
685int connectCanBootloader(canConnectParameters canParameters);
686
687
693int connectI2cBootloader(i2cConnectParameters i2cParameters);
694
698/* -------------------------------------------------------------------------------------------- */
699/* General purposes functions */
700/* -------------------------------------------------------------------------------------------- */
701
712void setDisplayCallbacks(displayCallBacks c);
713
714
719void setVerbosityLevel(int level);
720
721
726int checkDeviceConnection();
727
728
733 generalInf* getDeviceGeneralInf();
734
735
744int readMemory(unsigned int address, unsigned char** data, unsigned int size);
745
746
755int writeMemory(unsigned int address, char* data, unsigned int size);
756
757
767int editSector(unsigned int address, char* data, unsigned int size);
768
769
780int downloadFile(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t* binPath);
781
782
789int execute(unsigned int address);
790
791
797int massErase(char* sFlashMemName = nullptr);
798
799
807int sectorErase(unsigned int sectors[],unsigned int sectorNbr, char* sFlashMemName = nullptr);
808
809
810
818int readUnprotect();
819
820
821
822
828int tzenRegression();
829
830
835int getTargetInterfaceType();
836
837
842volatile int* getCancelPointer();
843
844
850void *fileOpen(const wchar_t* filePath);
851
852
857void freeFileData(fileData_C* data);
858
864void freeLibraryMemory(void* ptr);
865
872int verify(fileData_C* fileData, unsigned int address);
873
874
881int saveFileToFile(fileData_C *fileData, const wchar_t* sFileName);
882
883
892int saveMemoryToFile(int address, int size, const wchar_t* sFileName);
893
894
899void disconnect();
900
901
906void deleteInterfaceList();
907
908
920void automaticMode(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char* obCommand, int run);
921
937void serialNumberingAutomaticMode(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char* obCommand, int run, int enableSerialNumbering, int serialAddress, int serialSize, char* serialInitialData);
938
944int getStorageStructure(storageStructure** deviceStorageStruct);
945
949/* -------------------------------------------------------------------------------------------- */
950/* Option Bytes functions */
951/* -------------------------------------------------------------------------------------------- */
952
969int sendOptionBytesCmd(char* command);
970
971
976 peripheral_C* initOptionBytesInterface();
977
978
979 peripheral_C* fastRomInitOptionBytesInterface(uint16_t deviceId);
980
981
986int obDisplay();
987
991/* -------------------------------------------------------------------------------------------- */
992/* Loaders functions */
993/* -------------------------------------------------------------------------------------------- */
994
995
1006void setLoadersPath(const char* path);
1007
1008
1014void setExternalLoaderPath(const char* path, externalLoader** externalLoaderInfo);
1015
1021void setExternalLoaderOBL(const char* path, externalLoader** externalLoaderInfo);
1022
1023
1031int getExternalLoaders(const char* path, externalStorageInfo** externalStorageNfo);
1032
1033
1034
1039void removeExternalLoader(const char* path);
1043void deleteLoaders();
1044
1047/* -------------------------------------------------------------------------------------------- */
1048/* STM32WB specific functions */
1049/* -------------------------------------------------------------------------------------------- */
1050
1062int getUID64(unsigned char** data);
1063
1064
1069int firmwareDelete();
1070
1080int firmwareUpgrade(const wchar_t* filePath, unsigned int address, unsigned int firstInstall, unsigned int startStack, unsigned int verify);
1081
1082
1087int startWirelessStack();
1088
1089
1096int updateAuthKey(const wchar_t* filePath);
1097
1098
1103int authKeyLock();
1104
1105
1112int writeUserKey(const wchar_t* filePath, unsigned char keyType);
1113
1114
1119int antiRollBack();
1120
1121
1127int startFus();
1128
1132int unlockchip();
1133
1137/* -------------------------------------------------------------------------------------------- */
1138/* STM32MP specific functions */
1139/* -------------------------------------------------------------------------------------------- */
1140
1155int programSsp(const wchar_t* sspFile, const wchar_t* licenseFile, const wchar_t* tfaFile, int hsmSlotId) ;
1156
1160/* -------------------------------------------------------------------------------------------- */
1161/* STM32 HSM specific functions */
1162/* -------------------------------------------------------------------------------------------- */
1163
1174const char* getHsmFirmwareID(int hsmSlotId);
1175
1181unsigned long getHsmCounter(int hsmSlotId);
1182
1188const char* getHsmState(int hsmSlotId);
1189
1195const char* getHsmVersion(int hsmSlotId);
1196
1202const char* getHsmType(int hsmSlotId);
1203
1211int getHsmLicense(int hsmSlotId, const wchar_t* outLicensePath);
1212
1215#ifdef __cplusplus
1216}
1217#endif
1218
1219
1220
1221#endif // CUBEPROGRAMMER_API_H
cubeProgrammerError
cubeProgrammerError
List of errors that can be occured.
Definition: CubeProgrammer_API.h:146
CUBEPROGRAMMER_ERROR_NOT_SUPPORTED
@ CUBEPROGRAMMER_ERROR_NOT_SUPPORTED
Definition: CubeProgrammer_API.h:163
CUBEPROGRAMMER_ERROR_NO_MEM
@ CUBEPROGRAMMER_ERROR_NO_MEM
Definition: CubeProgrammer_API.h:169
CUBEPROGRAMMER_NO_ERROR
@ CUBEPROGRAMMER_NO_ERROR
Definition: CubeProgrammer_API.h:148
CUBEPROGRAMMER_ERROR_WRITE_MEM
@ CUBEPROGRAMMER_ERROR_WRITE_MEM
Definition: CubeProgrammer_API.h:178
CUBEPROGRAMMER_ERROR_OTHER
@ CUBEPROGRAMMER_ERROR_OTHER
Definition: CubeProgrammer_API.h:201
CUBEPROGRAMMER_ERROR_CHANGE_FREQ
@ CUBEPROGRAMMER_ERROR_CHANGE_FREQ
Definition: CubeProgrammer_API.h:193
CUBEPROGRAMMER_ERROR_ERASE_MEM
@ CUBEPROGRAMMER_ERROR_ERASE_MEM
Definition: CubeProgrammer_API.h:181
CUBEPROGRAMMER_ERROR_CONNECTION
@ CUBEPROGRAMMER_ERROR_CONNECTION
Definition: CubeProgrammer_API.h:157
CUBEPROGRAMMER_ERROR_NO_FILE
@ CUBEPROGRAMMER_ERROR_NO_FILE
Definition: CubeProgrammer_API.h:160
CUBEPROGRAMMER_ERROR_RDP_ENABLED
@ CUBEPROGRAMMER_ERROR_RDP_ENABLED
Definition: CubeProgrammer_API.h:196
CUBEPROGRAMMER_ERROR_WRONG_PARAM
@ CUBEPROGRAMMER_ERROR_WRONG_PARAM
Definition: CubeProgrammer_API.h:172
CUBEPROGRAMMER_ERROR_NOT_CONNECTED
@ CUBEPROGRAMMER_ERROR_NOT_CONNECTED
Definition: CubeProgrammer_API.h:151
CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT
@ CUBEPROGRAMMER_ERROR_UNSUPPORTED_FILE_FORMAT
Definition: CubeProgrammer_API.h:184
CUBEPROGRAMMER_ERROR_NO_DEVICE
@ CUBEPROGRAMMER_ERROR_NO_DEVICE
Definition: CubeProgrammer_API.h:154
CUBEPROGRAMMER_ERROR_READ_MEM
@ CUBEPROGRAMMER_ERROR_READ_MEM
Definition: CubeProgrammer_API.h:175
CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED
@ CUBEPROGRAMMER_ERROR_REFRESH_REQUIRED
Definition: CubeProgrammer_API.h:187
CUBEPROGRAMMER_ERROR_NO_SECURITY
@ CUBEPROGRAMMER_ERROR_NO_SECURITY
Definition: CubeProgrammer_API.h:190
CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED
@ CUBEPROGRAMMER_ERROR_INTERFACE_NOT_SUPPORTED
Definition: CubeProgrammer_API.h:166
targetInterfaceType
targetInterfaceType
Indicates the supported interfaces.
Definition: CubeProgrammer_API.h:456
JLINK_INTERFACE
@ JLINK_INTERFACE
Definition: CubeProgrammer_API.h:463
I2C_INTERFACE
@ I2C_INTERFACE
Definition: CubeProgrammer_API.h:461
SPI_INTERFACE
@ SPI_INTERFACE
Definition: CubeProgrammer_API.h:460
CAN_INTERFACE
@ CAN_INTERFACE
Definition: CubeProgrammer_API.h:462
USART_INTERFACE
@ USART_INTERFACE
Definition: CubeProgrammer_API.h:458
STLINK_INTERFACE
@ STLINK_INTERFACE
Definition: CubeProgrammer_API.h:457
USB_INTERFACE
@ USB_INTERFACE
Definition: CubeProgrammer_API.h:459
usartParity
usartParity
The parity bit in the data frame of the USART communication tells the receiving device if there is an...
Definition: CubeProgrammer_API.h:237
EVEN
@ EVEN
Definition: CubeProgrammer_API.h:238
ODD
@ ODD
Definition: CubeProgrammer_API.h:239
NONE
@ NONE
Definition: CubeProgrammer_API.h:240
wbFunctionArguments
wbFunctionArguments
Definition: CubeProgrammer_API.h:219
DO_NOT_VERIFY_DOWLOAD_FILE
@ DO_NOT_VERIFY_DOWLOAD_FILE
Definition: CubeProgrammer_API.h:225
START_STACK_ACTIVE
@ START_STACK_ACTIVE
Definition: CubeProgrammer_API.h:222
START_STACK_NOT_ACTIVE
@ START_STACK_NOT_ACTIVE
Definition: CubeProgrammer_API.h:223
FIRST_INSTALL_NOT_ACTIVE
@ FIRST_INSTALL_NOT_ACTIVE
Definition: CubeProgrammer_API.h:221
VERIFY_FILE_DOWLOAD_FILE
@ VERIFY_FILE_DOWLOAD_FILE
Definition: CubeProgrammer_API.h:224
FIRST_INSTALL_ACTIVE
@ FIRST_INSTALL_ACTIVE
Definition: CubeProgrammer_API.h:220
debugConnectMode
debugConnectMode
Choose the appropriate mode for connection.
Definition: CubeProgrammer_API.h:389
UNDER_RESET_MODE
@ UNDER_RESET_MODE
Definition: CubeProgrammer_API.h:392
PRE_RESET_MODE
@ PRE_RESET_MODE
Definition: CubeProgrammer_API.h:394
HOTPLUG_MODE
@ HOTPLUG_MODE
Definition: CubeProgrammer_API.h:391
POWER_DOWN_MODE
@ POWER_DOWN_MODE
Definition: CubeProgrammer_API.h:393
NORMAL_MODE
@ NORMAL_MODE
Definition: CubeProgrammer_API.h:390
hwRstPulse_MODE
@ hwRstPulse_MODE
Definition: CubeProgrammer_API.h:395
debugPort
debugPort
Select the debug port interface for connection.
Definition: CubeProgrammer_API.h:402
SWD
@ SWD
Definition: CubeProgrammer_API.h:404
JTAG
@ JTAG
Definition: CubeProgrammer_API.h:403
usartFlowControl
usartFlowControl
UART Flow Control is a method for devices to communicate with each other over UART without the risk o...
Definition: CubeProgrammer_API.h:249
SOFTWARE
@ SOFTWARE
Definition: CubeProgrammer_API.h:252
OFF
@ OFF
Definition: CubeProgrammer_API.h:250
HARDWARE
@ HARDWARE
Definition: CubeProgrammer_API.h:251
cubeProgrammerVerbosityLevel
cubeProgrammerVerbosityLevel
List of verbosity levels.
Definition: CubeProgrammer_API.h:124
CUBEPROGRAMMER_VER_LEVEL_DEBUG
@ CUBEPROGRAMMER_VER_LEVEL_DEBUG
Definition: CubeProgrammer_API.h:135
CUBEPROGRAMMER_VER_LEVEL_TWO
@ CUBEPROGRAMMER_VER_LEVEL_TWO
Definition: CubeProgrammer_API.h:132
CUBEPROGRAMMER_VER_LEVEL_NONE
@ CUBEPROGRAMMER_VER_LEVEL_NONE
Definition: CubeProgrammer_API.h:126
CUBEPROGRAMMER_VER_LEVEL_ONE
@ CUBEPROGRAMMER_VER_LEVEL_ONE
Definition: CubeProgrammer_API.h:129
CUBEPROGRAMMER_NO_PROGRESS_BAR
@ CUBEPROGRAMMER_NO_PROGRESS_BAR
Definition: CubeProgrammer_API.h:138
flashSize
flashSize
Definition: CubeProgrammer_API.h:208
Flash_Size_512KB
@ Flash_Size_512KB
Definition: CubeProgrammer_API.h:210
Flash_Size_256KB
@ Flash_Size_256KB
Definition: CubeProgrammer_API.h:211
Flash_Size_1KB
@ Flash_Size_1KB
Definition: CubeProgrammer_API.h:209
debugResetMode
debugResetMode
Choose the way to apply a system reset.
Definition: CubeProgrammer_API.h:377
CORE_RESET
@ CORE_RESET
Definition: CubeProgrammer_API.h:380
HARDWARE_RESET
@ HARDWARE_RESET
Definition: CubeProgrammer_API.h:379
SOFTWARE_RESET
@ SOFTWARE_RESET
Definition: CubeProgrammer_API.h:378
DeviceDataStructure.h
sendByteUart
int sendByteUart(int byte)
This routine allows to send a single byte through the USART interface.
connectUsartBootloader
int connectUsartBootloader(usartConnectParameters usartParameters)
This routine allows to start connection to device through USART interface.
connectDfuBootloader
int connectDfuBootloader(char *usbIndex)
This routine allows to start a simple connection through USB DFU interface.
connectSpiBootloader
int connectSpiBootloader(spiConnectParameters spiParameters)
This routine allows to start connection to device through SPI interface.
getDfuDeviceList
int getDfuDeviceList(dfuDeviceInfo **dfuList, int iPID, int iVID)
This routine allows to get connected DFU devices.
connectDfuBootloader2
int connectDfuBootloader2(dfuConnectParameters dfuParameters)
This routine allows to start connection to device through USB DFU interface.
connectCanBootloader
int connectCanBootloader(canConnectParameters canParameters)
This routine allows to start connection to device through CAN interface.
getUsartList
int getUsartList(usartConnectParameters **usartList)
This routine allows to get connected serial ports.
connectI2cBootloader
int connectI2cBootloader(i2cConnectParameters i2cParameters)
This routine allows to start connection to device through I2C interface.
execute
int execute(unsigned int address)
This routine allows to run the application.
fileOpen
void * fileOpen(const wchar_t *filePath)
This routine allows to open and get data from any supported file extension.
setVerbosityLevel
void setVerbosityLevel(int level)
This routine allows to choose the verbosity level for display.
getCancelPointer
volatile int * getCancelPointer()
This routine allows to drop the current read/write operation.
massErase
int massErase(char *sFlashMemName=nullptr)
This routine allows to erase the whole Flash memory.
setDisplayCallbacks
void setDisplayCallbacks(displayCallBacks c)
This routine allows to choose your custom display.
checkDeviceConnection
int checkDeviceConnection()
This routine allows to check connection status [maintained or lost].
readUnprotect
int readUnprotect()
This routine allows to disable the readout protection. If the memory is not protected,...
readMemory
int readMemory(unsigned int address, unsigned char **data, unsigned int size)
This routine allows to receive memory data on the used interface with the configration already initia...
freeLibraryMemory
void freeLibraryMemory(void *ptr)
This routine allows to free a specific memory region, typically used after readMemory().
writeMemory
int writeMemory(unsigned int address, char *data, unsigned int size)
This routine allows to write memory data on the user interface with the configration already initiali...
automaticMode
void automaticMode(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run)
This routine allows to enter and make an automatic process for memory management through JTAG/SWD,...
verify
int verify(fileData_C *fileData, unsigned int address)
This routine allows to verfiy if the indicated file data is identical to Flash memory content.
downloadFile
int downloadFile(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t *binPath)
This routine allows to download data from a file to the memory. File formats that are supported : hex...
saveMemoryToFile
int saveMemoryToFile(int address, int size, const wchar_t *sFileName)
This routine allows to save Flash memory content to file.
disconnect
void disconnect()
This routine allows to clean up and disconnect the current connected target.
editSector
int editSector(unsigned int address, char *data, unsigned int size)
This routine allows to write sector data on the user interface with the configration already initiali...
getTargetInterfaceType
int getTargetInterfaceType()
This routine allows to know the interface what is in use.
freeFileData
void freeFileData(fileData_C *data)
This routine allows to clean up the handled file data.
getStorageStructure
int getStorageStructure(storageStructure **deviceStorageStruct)
This routine allows to get Flash storage information.
saveFileToFile
int saveFileToFile(fileData_C *fileData, const wchar_t *sFileName)
This routine allows to save the data file content to another file.
sectorErase
int sectorErase(unsigned int sectors[], unsigned int sectorNbr, char *sFlashMemName=nullptr)
This routine allows to erase specific sectors of the Flash memory.
tzenRegression
int tzenRegression()
This routine allows the TZEN Option Byte regression.
getDeviceGeneralInf
generalInf * getDeviceGeneralInf()
This routine allows to get general device informations.
serialNumberingAutomaticMode
void serialNumberingAutomaticMode(const wchar_t *filePath, unsigned int address, unsigned int skipErase, unsigned int verify, int isMassErase, char *obCommand, int run, int enableSerialNumbering, int serialAddress, int serialSize, char *serialInitialData)
This routine allows to enter and make an automatic process for memory management with serial numberin...
deleteInterfaceList
void deleteInterfaceList()
This routine allows to clear the list of each created interface.
getExternalLoaders
int getExternalLoaders(const char *path, externalStorageInfo **externalStorageNfo)
This routine allows to get available external Loaders in the mentioned path.
setExternalLoaderPath
void setExternalLoaderPath(const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded.
setLoadersPath
void setLoadersPath(const char *path)
This routine allows to specify the location of Flash Loader.
deleteLoaders
void deleteLoaders()
This routine allows to delete all target Flash Loaders.
removeExternalLoader
void removeExternalLoader(const char *path)
This routine allows to unload an external Loaders.
setExternalLoaderOBL
void setExternalLoaderOBL(const char *path, externalLoader **externalLoaderInfo)
This routine allows to specify the path of the external Loaders to be loaded via OBL interfaces.
obDisplay
int obDisplay()
This routine allows to display the Option bytes.
initOptionBytesInterface
peripheral_C * initOptionBytesInterface()
This routine allows to get option bytes values of the connected target.
sendOptionBytesCmd
int sendOptionBytesCmd(char *command)
This routine allows program the given Option Byte. The option bytes are configured by the end user de...
fastRomInitOptionBytesInterface
peripheral_C * fastRomInitOptionBytesInterface(uint16_t deviceId)
getStLinkList
int getStLinkList(debugConnectParameters **stLinkList, int shared)
This routine allows to get ST-LINK conneted probe(s).
connectStLink
int connectStLink(debugConnectParameters debugParameters)
This routine allows to start connection to device through SWD or JTAG interfaces.
reset
int reset(debugResetMode rstMode)
This routine used to apply a target reset.
getStLinkEnumerationList
int getStLinkEnumerationList(debugConnectParameters **stlink_list, int shared)
This routine allows to get ST-LINK conneted probe(s) without connecting and intruse the target.
getHsmType
const char * getHsmType(int hsmSlotId)
getHsmType: this routine aims to get the HSM type.
getHsmCounter
unsigned long getHsmCounter(int hsmSlotId)
getHsmCounter: this routine aims to get the current HSM counter.
getHsmFirmwareID
const char * getHsmFirmwareID(int hsmSlotId)
getHsmFirmwareID: this routine aims to get the HSM Firmware Identifier.
getHsmVersion
const char * getHsmVersion(int hsmSlotId)
getHsmVersion: this routine aims to get the HSM version.
getHsmState
const char * getHsmState(int hsmSlotId)
getHsmState: this routine aims to get the HSM State.
getHsmLicense
int getHsmLicense(int hsmSlotId, const wchar_t *outLicensePath)
getHsmLicense: this routine aims to get and save the HSM license into a binary file.
programSsp
int programSsp(const wchar_t *sspFile, const wchar_t *licenseFile, const wchar_t *tfaFile, int hsmSlotId)
This routine aims to launch the Secure Secret Provisioning.
getUID64
int getUID64(unsigned char **data)
This routine allows to read the device unique identifier.
antiRollBack
int antiRollBack()
This routine allows to activate the AntiRollBack.
startFus
int startFus()
This routine allows to start and establish a communication with the FUS operator.
unlockchip
int unlockchip()
This routine allows to set default option Bytes.
writeUserKey
int writeUserKey(const wchar_t *filePath, unsigned char keyType)
This routine allows to write a customized user key.
firmwareUpgrade
int firmwareUpgrade(const wchar_t *filePath, unsigned int address, unsigned int firstInstall, unsigned int startStack, unsigned int verify)
This routine allows to make upgrade of BLE stack firmware or FUS firmware.
startWirelessStack
int startWirelessStack()
This routine allows to start the programmed Stack.
firmwareDelete
int firmwareDelete()
This routine allows to erase the BLE stack firmware.
updateAuthKey
int updateAuthKey(const wchar_t *filePath)
This routine allows to start the programmed Stack.
authKeyLock
int authKeyLock()
This routine allows to lock the authentication key and once locked, it is no longer possible to chang...
canConnectParameters
Specify the CAN connect parameters.
Definition: CubeProgrammer_API.h:332
canConnectParameters::fifo
int fifo
Definition: CubeProgrammer_API.h:337
canConnectParameters::mode
int mode
Definition: CubeProgrammer_API.h:334
canConnectParameters::fe
int fe
Definition: CubeProgrammer_API.h:340
canConnectParameters::fbn
char fbn
Definition: CubeProgrammer_API.h:341
canConnectParameters::ide
int ide
Definition: CubeProgrammer_API.h:335
canConnectParameters::fs
int fs
Definition: CubeProgrammer_API.h:339
canConnectParameters::fm
int fm
Definition: CubeProgrammer_API.h:338
canConnectParameters::br
int br
Definition: CubeProgrammer_API.h:333
canConnectParameters::rtr
int rtr
Definition: CubeProgrammer_API.h:336
debugConnectParameters
Get device characterization and specify connection parameters through ST-LINK interface.
Definition: CubeProgrammer_API.h:426
debugConnectParameters::frequency
int frequency
Definition: CubeProgrammer_API.h:438
debugConnectParameters::firmwareVersion
char firmwareVersion[20]
Definition: CubeProgrammer_API.h:430
debugConnectParameters::shared
int shared
Definition: CubeProgrammer_API.h:440
debugConnectParameters::isBridge
int isBridge
Definition: CubeProgrammer_API.h:439
debugConnectParameters::serialNumber
char serialNumber[33]
Definition: CubeProgrammer_API.h:429
debugConnectParameters::speed
int speed
Definition: CubeProgrammer_API.h:443
debugConnectParameters::freq
frequencies freq
Definition: CubeProgrammer_API.h:437
debugConnectParameters::isOldFirmware
int isOldFirmware
Definition: CubeProgrammer_API.h:436
debugConnectParameters::index
int index
Definition: CubeProgrammer_API.h:428
debugConnectParameters::connectionMode
debugConnectMode connectionMode
Definition: CubeProgrammer_API.h:434
debugConnectParameters::DBG_Sleep
int DBG_Sleep
Definition: CubeProgrammer_API.h:442
debugConnectParameters::board
char board[100]
Definition: CubeProgrammer_API.h:441
debugConnectParameters::dbgPort
debugPort dbgPort
Definition: CubeProgrammer_API.h:427
debugConnectParameters::accessPort
int accessPort
Definition: CubeProgrammer_API.h:433
debugConnectParameters::accessPortNumber
int accessPortNumber
Definition: CubeProgrammer_API.h:432
debugConnectParameters::resetMode
debugResetMode resetMode
Definition: CubeProgrammer_API.h:435
debugConnectParameters::targetVoltage
char targetVoltage[5]
Definition: CubeProgrammer_API.h:431
deviceSector
Get device sectors basic informations.
Definition: CubeProgrammer_API.h:528
deviceSector::sectorSize
uint32_t sectorSize
Definition: CubeProgrammer_API.h:530
deviceSector::sectorNum
uint32_t sectorNum
Definition: CubeProgrammer_API.h:529
dfuConnectParameters
Specify the USB DFU connect parameters.
Definition: CubeProgrammer_API.h:294
dfuConnectParameters::tzenreg
char tzenreg
Definition: CubeProgrammer_API.h:297
dfuConnectParameters::rdu
char rdu
Definition: CubeProgrammer_API.h:296
dfuConnectParameters::usb_index
char * usb_index
Definition: CubeProgrammer_API.h:295
dfuDeviceInfo
Get DFU device informations .
Definition: CubeProgrammer_API.h:261
dfuDeviceInfo::serialNumber
char serialNumber[100]
Definition: CubeProgrammer_API.h:266
dfuDeviceInfo::productId
char productId[100]
Definition: CubeProgrammer_API.h:265
dfuDeviceInfo::addressNumber
int addressNumber
Definition: CubeProgrammer_API.h:264
dfuDeviceInfo::busNumber
int busNumber
Definition: CubeProgrammer_API.h:263
dfuDeviceInfo::usbIndex
char usbIndex[10]
Definition: CubeProgrammer_API.h:262
dfuDeviceInfo::dfuVersion
unsigned int dfuVersion
Definition: CubeProgrammer_API.h:267
displayCallBacks
Functions must be implemented to personalize the display of messages.
Definition: CubeProgrammer_API.h:472
displayCallBacks::loadBar
void(* loadBar)(int x, int n)
Definition: CubeProgrammer_API.h:475
displayCallBacks::initProgressBar
void(* initProgressBar)()
Definition: CubeProgrammer_API.h:473
displayCallBacks::logMessage
void(* logMessage)(int msgType, const wchar_t *str)
Definition: CubeProgrammer_API.h:474
externalLoader
Get external Loader parameters to launch the process of programming an external flash memory.
Definition: CubeProgrammer_API.h:538
externalLoader::pageSize
uint32_t pageSize
Definition: CubeProgrammer_API.h:544
externalLoader::deviceName
char deviceName[100]
Definition: CubeProgrammer_API.h:540
externalLoader::deviceSize
uint32_t deviceSize
Definition: CubeProgrammer_API.h:543
externalLoader::filePath
char filePath[200]
Definition: CubeProgrammer_API.h:539
externalLoader::deviceType
int deviceType
Definition: CubeProgrammer_API.h:541
externalLoader::sectorsTypeNbr
uint32_t sectorsTypeNbr
Definition: CubeProgrammer_API.h:546
externalLoader::deviceStartAddress
uint32_t deviceStartAddress
Definition: CubeProgrammer_API.h:542
externalLoader::sectors
deviceSector * sectors
Definition: CubeProgrammer_API.h:547
externalStorageInfo
Get external storage informations useful for external Loader.
Definition: CubeProgrammer_API.h:556
externalStorageInfo::externalLoaderNbr
unsigned int externalLoaderNbr
Definition: CubeProgrammer_API.h:557
externalStorageInfo::externalLoader
externalLoader * externalLoader
Definition: CubeProgrammer_API.h:558
fileData_C
Definition: CubeProgrammer_API.h:492
fileData_C::segments
segmentData_C * segments
Definition: CubeProgrammer_API.h:495
fileData_C::segmentsNbr
int segmentsNbr
Definition: CubeProgrammer_API.h:494
fileData_C::Type
int Type
Definition: CubeProgrammer_API.h:493
frequencies
Get supported frequencies for JTAG and SWD ineterfaces.
Definition: CubeProgrammer_API.h:413
frequencies::swdFreq
unsigned int swdFreq[12]
Definition: CubeProgrammer_API.h:416
frequencies::swdFreqNumber
unsigned int swdFreqNumber
Definition: CubeProgrammer_API.h:417
frequencies::jtagFreq
unsigned int jtagFreq[12]
Definition: CubeProgrammer_API.h:414
frequencies::jtagFreqNumber
unsigned int jtagFreqNumber
Definition: CubeProgrammer_API.h:415
generalInf
Definition: CubeProgrammer_API.h:504
generalInf::bootloaderVersion
int bootloaderVersion
Definition: CubeProgrammer_API.h:507
generalInf::series
char series[100]
Definition: CubeProgrammer_API.h:511
generalInf::type
char type[4]
Definition: CubeProgrammer_API.h:508
generalInf::description
char description[150]
Definition: CubeProgrammer_API.h:512
generalInf::revisionId
char revisionId[8]
Definition: CubeProgrammer_API.h:513
generalInf::flashSize
int flashSize
Definition: CubeProgrammer_API.h:506
generalInf::cpu
char cpu[20]
Definition: CubeProgrammer_API.h:509
generalInf::board
char board[100]
Definition: CubeProgrammer_API.h:514
generalInf::deviceId
unsigned short deviceId
Definition: CubeProgrammer_API.h:505
generalInf::name
char name[100]
Definition: CubeProgrammer_API.h:510
i2cConnectParameters
Specify the I2C connect parameters.
Definition: CubeProgrammer_API.h:354
i2cConnectParameters::af
int af
Definition: CubeProgrammer_API.h:359
i2cConnectParameters::ft
int ft
Definition: CubeProgrammer_API.h:363
i2cConnectParameters::rt
int rt
Definition: CubeProgrammer_API.h:362
i2cConnectParameters::dnf
char dnf
Definition: CubeProgrammer_API.h:361
i2cConnectParameters::sm
int sm
Definition: CubeProgrammer_API.h:357
i2cConnectParameters::df
int df
Definition: CubeProgrammer_API.h:360
i2cConnectParameters::am
int am
Definition: CubeProgrammer_API.h:358
i2cConnectParameters::br
int br
Definition: CubeProgrammer_API.h:356
i2cConnectParameters::add
int add
Definition: CubeProgrammer_API.h:355
peripheral_C
Get peripheral option bytes general informations.
Definition: DeviceDataStructure.h:141
segmentData_C
Definition: CubeProgrammer_API.h:480
segmentData_C::size
int size
Definition: CubeProgrammer_API.h:482
segmentData_C::address
int address
Definition: CubeProgrammer_API.h:481
segmentData_C::data
unsigned char * data
Definition: CubeProgrammer_API.h:483
spiConnectParameters
Specify the SPI connect parameters.
Definition: CubeProgrammer_API.h:307
spiConnectParameters::crc
int crc
Definition: CubeProgrammer_API.h:313
spiConnectParameters::frameFormat
int frameFormat
Definition: CubeProgrammer_API.h:315
spiConnectParameters::nss
int nss
Definition: CubeProgrammer_API.h:318
spiConnectParameters::mode
int mode
Definition: CubeProgrammer_API.h:317
spiConnectParameters::cpol
int cpol
Definition: CubeProgrammer_API.h:312
spiConnectParameters::nssPulse
int nssPulse
Definition: CubeProgrammer_API.h:319
spiConnectParameters::delay
int delay
Definition: CubeProgrammer_API.h:320
spiConnectParameters::firstBit
int firstBit
Definition: CubeProgrammer_API.h:314
spiConnectParameters::direction
int direction
Definition: CubeProgrammer_API.h:310
spiConnectParameters::dataSize
int dataSize
Definition: CubeProgrammer_API.h:316
spiConnectParameters::cpha
int cpha
Definition: CubeProgrammer_API.h:311
spiConnectParameters::crcPol
uint16_t crcPol
Definition: CubeProgrammer_API.h:309
spiConnectParameters::baudrate
uint32_t baudrate
Definition: CubeProgrammer_API.h:308
storageStructure
This stucture describes sotrage characterization.
Definition: DeviceDataStructure.h:58
usartConnectParameters
Specify the USART connect parameters.
Definition: CubeProgrammer_API.h:275
usartConnectParameters::stopBits
float stopBits
Definition: CubeProgrammer_API.h:280
usartConnectParameters::dataBits
unsigned char dataBits
Definition: CubeProgrammer_API.h:279
usartConnectParameters::tzenreg
char tzenreg
Definition: CubeProgrammer_API.h:286
usartConnectParameters::flowControl
usartFlowControl flowControl
Definition: CubeProgrammer_API.h:281
usartConnectParameters::parity
usartParity parity
Definition: CubeProgrammer_API.h:278
usartConnectParameters::baudrate
unsigned int baudrate
Definition: CubeProgrammer_API.h:277
usartConnectParameters::rdu
char rdu
Definition: CubeProgrammer_API.h:285
usartConnectParameters::statusDTR
int statusDTR
Definition: CubeProgrammer_API.h:283
usartConnectParameters::noinitBits
unsigned char noinitBits
Definition: CubeProgrammer_API.h:284
usartConnectParameters::statusRTS
int statusRTS
Definition: CubeProgrammer_API.h:282
usartConnectParameters::portName
char portName[100]
Definition: CubeProgrammer_API.h:276


STM32CubeProgrammer API: files/DeviceDataStructure.h Source File

  • File List
  • Globals
  • files
DeviceDataStructure.h
Go to the documentation of this file.
1
2/*******************************************************************************
3 *
4 * Copyright (C) 2021 STMicroelectronics - All rights reserved
5 *
6 * This file is part of STM32CubeProgrammer project.
7 *
8 * Unauthorized copying of this file, via any medium is strictly prohibited
9 * Proprietary and confidential
10 *
11 ******************************************************************************/
12#ifndef DEVICEDATASTRUCTURE
13#define DEVICEDATASTRUCTURE
14
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20#define R_ACCESS 0x0
21#define W_ACCESS 0x1
22#define RW_ACCESS 0x2
23#define RWE_ACCESS 0x3
24
25
26/* -------------------------------------------------------------------------------------------- */
27/* OB Data Structures */
28/* -------------------------------------------------------------------------------------------- */
29
34typedef struct bankSector
35{
36 unsigned int index ;
37 unsigned int size ;
38 unsigned int address ;
39}bankSector;
40
41
46typedef struct deviceBank
47{
48 unsigned int sectorsNumber;
49 bankSector* sectors;
50}deviceBank;
51
52
57typedef struct storageStructure
58{
59 unsigned int banksNumber;
60 deviceBank* banks;
61}storageStructure;
62
63
64
65
70typedef struct bitCoefficient_C
71{
72 unsigned int multiplier;
73 unsigned int offset;
74}bitCoefficient_C;
75
76
81typedef struct bitValue_C
82{
83 unsigned int value;
84 char description[1000];
85}bitValue_C;
86
87
93typedef struct bit_C
94{
95 char name[64];
96 char description[1000];
97 unsigned int wordOffset;
98 unsigned int bitOffset;
99 unsigned int bitWidth;
100 unsigned char access;
101 unsigned int valuesNbr;
102 bitValue_C** values;
103 bitCoefficient_C equation;
104 unsigned char* reference;
105 unsigned int bitValue;
106}bit_C;
107
108
113typedef struct category_C
114{
115 char name[100];
116 unsigned int bitsNbr;
117 bit_C** bits;
118}category_C;
119
120
126typedef struct bank_C
127{
128 unsigned int size;
129 unsigned int address;
130 unsigned char access;
131 unsigned int categoriesNbr;
132 category_C** categories;
133}bank_C;
134
135
140typedef struct peripheral_C
141{
142 char name[64];
143 char description[1000];
144 unsigned int banksNbr;
145 bank_C** banks;
146}peripheral_C;
147
148
149
150#ifdef __cplusplus
151}
152#endif
153
154
155#endif // DEVICEDATASTRUCTURE
156
bank_C
Get option bytes banks internal descriptions.
Definition: DeviceDataStructure.h:127
bank_C::access
unsigned char access
Definition: DeviceDataStructure.h:130
bank_C::address
unsigned int address
Definition: DeviceDataStructure.h:129
bank_C::categories
category_C ** categories
Definition: DeviceDataStructure.h:132
bank_C::categoriesNbr
unsigned int categoriesNbr
Definition: DeviceDataStructure.h:131
bank_C::size
unsigned int size
Definition: DeviceDataStructure.h:128
bankSector
This stucture indicates the sectors parameters.
Definition: DeviceDataStructure.h:35
bankSector::address
unsigned int address
Definition: DeviceDataStructure.h:38
bankSector::index
unsigned int index
Definition: DeviceDataStructure.h:36
bankSector::size
unsigned int size
Definition: DeviceDataStructure.h:37
bit_C
This stucture will be filled by values which characterize the device's option bytes.
Definition: DeviceDataStructure.h:94
bit_C::wordOffset
unsigned int wordOffset
Definition: DeviceDataStructure.h:97
bit_C::access
unsigned char access
Definition: DeviceDataStructure.h:100
bit_C::values
bitValue_C ** values
Definition: DeviceDataStructure.h:102
bit_C::equation
bitCoefficient_C equation
Definition: DeviceDataStructure.h:103
bit_C::bitWidth
unsigned int bitWidth
Definition: DeviceDataStructure.h:99
bit_C::bitValue
unsigned int bitValue
Definition: DeviceDataStructure.h:105
bit_C::bitOffset
unsigned int bitOffset
Definition: DeviceDataStructure.h:98
bit_C::reference
unsigned char * reference
Definition: DeviceDataStructure.h:104
bit_C::description
char description[1000]
Definition: DeviceDataStructure.h:96
bit_C::name
char name[64]
Definition: DeviceDataStructure.h:95
bit_C::valuesNbr
unsigned int valuesNbr
Definition: DeviceDataStructure.h:101
bitCoefficient_C
This stucture indicates the coefficients to access to the adequate option bit.
Definition: DeviceDataStructure.h:71
bitCoefficient_C::multiplier
unsigned int multiplier
Definition: DeviceDataStructure.h:72
bitCoefficient_C::offset
unsigned int offset
Definition: DeviceDataStructure.h:73
bitValue_C
This stucture describes the option Bit value.
Definition: DeviceDataStructure.h:82
bitValue_C::value
unsigned int value
Definition: DeviceDataStructure.h:83
bitValue_C::description
char description[1000]
Definition: DeviceDataStructure.h:84
category_C
Get option bytes banks categories descriptions.
Definition: DeviceDataStructure.h:114
category_C::bitsNbr
unsigned int bitsNbr
Definition: DeviceDataStructure.h:116
category_C::name
char name[100]
Definition: DeviceDataStructure.h:115
category_C::bits
bit_C ** bits
Definition: DeviceDataStructure.h:117
deviceBank
This stucture defines the memory sectors for each bank.
Definition: DeviceDataStructure.h:47
deviceBank::sectors
bankSector * sectors
Definition: DeviceDataStructure.h:49
deviceBank::sectorsNumber
unsigned int sectorsNumber
Definition: DeviceDataStructure.h:48
peripheral_C
Get peripheral option bytes general informations.
Definition: DeviceDataStructure.h:141
peripheral_C::banks
bank_C ** banks
Definition: DeviceDataStructure.h:145
peripheral_C::banksNbr
unsigned int banksNbr
Definition: DeviceDataStructure.h:144
peripheral_C::description
char description[1000]
Definition: DeviceDataStructure.h:143
peripheral_C::name
char name[64]
Definition: DeviceDataStructure.h:142
storageStructure
This stucture describes sotrage characterization.
Definition: DeviceDataStructure.h:58
storageStructure::banks
deviceBank * banks
Definition: DeviceDataStructure.h:60
storageStructure::banksNumber
unsigned int banksNumber
Definition: DeviceDataStructure.h:59