Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/electron/bl dfu err propagation #813

Merged
merged 2 commits into from
Jan 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions platform/MCU/STM32F2xx/STM32_USB_Device_Driver/src/usbd_dfu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "usbd_desc.h"
#include "usbd_req.h"
#include "usb_bsp.h"
#include "usbd_dfu_mal.h"


/** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
Expand Down Expand Up @@ -567,7 +568,13 @@ static uint8_t EP0_TxSent (void *pdev)
Pointer += MAL_Buffer[2] << 8;
Pointer += MAL_Buffer[3] << 16;
Pointer += MAL_Buffer[4] << 24;
MAL_Erase(usbd_dfu_AltSet, Pointer);
uint16_t status = MAL_Erase(usbd_dfu_AltSet, Pointer);
if (status != MAL_OK) {
/* Call the error management function (command will be nacked) */
req.bmRequest = 0;
req.wLength = 1;
USBD_CtlError (pdev, &req);
}
}
else
{
Expand All @@ -587,7 +594,13 @@ static uint8_t EP0_TxSent (void *pdev)
Addr = ((wBlockNum - 2) * XFERSIZE) + Pointer;

/* Preform the write operation */
MAL_Write(usbd_dfu_AltSet, Addr, wlength);
uint16_t status = MAL_Write(usbd_dfu_AltSet, Addr, wlength);
if (status != MAL_OK) {
/* Call the error management function (command will be nacked) */
req.bmRequest = 0;
req.wLength = 1;
USBD_CtlError (pdev, &req);
}
}
/* Reset the global lenght and block number */
wlength = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ uint16_t FLASH_If_Erase(uint32_t Add)

/* Check which sector has to be erased */
uint16_t FLASH_Sector = FLASH_SectorToErase(FLASH_INTERNAL, Add);
FLASH_EraseSector(FLASH_Sector, VoltageRange_3);
FLASH_Status status = FLASH_EraseSector(FLASH_Sector, VoltageRange_3);

#elif defined(STM32F10X_CL)
/* Call the standard Flash erase function */
Expand All @@ -113,6 +113,8 @@ uint16_t FLASH_If_Erase(uint32_t Add)
/* Lock the internal flash */
FLASH_Lock();

if (status != FLASH_COMPLETE) return MAL_FAIL;

return MAL_OK;
}

Expand Down Expand Up @@ -141,15 +143,18 @@ uint16_t FLASH_If_Write(uint32_t Add, uint32_t Len)
FLASH_ClearFlags();

/* Data received are Word multiple */
for (idx = 0; idx < Len; idx = idx + 4)
FLASH_Status status = FLASH_COMPLETE;
for (idx = 0; idx < Len && status == FLASH_COMPLETE; idx = idx + 4)
{
FLASH_ProgramWord(Add, *(uint32_t *)(MAL_Buffer + idx));
status = FLASH_ProgramWord(Add, *(uint32_t *)(MAL_Buffer + idx));
Add += 4;
}

/* Lock the internal flash */
FLASH_Lock();

if (status != FLASH_COMPLETE) return MAL_FAIL;

return MAL_OK;
}

Expand Down