Other Parts Discussed in Thread: CC2640, CC2640R2F
I am working on a project based heavily on the Sensortag both in firmware and hardware. My current task is to improve the reliability of the OAD update. I am using the BLE Device Monitor program to characterize failures and have narrowed down our most reoccurring problem to an OAD_BUFFER_OFL error. In the firmware, I have found that this is the section of code that causes the error (in red below)
In oadService.c, OADService_ImgBlockWrite():
...
if (oadBlkNum == blkNum)
{
// Calculate address to write as (start of OAD range) + (offset into range)
uint32_t addr = imageAddress + (oadBlkNum * OAD_BLOCK_SIZE);
// If address starts a new page, erase that page first.
if ((addr % HAL_FLASH_PAGE_SIZE) == 0)
{
if (!OADTarget_eraseFlash(addr / HAL_FLASH_PAGE_SIZE))
OADTarget_systemReset();
}
// Write a 16 byte block to Flash.
OADTarget_writeFlash(imagePage, (blkNum * OAD_BLOCK_SIZE), pValue+2, OAD_BLOCK_SIZE);
// Increment received block count.
oadBlkNum++;
}
else
{
// Overflow, abort OAD
oadBlkNum = 0;
flagRecord = 0;
// Close the target device
OADTarget_close();
// Send status
OAD_sendStatus(connHandle, OAD_BUFFER_OFL);
delay_ms(1000);
OADTarget_systemReset();
}
So oadBlkNum and blkNum could be used as a sequence counter - in the case that they do not match, I would like to request the current oadBlkNum again but the BLE Device Monitor does not seem to respond to a:
// Request the next OAD Image block.
OAD_getNextBlockReq(connHandle, oadBlkNum);
if that oadBlkNum block has already been sent. In essence, this is a request for the downloader application to retransmit a block. It seems like the BLE Device Monitor downloader keeps track of its own block sequence and is unwilling to retransmit a packet instead of responding to the OAD_getNextBlockReq. Has anyone tried implementing this?
Thanks,
Tom