AnsweredAssumed Answered

DFU operation OPERATION_RETURN not working

Question asked by dietzsch.rick on Nov 4, 2013

Hi,
I have to write a Flash tool for the STM32 Family via USB. So I have tu use DfuSe API. I found the demo DfuSeDemo where everything works fine (the button "Leave DFU mode" too). Now I ported the code step by step in an own Windows console tool. But currently I have a problem on the operation OPERATION_RETURN. Function STDFUPRT_GetOperationStatus always retruns the Context.ErrorCode = STDFUPRT_UNEXPECTEDERROR. I already read the user manual UM0384 but did not found any hints. I checked the device name, the content of the image and the content of the mapping between both tools but I cannot find a difference. Has anybody an idea where is my mistake?

Here is my code:

lstrcpy (Context.szDevLink, szDeviceName_l);

Context.DfuGUID = GUID_DFU;
Context.AppGUID = GUID_APP;
Context.Operation = OPERATION_RETURN;

STDFUFILES_CreateImageFromMapping (&hImage, pStdfuMapping_l + 0);
STDFUFILES_SetImageName (hImage, (LPSTR)(LPCSTR) pStdfuMapping_l->Name);
STDFUFILES_FilterImageForOperation (hImage, pStdfuMapping_l + 0, OPERATION_RETURN, FALSE);

Context.hImage = hImage;

dwRes = STDFUPRT_LaunchOperation (&Context, &dwOperationCode_l);
if (dwRes == STDFUPRT_NOERROR)

  do
  {
    Sleep (100);
    STDFUPRT_GetOperationStatus (dwOperationCode_l, &CheckContext);
    if (CheckContext.ErrorCode != STDFUPRT_NOERROR)
    {
      ...
      break;
    }
    else
    {
      ...
      break;

    }
  }
  while (1);
}

 

Outcomes