mirror of https://github.com/FOME-Tech/openblt.git
Refs #343. Added option to specify a memory address offset to BltFirmwareLoadFromFile.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@275 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
be5f70b264
commit
97cadfc1da
|
@ -170,8 +170,8 @@ int main(int argc, char const * const argv[])
|
|||
printf("Loading firmware data from file..."); (void)fflush(stdout);
|
||||
/* Initialize the firmware data module using the S-record parser. */
|
||||
BltFirmwareInit(BLT_FIRMWARE_PARSER_SRECORD);
|
||||
/* Load firmware data from the firmware file. */
|
||||
if (BltFirmwareLoadFromFile(appFirmwareFile) != BLT_RESULT_OK)
|
||||
/* Load firmware data from the firmware file without memory address offset. */
|
||||
if (BltFirmwareLoadFromFile(appFirmwareFile, 0) != BLT_RESULT_OK)
|
||||
{
|
||||
/* Set error code. */
|
||||
result = RESULT_ERROR_FIRMWARE_LOAD;
|
||||
|
|
|
@ -93,10 +93,12 @@ void FirmwareTerminate(void)
|
|||
** \brief Uses the linked parser to load the firmware data from the specified file
|
||||
** into the linked list of segments.
|
||||
** \param firmwareFile Filename of the firmware file to load.
|
||||
** \param addressOffset Optional memory address offset to add when loading the
|
||||
** firmware data from the file.
|
||||
** \return True if successful, false otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
bool FirmwareLoadFromFile(char const * firmwareFile)
|
||||
bool FirmwareLoadFromFile(char const * firmwareFile, uint32_t addressOffset)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
@ -113,7 +115,7 @@ bool FirmwareLoadFromFile(char const * firmwareFile)
|
|||
if (parserPtr->LoadFromFile != NULL)
|
||||
{
|
||||
/* Request the parser to perform the load operation. */
|
||||
result = parserPtr->LoadFromFile(firmwareFile);
|
||||
result = parserPtr->LoadFromFile(firmwareFile, addressOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ typedef struct t_firmware_parser
|
|||
/** \brief Extract the firmware segments from the firmware file and add them as nodes
|
||||
* to the linked list.
|
||||
*/
|
||||
bool (* LoadFromFile) (char const * firmwareFile);
|
||||
bool (* LoadFromFile) (char const * firmwareFile, uint32_t addressOffset);
|
||||
/** \brief Write all the firmware segments from the linked list to the specified
|
||||
* firmware file.
|
||||
*/
|
||||
|
@ -81,7 +81,7 @@ typedef struct t_firmware_parser
|
|||
****************************************************************************************/
|
||||
void FirmwareInit(tFirmwareParser const * parser);
|
||||
void FirmwareTerminate(void);
|
||||
bool FirmwareLoadFromFile(char const * firmwareFile);
|
||||
bool FirmwareLoadFromFile(char const * firmwareFile, uint32_t addressOffset);
|
||||
bool FirmwareSaveToFile(char const * firmwareFile);
|
||||
uint32_t FirmwareGetSegmentCount(void);
|
||||
tFirmwareSegment * FirmwareGetSegment(uint32_t segmentIdx);
|
||||
|
|
|
@ -357,10 +357,14 @@ LIBOPENBLT_EXPORT void BltFirmwareTerminate(void)
|
|||
** \brief Loads firmware data from the specified file using the firmware file parser
|
||||
** that was specified during the initialization of this module.
|
||||
** \param firmwareFile Filename of the firmware file to load.
|
||||
** \param addressOffset Optional memory address offset to add when loading the
|
||||
** firmware data from the file. This is typically only useful when loading
|
||||
** firmware data from a binary formatted firmware file.
|
||||
** \return BLT_RESULT_OK if successful, BLT_RESULT_ERROR_xxx otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareLoadFromFile(char const * firmwareFile)
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareLoadFromFile(char const * firmwareFile,
|
||||
uint32_t addressOffset)
|
||||
{
|
||||
uint32_t result = BLT_RESULT_ERROR_GENERIC;
|
||||
|
||||
|
@ -371,7 +375,7 @@ LIBOPENBLT_EXPORT uint32_t BltFirmwareLoadFromFile(char const * firmwareFile)
|
|||
if (firmwareFile != NULL) /*lint !e774 */
|
||||
{
|
||||
/* Pass the request on to the firmware data module. */
|
||||
if (FirmwareLoadFromFile(firmwareFile))
|
||||
if (FirmwareLoadFromFile(firmwareFile, addressOffset))
|
||||
{
|
||||
result = BLT_RESULT_OK;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,8 @@ LIBOPENBLT_EXPORT uint32_t BltSessionReadData(uint32_t address, uint32_t len,
|
|||
****************************************************************************************/
|
||||
LIBOPENBLT_EXPORT void BltFirmwareInit(uint32_t parserType);
|
||||
LIBOPENBLT_EXPORT void BltFirmwareTerminate(void);
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareLoadFromFile(char const * firmwareFile);
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareLoadFromFile(char const * firmwareFile,
|
||||
uint32_t addressOffset);
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareSaveToFile(char const * firmwareFile);
|
||||
LIBOPENBLT_EXPORT uint32_t BltFirmwareGetSegmentCount(void);
|
||||
LIBOPENBLT_EXPORT uint8_t * BltFirmwareGetSegment(uint32_t idx, uint32_t * address,
|
||||
|
|
|
@ -134,9 +134,9 @@ const
|
|||
|
||||
procedure BltFirmwareInit(parserType: LongWord); cdecl; external LIBOPENBLT_LIBNAME;
|
||||
procedure BltFirmwareTerminate; cdecl; external LIBOPENBLT_LIBNAME;
|
||||
function BltFirmwareLoadFromFile(firmwareFile: PAnsiChar): LongWord;
|
||||
cdecl; external LIBOPENBLT_LIBNAME;
|
||||
function BltFirmwareSaveToFile(firmwareFile: PAnsiChar): LongWord;
|
||||
function BltFirmwareLoadFromFile(firmwareFile: PAnsiChar; addressOffsets: LongWord):
|
||||
LongWord; cdecl; external LIBOPENBLT_LIBNAME;
|
||||
function BltFirmwareSaveToFile(firmwareFile: PAnsiChar): LongWord;
|
||||
cdecl; external LIBOPENBLT_LIBNAME;
|
||||
function BltFirmwareGetSegmentCount: LongWord; cdecl; external LIBOPENBLT_LIBNAME;
|
||||
function BltFirmwareGetSegment(idx: LongWord;
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef enum t_srec_parser_line_type
|
|||
/****************************************************************************************
|
||||
* Function prototypes
|
||||
****************************************************************************************/
|
||||
static bool SRecParserLoadFromFile (char const * firmwareFile);
|
||||
static bool SRecParserLoadFromFile (char const * firmwareFile, uint32_t addressOffset);
|
||||
static bool SRecParserSaveToFile (char const * firmwareFile);
|
||||
static bool SRecParserExtractLineData(char const * line, uint32_t * address,
|
||||
uint32_t * len, uint8_t * data);
|
||||
|
@ -101,10 +101,12 @@ tFirmwareParser const * SRecParserGetParser(void)
|
|||
** data to the firmware data that is currently managed by the firmware data
|
||||
** module.
|
||||
** \param firmwareFile Filename of the firmware file to load.
|
||||
** \param addressOffset Optional memory address offset to add when loading the
|
||||
** firmware data from the file.
|
||||
** \return True if successful, false otherwise.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static bool SRecParserLoadFromFile (char const * firmwareFile)
|
||||
static bool SRecParserLoadFromFile (char const * firmwareFile, uint32_t addressOffset)
|
||||
{
|
||||
bool result = false;
|
||||
FILE *fp;
|
||||
|
@ -151,8 +153,10 @@ static bool SRecParserLoadFromFile (char const * firmwareFile)
|
|||
/* Only add data if there is actually something to add. */
|
||||
if (len > 0)
|
||||
{
|
||||
/* Add the extracted data to the firmware data module. */
|
||||
if (!FirmwareAddData(address, len, data))
|
||||
/* Add the extracted data to the firmware data module and add the memory
|
||||
* address that was specified by the caller.
|
||||
*/
|
||||
if (!FirmwareAddData(address + addressOffset, len, data))
|
||||
{
|
||||
/* Error detected. Flag it and abort. */
|
||||
result = false;
|
||||
|
|
Loading…
Reference in New Issue