Skip to main content
jonas239955
Associate II
April 12, 2012
Question

Accessing ST Dfuse DLL with C#

  • April 12, 2012
  • 52 replies
  • 9972 views
Posted on April 12, 2012 at 10:26

To integrate firmware update functionality into a custom c♯ application I start to use ST Dfuse dll from c♯. I managed to enumerate and identify the device (UM0392 - 3.1 and 3.2) but now get stucked  while trying to erase the device. Out of the manual:

DWORD OperationCode;

PDWORD pNbAlternates;

PMAPPING pMapping;

PHANDLE pHandle;

// Programming the operation contex

lstrcpy(Context.szDevLink, DFUName);

Context.DfuGUID=GUID_DFU;

Context.AppGUID=GUID_APP;

Context.Operation=OPERATION_ERASE;

Context.bDontSendFFTransfersForUpgrade= TRUE;

STDFUPRT_CreateMappingFromDevice((LPSTR)(LPCSTR)DFUName,&pMapping, &NbAlternates);

STDFUFILES_CreateImageFromMapping(pHandle, pMapping);

STDFUFILES_FilterImageForOperation(hImage, m_pMapping+TargetSel,

OPERATION_ERASE, FALSE);

Context.hImage=hImage;

if( STDFUPRT_LaunchOperation(&Context, &OperationCode) != STDFUPRT_NOERROR)

{

Printf(�Erase error�);

}

The call of STDFUPRT_LaunchOperation() does always return a STDFUPRT_BADPARAMETER error.

Is there a way to get some more information about this error? Which parameter is bad?

The first parameter in LaunchOperation() is a pointer to the struct DFUThreadContext. I rebuilt this struct in c♯ using the information given in UM0384.pdf chapter 4.3.4. My UM0384 is revision 1 - June 2007 - wonder if that user manual is still up-to-date?!?

I did not find UM0384 on the webpage (my copy is out of the package UM0412.zip). Does anyone have a newer one?

Thanks in advance for any help

#st-dfu #st-dfuse #dfuse
This topic has been closed for replies.

52 replies

assaf2
Visitor II
August 29, 2012
Posted on August 29, 2012 at 16:02

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6bO&d=%2Fa%2F0X0000000bra%2FjDn3.1g.dFJaXngC4RtexiFDjnmD7NjMRdMIkjUYgNI&asPdf=false
markmclean9
Associate
January 18, 2013
Posted on January 18, 2013 at 16:36

Hi,

I'm also trying to write some C# code to do the ST DFU erase and download.  What you've got here looks very useful ,and I'll have a dig thru it on Monday, but I wondered if any of the posters had a complete working .net app they they could post somewhere (eg. Code Project), I'm sure it would be very useful to other people too.

Cheers,

Mark