mirror of https://github.com/FOME-Tech/openblt.git
Refs #306. Improved S-record parsing for detecting the erase blocks to support program data gaps in the S-record.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@218 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
e9373e236c
commit
71e918f3c4
|
@ -216,7 +216,7 @@ void FileTask(void)
|
|||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Starting the programming sequence\n\r");
|
||||
FileFirmwareUpdateLogHook("Parsing firmware file to obtain erase size...");
|
||||
FileFirmwareUpdateLogHook("Parsing firmware file to detect erase blocks...");
|
||||
#endif
|
||||
/* prepare data objects for the erasing state */
|
||||
eraseInfo.start_address = 0;
|
||||
|
@ -276,32 +276,18 @@ void FileTask(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* update the start_address and byte count */
|
||||
if (lineParseObject.address < eraseInfo.start_address)
|
||||
/* does this data fit at the end of the previously detected program block? */
|
||||
if (lineParseObject.address == (eraseInfo.start_address + eraseInfo.total_size))
|
||||
{
|
||||
eraseInfo.start_address = lineParseObject.address;
|
||||
}
|
||||
/* update the byte count */
|
||||
eraseInfo.total_size += parse_result;
|
||||
}
|
||||
}
|
||||
/* check if the end of the file was reached */
|
||||
if (f_eof(&fatFsObjects.file) > 0)
|
||||
else
|
||||
{
|
||||
/* rewind the file in preparation for the programming state */
|
||||
if (f_lseek(&fatFsObjects.file, 0) != FR_OK)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_REWINDING_FILE_READ_POINTER);
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
/* data does not belong to the previously detected block so there must be a
|
||||
* gap in the data. first erase the currently detected block and then start
|
||||
* tracking a new block.
|
||||
*/
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Erasing ");
|
||||
|
@ -334,6 +320,70 @@ void FileTask(void)
|
|||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Parsing firmware file to detect erase blocks...");
|
||||
#endif
|
||||
|
||||
/* store the start_address and element count */
|
||||
eraseInfo.start_address = lineParseObject.address;
|
||||
eraseInfo.total_size = parse_result;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* check if the end of the file was reached */
|
||||
if (f_eof(&fatFsObjects.file) > 0)
|
||||
{
|
||||
/* rewind the file in preparation for the programming state */
|
||||
if (f_lseek(&fatFsObjects.file, 0) != FR_OK)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_REWINDING_FILE_READ_POINTER);
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
/* still here so we are ready to perform the last memory erase operation, if there
|
||||
* is still something left to erase.
|
||||
*/
|
||||
if (eraseInfo.total_size > 0)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Erasing ");
|
||||
/* convert size to string */
|
||||
FileLibLongToIntString(eraseInfo.total_size, loggingStr);
|
||||
FileFirmwareUpdateLogHook(loggingStr);
|
||||
FileFirmwareUpdateLogHook(" bytes from memory at 0x");
|
||||
/* convert address to hex-string */
|
||||
FileLibByteToHexString((blt_int8u)(eraseInfo.start_address >> 24), &loggingStr[0]);
|
||||
FileLibByteToHexString((blt_int8u)(eraseInfo.start_address >> 16), &loggingStr[2]);
|
||||
FileLibByteToHexString((blt_int8u)(eraseInfo.start_address >> 8), &loggingStr[4]);
|
||||
FileLibByteToHexString((blt_int8u)eraseInfo.start_address, &loggingStr[6]);
|
||||
FileFirmwareUpdateLogHook(loggingStr);
|
||||
FileFirmwareUpdateLogHook("...");
|
||||
#endif
|
||||
if (NvmErase(eraseInfo.start_address, eraseInfo.total_size) == BLT_FALSE)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_ERASE_MEMORY);
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
#endif
|
||||
/* all okay, then go to programming state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_PROGRAMMING;
|
||||
|
|
Loading…
Reference in New Issue