CubeProgrammer API examples not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-07 2:27 AM - edited ‎2025-05-07 2:35 AM
I've just compiled the USB_Example.cpp example and its reporting an initialization error on running (The application could not initialize correctly (0xc000007b)), I have VS 2022 fully updated, I did not migrate the project to the latest toolset to avoid problems.
Any ideas STM team?
D:\Program Files (x86)\STMicroelectronics\STM32Cube\STM32CubeProgrammer\api\project\Visual Studio\x64\STM32CubePrgAPI\/../../../../lib/STM32CubePrgAPI.exe (process 25224) exited with code -1073741701 (0xc000007b).
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
Solved! Go to Solution.
- Labels:
-
Bug-report
-
STM32CubeProgrammer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-08 4:08 AM - edited ‎2025-05-08 4:12 AM
Is there a way to get it to remove any ROP protection?
Will try "-ob rdp=0x0 BOR_LEV=1"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-08 4:21 AM - edited ‎2025-05-08 4:31 AM
Okay so reading the API file notes, I made this change to clear RDP:-
/* 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);
// Robmar mod
dfuConnectParameters params;
params.usb_index = dfuList[0].usbIndex;
params.rdu = 1; // 1 == request removal of RDP
params.tzenreg = 0;
int usbConnectFlag = connectDfuBootloader2(params);
if (usbConnectFlag != 0)
USB speed : Full Speed (12MBit/s)
Manuf. ID : STMicroelectronics
Product ID : DFU in FS Mode
SN : 200364500000
DFU protocol: 1.1
Board : --
Device ID : 0x0450
Warning: Device is under Read Out Protection or Target is held under reset
Device Read Unprotect requested
--- Device Connected ---
So it seems to work now, thanks for your help.
Is there any documentation for the functions that shows all the parameters?
The .chm in the API Docs does not have the info on the params for functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-08 6:47 AM
The CubeProgrammer_API.h
file contains all the necessary details, including function declarations and data structures. Feel free to review it, and I hope it helps!
Maryem.
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-08 10:26 AM
I had to search for that file on the web as it wasn't in the STM Repository or Program File section.
But it doesn't have all the parameters, look at this one for example, dfuConnectParameters isn't detailed anywhere in that file. Is there another source of information?
/**
* \brief This routine allows to start connection to device through USB DFU interface.
* \param dfuConnectParameters : Indicates the dfu connection parameters
* \return 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.
*/
int connectDfuBootloader2(dfuConnectParameters dfuParameters);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-08 1:45 PM
@Robmar if you install CubeProgrammer, on a 64 bit machine, the file should be located in:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\api\include
and you should see:
/**
* \struct dfuConnectParameters
* \brief Specify the USB DFU connect parameters.
*/
typedef struct dfuConnectParameters
{
char *usb_index;
char rdu; /**< request a read unprotect: value in {0,1}.*/
char tzenreg; /**< request a TZEN regression: value in {0,1}.*/
}dfuConnectParameters;
as well as:
/**
* \brief This routine allows to start connection to device through USB DFU interface.
* \param dfuConnectParameters : Indicates the dfu connection parameters
* \return 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.
*/
int connectDfuBootloader2(dfuConnectParameters dfuParameters);
C-Coder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-09 1:25 AM
I downloaded CubeProgrammer from STM's page, and it installed the x86 and 64-bit files on my 64-bit laptop in the x86 Program Files directory which I also thought odd.
And yes, sure I see the same structure, whoopee! But there are no details on what values do what, which is pretty useless, no?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-09 5:31 AM
Robmar,
Simple searching quickly finds what you're looking for. Regarding the rdu, checkout what RDP is here:
https://www.st.com/resource/en/product_training/STM32F7_Security_Memories_Protections.pdf
It's reasonable to assume that the same principles are carried across all of the STM32 products that contain RDP. For the tzenreg parameter, see this:
https://community.st.com/t5/stm32-mcus-products/what-does-tzen-really-do/td-p/716196
C-Coder
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-12 12:51 AM
Hi, are there any examples of programming via the CubeProgrammer from memory?
I've seen in the header there is a writeMemory function:-
int writeMemory(unsigned int address, char* data, unsigned int size);
I've loaded a .hex file into memory, can I use that function to program the MCU, or do I have to use a binary file? The hex file seems to have address that jump around quite a lot, how's that handled if its a binary file?
I ask because I can't find any documentation more than the basic header.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 2:54 AM
Hello @Robmar ,
When converting .hex files to binary, the data is organized so it fits correctly in memory, handling any jumps in addresses.
This function lets you write data directly to specific memory addresses, suitable for continuous data block. You can see how it's used in Example1.cpp
.
int writeMemory(unsigned int address, char* data, unsigned int size);
This function handles downloading data from various file formats, such as .hex and it automatically handles address jumps and data placement. An example implementation can be found in UART_Example.cpp
.
int downloadFile(const wchar_t* filePath, unsigned int address, unsigned int skipErase, unsigned int verify, const wchar_t* binPath);
Hope this helps answer your question!
Maryem.
In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-05-13 3:27 AM
Thanks but you don't say if the WriteMemory function can process a .hex file in memory, nor is this explained in the header file. This is important to know, unless .bin files are padded for contigious data coverage.
Also, in the examples the .exe's are dumped into the api/lib folder, not very normal really, so is it possible to just distribute that folder for people to run the USB example code, a modified version in our case? There are no details of what needs to be put together to package up an application for distribution under this unusual setup, and I hope we don't have to make our clients install CubeProgrammer and then our application.
Appreciate your guidance on this matter.
