/
STM32 Save SFI device certificate to file

STM32 Save SFI device certificate to file

FlashPro-ARM/GangPro-ARM programmers support the ability to read the SFI chip certificate and save it to a file on disk.

The read and save chip certificate to file feature is also accessible by using the API-DLL.

F_ReadSTM32Certificate

General Description

Read device certificate from connected devices to FlashPro-ARM/GangPro-ARM programmers and save to file(cert_1.bin, cert_2.bin etc.)

Supported STM32 series:

  • STM32U5 Series

  • STM32L5 Series

  • STM32H5 Series

Syntax

INT X F_ReadSTM32Certificate( char* path );

Input

char *path : path to save certificate file

  • ““: save in execute place

Output

INT_X : result of operation

  • 1 - success

  • 2 - selected not supported vendor or family

  • 3 - target not opened(no connection established)

  • 4 - can’t create file or path don't exists

  • 5 - error during read certificate

Code example

Code example in python how use F_ReadSTM32Certificate

import os import sys import ctypes #FP-ARM - comment this out and uncomment GP-ARM to use demo for GangPro-ARM if (sys.platform == "win32"): libname = "./FlashProARM-FPAsel.dll" else: libname = "libmultifparm.so" #GP-ARM - commented out - comment this out and uncomment FP-ARM to use demo for FlashPro-ARM #if (sys.platform == "win32"): # libname = "./GangProARM-FPAsel.dll" #else: # libname = "libmultigparm.so" init_file = bytes('FPAs-setup.ini', 'utf-8') if (sys.platform == "win32"): config_file_path = bytes('ConfigFiles\\STM32U5_cert.cfg', 'utf-8') else: config_file_path = bytes('STM32U5_cert.cfg', 'utf-8') #Load library lib = ctypes.cdll.LoadLibrary(libname) # Get number of connected adapters instances = lib.F_OpenInstancesAndFPAs(init_file) print("Connected adapters: {}".format(instances)) # Init all adapters result = lib.F_Set_FPA_index(0) print("F_Set_FPA_index(0): {}".format(result)) result = lib.F_Initialization() print("F_Initialization: {}".format(result)) # Get adapters serial numbers serials = [] for instance in range(1, instances+1): serials.append(lib.F_Get_FPA_SN(instance)) print(serials) result = lib.F_ConfigFileLoad(config_file_path) print("F_ConfigFileLoad: {}".format(result)) # Select one adapter result = lib.F_Set_FPA_index(1) print("F_Set_FPA_index(1): {}".format(result)) # Open Target (required before F_ReadSTM32Certificate ) result = lib.F_Open_Target_Device() print("F_Open_Target_Device".format(result)) result = lib.F_ReadSTM32Certificate("") print("F_ReadSTM32Certificate: {}".format(result)) result = lib.F_Close_Target_Device() print("F_Close_Target_Device: {}".format(result))

 

Useful links

[1] FlashPro-ARM & GangPro-ARM DLL User Guide

 

 

 

 

Related content

Sequential Functions
Sequential Functions
Read with this
SFI binary generation GUI
SFI binary generation GUI
More like this
STM32 MCUs secure firmware install (SFI)
STM32 MCUs secure firmware install (SFI)
More like this
Custom Buffer Write and Verify - FlashPro-ARM
Custom Buffer Write and Verify - FlashPro-ARM
More like this
Custom Buffer Write and Verify - FlashPro-M
Custom Buffer Write and Verify - FlashPro-M
More like this
HSM preparation process
HSM preparation process
More like this