cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer_api project cannot run

szhih
Associate

hi,

   I'm trying to run STM32CubeProgrammer_api project, I could build the STM32CubePrgAPI.exe with no error, but I got the 0xc000007B error when I run it; it seems that missing some runtime DLLs, I tried to install vs2015, vs2013, vs2010 runtime, but got the mistake;

my environment as blow:

os: win7 64bit

build with VS2017 version 15.6.6 and Windows SDK version 10.0.16299.0;

17 REPLIES 17
Marcuka
Associate III

Hi Alberto,

Thank you for spending time to write to me. If you come to Bulgaria call me to drink a beer!

Now on the problem. I configure new visual studio project for 64 bit architecture and got error (The attached picture). It says that the library is for 32bit but the application is for 64 bit. The last week I try with MSYS2 and mingw64, again can't start the application, due to the first error I got.

May be it is better to try with another tool provided by ST - STVP programming toolkit.

I'm still wondering, could it be possible the provided demo by ST to not work properly even with the new software release!!!

alberto.spagnolo
Associate III

Yes, that's why I didn't use the .lib and imported the dll symbols manually (see stLink_loadDll() in my stLink.c). I've been struggling on this for many days, but at last I was able to make it work.

My code should compile as well with the MSVC compiler and doesn't use the .lib (I got your very same error while trying to use it).

Another possible solution is:

  • uninstall STM32CubeProgrammer
  • uninstall Java64
  • install Java32
  • install STM32CubeProgrammer

At that point, you should have the 32 bit version of both the .dll and the .lib (and you need to compile a 32 bit executable, of course).

I'll keep that beer coupon in my pocket, thanks :beaming_face_with_smiling_eyes:

Marcuka
Associate III

Alberto, I follow your advice and install 32bit java and now the example Visual studio project works for me. Thank you so much! Don't forget the beer! Where are you?

alberto.spagnolo
Associate III

Happy to hear that, Martin :)

I'm from Italy. If I come there, I'll let you know!

@alberto.spagnolo​, Thanks! Just curious - how did you know that setDisplayCallbacks() must be called to enumerate the ST Link? It solved the 0xC0000005 I was seeing when calling getStLinkList() from Python.

The STM32CubeProgrammer_API.chm doc says, regarding setDisplayCallbacks(), "This function must be called first of all to ensure the display management" which implies that it's needed only for display management.

Well, actually I replicated the initialization in the sample application, then started to remove parts that were missing in my application. I started right from setDisplayCallbacks(), because I was suspecting that there were void pointers somewhere.

I'm happy that I could spare you some headache...

Alberto,

Thank you very much for sharing this information. It is not necessarily intuitive to call the display functionalities when doing device operations, but nonetheless it fixed my Access Violation Exception and saved me a lot of misery. Thank you again!

Other advice - follow the example exactly when connecting the STLink adapter and to the device with the API. Even if connectStLink returns an error flag, it can often still work in the case of downloadFile().

A followup: While connectStLink() returned a -5 error flag for me, it still connected to the device. However, this meant I had to skip the error flag check which was not desirable.

To fix this, you MUST set the 'loaderPath' variable to the folder where ExternalLoader and FlashLoader folders are. This is the 'lib' folder. Additionally, the 'Data_Base' folder must be present alongside 'lib'. Since my .exe was not in the same folder as these folders like STM32CubePrgApi.exe is, it initially returned -5 'CUBEPROGRAMMER_ERROR_NOT_SUPPORTED'. I had to change it from the default "./." to the appropriate folder and now it returns 0.

Maybe I missed it but did not see this in the documentation.