updated HPM firmware agent to version 1.04

2009-02-11
  - With multi-component HPM file, if one component need to be skipped because
    the component is already up-to-date,  ipmitool sends "Initiate upgrade
    action / Upload for upgrade" anyway.

    If the component needs to be skipped, ipmitool will not send "Initiate
    upgrade action / Upload for upgrade"

  - Incremented version to 1.03

  2009-02-11
  - Fixed side effect introduced by last version, "forced" update didn't
    work anymore
  - Incremented version to 1.04
This commit is contained in:
Francois Isabelle 2009-03-18 20:19:23 +00:00
parent 756c22a866
commit e2b72d82de

View File

@ -105,6 +105,21 @@
* - Reduce buffer length more aggressively when no response from iol. * - Reduce buffer length more aggressively when no response from iol.
* - Incremented version to 1.02 * - Incremented version to 1.02
* *
* 2009-02-11
* - With multi-component HPM file, if one component need to be skipped because
* the component is already up-to-date, ipmitool sends "Initiate upgrade
* action / Upload for upgrade" anyway.
*
* If the component needs to be skipped, ipmitool will not send "Initiate
* upgrade action / Upload for upgrade"
*
* - Incremented version to 1.03
*
* 2009-02-11
* - Fixed side effect introduced by last version, "forced" update didn't
* work anymore
* - Incremented version to 1.04
*
* =========================================================================== * ===========================================================================
* TODO * TODO
* =========================================================================== * ===========================================================================
@ -121,7 +136,7 @@ extern int verbose;
*/ */
#define HPMFWUPG_VERSION_MAJOR 1 #define HPMFWUPG_VERSION_MAJOR 1
#define HPMFWUPG_VERSION_MINOR 0 #define HPMFWUPG_VERSION_MINOR 0
#define HPMFWUPG_VERSION_SUBMINOR 2 #define HPMFWUPG_VERSION_SUBMINOR 4
/* /*
* HPM.1 FIRMWARE UPGRADE COMMANDS (part of PICMG) * HPM.1 FIRMWARE UPGRADE COMMANDS (part of PICMG)
@ -1042,6 +1057,18 @@ static int HpmfwupgWaitLongDurationCmd(struct ipmi_intf *intf, struct HpmfwupgUp
static struct ipmi_rs * HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req, static struct ipmi_rs * HpmfwupgSendCmd(struct ipmi_intf *intf, struct ipmi_rq req,
struct HpmfwupgUpgradeCtx* pFwupgCtx); struct HpmfwupgUpgradeCtx* pFwupgCtx);
static int HpmFwupgActionUploadFirmware
(
struct HpmfwupgComponentBitMask components,
struct HpmfwupgUpgradeCtx* pFwupgCtx,
unsigned char** pImagePtr,
int componentToUpload,
struct ipmi_intf *intf,
int option,
int* pFlagColdReset
);
/**************************************************************************** /****************************************************************************
* *
* Function Name: HpmGetuserInput * Function Name: HpmGetuserInput
@ -1958,7 +1985,6 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
/* Deternime actions size */ /* Deternime actions size */
actionsSize = pFwupgCtx->imageSize - sizeof(struct HpmfwupgImageHeader); actionsSize = pFwupgCtx->imageSize - sizeof(struct HpmfwupgImageHeader);
if (option & VERSIONCHECK_MODE || option & FORCE_MODE) if (option & VERSIONCHECK_MODE || option & FORCE_MODE)
{ {
HpmDisplayUpgradeHeader(0); HpmDisplayUpgradeHeader(0);
@ -2054,6 +2080,46 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
case HPMFWUPG_ACTION_UPLOAD_FIRMWARE: case HPMFWUPG_ACTION_UPLOAD_FIRMWARE:
/* Upload all firmware blocks */ /* Upload all firmware blocks */
rc = HpmFwupgActionUploadFirmware
(
pActionRecord->components,
pFwupgCtx,
&pImagePtr,
componentToUpload,
intf,
option,
&flagColdReset
);
break;
default:
lprintf(LOG_NOTICE," Invalid Action type. Cannot continue");
rc = HPMFWUPG_ERROR;
break;
}
}
}
HpmDisplayLine("-",79);
if (flagColdReset)
{
fflush(stdout);
lprintf(LOG_NOTICE,"(*) Component requires Payload Cold Reset");
}
return rc;
}
static int HpmFwupgActionUploadFirmware
(
struct HpmfwupgComponentBitMask components,
struct HpmfwupgUpgradeCtx* pFwupgCtx,
unsigned char** pImagePtr,
int componentToUpload,
struct ipmi_intf *intf,
int option,
int *pFlagColdReset
)
{ {
struct HpmfwupgFirmwareImage* pFwImage; struct HpmfwupgFirmwareImage* pFwImage;
struct HpmfwupgInitiateUpgradeActionCtx initUpgActionCmd; struct HpmfwupgInitiateUpgradeActionCtx initUpgActionCmd;
@ -2061,7 +2127,10 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
struct HpmfwupgFinishFirmwareUploadCtx finishCmd; struct HpmfwupgFinishFirmwareUploadCtx finishCmd;
struct HpmfwupgGetComponentPropertiesCtx getCompProp; struct HpmfwupgGetComponentPropertiesCtx getCompProp;
VERSIONINFO *pVersionInfo; VERSIONINFO *pVersionInfo;
time_t start,end;
int rc = HPMFWUPG_SUCCESS;
int skip = FALSE;
unsigned char* pData, *pDataInitial; unsigned char* pData, *pDataInitial;
unsigned char count; unsigned char count;
unsigned int totalSent = 0; unsigned int totalSent = 0;
@ -2079,32 +2148,67 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
unsigned char componentId = 0x00; unsigned char componentId = 0x00;
unsigned char componentIdByte = 0x00; unsigned char componentIdByte = 0x00;
/* Save component ID on which the upload is done */ /* Save component ID on which the upload is done */
componentIdByte = pActionRecord->components.ComponentBits.byte; componentIdByte = components.ComponentBits.byte;
while ((componentIdByte>>=1)!=0) while ((componentIdByte>>=1)!=0)
{ {
componentId++; componentId++;
} }
pFwupgCtx->componentId = componentId; pFwupgCtx->componentId = componentId;
/* Initialize parameters */ pVersionInfo = (VERSIONINFO*) &gVersionInfo[componentId];
uploadCmd.req.blockNumber = 0;
pFwImage = (struct HpmfwupgFirmwareImage*)(pImagePtr + pFwImage = (struct HpmfwupgFirmwareImage*)((*pImagePtr) +
sizeof(struct HpmfwupgActionRecord)); sizeof(struct HpmfwupgActionRecord));
/*
* lprintf(LOG_NOTICE," Upgrading %s", pFwImage->desc);
* lprintf(LOG_NOTICE," with Version: Major: %d", pFwImage->version[0]);
* lprintf(LOG_NOTICE," Minor: %x", pFwImage->version[1]);
* lprintf(LOG_NOTICE," Aux : %03d %03d %03d %03d", pFwImage->version[2],
* pFwImage->version[3],
* pFwImage->version[4],
* pFwImage->version[5]);
*/
pDataInitial = ((unsigned char*)pFwImage + sizeof(struct HpmfwupgFirmwareImage)); pDataInitial = ((unsigned char*)pFwImage + sizeof(struct HpmfwupgFirmwareImage));
pData = pDataInitial; pData = pDataInitial;
/* Get firmware length */
firmwareLength = pFwImage->length[0];
firmwareLength |= (pFwImage->length[1] << 8) & 0xff00;
firmwareLength |= (pFwImage->length[2] << 16) & 0xff0000;
firmwareLength |= (pFwImage->length[3] << 24) & 0xff000000;
mode = TARGET_VER | IMAGE_VER;
if (pVersionInfo->rollbackSupported)
{
mode |= ROLLBACK_VER;
}
if ((option & DEBUG_MODE))
{
printf("\n\n Comp ID : %d [%-20s]\n",pVersionInfo->componentId,pFwImage->desc);
}
else
{
HpmDisplayVersion(mode,pVersionInfo);
}
if
(
(
(pVersionInfo->skipUpgrade)
||
(
/* We will skip if the user has given some components in command line "component 2" */
(!(1<<componentToUpload & components.ComponentBits.byte))
&&
(componentToUpload != DEFAULT_COMPONENT_UPLOAD)
)
)
&&
((option & FORCE_MODE_ALL) != FORCE_MODE_ALL)
)
{
skip = TRUE;
}
if(!skip)
{
/* Initialize parameters */
uploadCmd.req.blockNumber = 0;
/* Find max buffer length according the connection parameters */ /* Find max buffer length according the connection parameters */
if ( strstr(intf->name,"lan") != NULL ) if ( strstr(intf->name,"lan") != NULL )
{ {
@ -2138,60 +2242,21 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
} }
} }
/* Get firmware length */ /* Send Initiate Upgrade Action */
firmwareLength = pFwImage->length[0]; initUpgActionCmd.req.componentsMask = components;
firmwareLength |= (pFwImage->length[1] << 8) & 0xff00;
firmwareLength |= (pFwImage->length[2] << 16) & 0xff0000;
firmwareLength |= (pFwImage->length[3] << 24) & 0xff000000;
if ( (!(1<<componentToUpload & pActionRecord->components.ComponentBits.byte))
&& (componentToUpload != DEFAULT_COMPONENT_UPLOAD))
{
/* We will skip if the user has given some components in command line "component 2" */
pImagePtr = pDataInitial + firmwareLength;
break;
}
/* Send initiate command */
initUpgActionCmd.req.componentsMask = pActionRecord->components;
/* Action is upgrade */ /* Action is upgrade */
initUpgActionCmd.req.upgradeAction = HPMFWUPG_UPGRADE_ACTION_UPGRADE; initUpgActionCmd.req.upgradeAction = HPMFWUPG_UPGRADE_ACTION_UPGRADE;
rc = HpmfwupgInitiateUpgradeAction(intf, &initUpgActionCmd, pFwupgCtx); rc = HpmfwupgInitiateUpgradeAction(intf, &initUpgActionCmd, pFwupgCtx);
if (rc != HPMFWUPG_SUCCESS) if (rc != HPMFWUPG_SUCCESS)
{ {
break; skip = TRUE;
} }
pVersionInfo = (VERSIONINFO*) &gVersionInfo[componentId]; if ( (pVersionInfo->coldResetRequired) && (!skip))
mode = TARGET_VER | IMAGE_VER;
if (pVersionInfo->rollbackSupported)
{ {
mode |= ROLLBACK_VER; *pFlagColdReset = TRUE;
} }
if ( pVersionInfo->coldResetRequired)
{
flagColdReset = TRUE;
}
if( (option & VERSIONCHECK_MODE) && pVersionInfo->skipUpgrade)
{
HpmDisplayVersion(mode,pVersionInfo);
HpmDisplayUpgrade(1,0,0,0);
pImagePtr = pDataInitial + firmwareLength;
break;
}
if ((option & DEBUG_MODE))
{
printf("\n\n Comp ID : %d [%-20s]\n",pVersionInfo->componentId,pFwImage->desc);
}
else
{
HpmDisplayVersion(mode,pVersionInfo);
}
/* pDataInitial is the starting pointer of the image data */ /* pDataInitial is the starting pointer of the image data */
/* pDataTemp is one which we will move across */ /* pDataTemp is one which we will move across */
pData = pDataInitial; pData = pDataInitial;
@ -2245,7 +2310,6 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
lprintf(LOG_NOTICE,"\n TotalSent:0x%x ",totalSent); lprintf(LOG_NOTICE,"\n TotalSent:0x%x ",totalSent);
/* Exiting from the function */ /* Exiting from the function */
rc = HPMFWUPG_ERROR; rc = HPMFWUPG_ERROR;
break;
} }
} }
else else
@ -2253,14 +2317,13 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
if (blockLength > firmwareLength) if (blockLength > firmwareLength)
{ {
/* /*
* blockLength is the remaining length of the firnware to upload so * blockLength is the remaining length of the firmware to upload so
* if its greater than the firmware length then its kind of error * if its greater than the firmware length then its kind of error
*/ */
lprintf(LOG_NOTICE,"\n Error in Upload FIRMWARE command [rc=%d]\n",rc); lprintf(LOG_NOTICE,"\n Error in Upload FIRMWARE command [rc=%d]\n",rc);
lprintf(LOG_NOTICE,"\n TotalSent:0x%x Img offset:0x%x Blk length:0x%x Fwlen:0x%x\n", lprintf(LOG_NOTICE,"\n TotalSent:0x%x Img offset:0x%x Blk length:0x%x Fwlen:0x%x\n",
totalSent,imageOffset,blockLength,firmwareLength); totalSent,imageOffset,blockLength,firmwareLength);
rc = HPMFWUPG_ERROR; rc = HPMFWUPG_ERROR;
break;
} }
totalSent += count; totalSent += count;
if (imageOffset != 0x00) if (imageOffset != 0x00)
@ -2306,8 +2369,21 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
uploadCmd.req.blockNumber++; uploadCmd.req.blockNumber++;
} }
} }
}
if (rc == HPMFWUPG_SUCCESS) if (skip)
{
HpmDisplayUpgrade(1,0,0,0);
*pImagePtr = pDataInitial + firmwareLength;
}
if
(
(rc == HPMFWUPG_SUCCESS)
&&
(!skip)
)
{ {
/* Send finish component */ /* Send finish component */
/* Set image length */ /* Set image length */
@ -2320,25 +2396,9 @@ int HpmfwupgUpgradeStage(struct ipmi_intf *intf, struct HpmfwupgUpgradeCtx* pFwu
finishCmd.req.imageLength[2] = (totalSent >> 16) & 0xFF; finishCmd.req.imageLength[2] = (totalSent >> 16) & 0xFF;
finishCmd.req.imageLength[3] = (totalSent >> 24) & 0xFF; finishCmd.req.imageLength[3] = (totalSent >> 24) & 0xFF;
rc = HpmfwupgFinishFirmwareUpload(intf, &finishCmd, pFwupgCtx); rc = HpmfwupgFinishFirmwareUpload(intf, &finishCmd, pFwupgCtx);
pImagePtr = pDataInitial + firmwareLength; *pImagePtr = pDataInitial + firmwareLength;
}
}
break;
default:
lprintf(LOG_NOTICE," Invalid Action type. Cannot continue");
rc = HPMFWUPG_ERROR;
break;
}
}
} }
HpmDisplayLine("-",79);
if (flagColdReset)
{
fflush(stdout);
lprintf(LOG_NOTICE,"(*) Component requires Payload Cold Reset");
}
return rc; return rc;
} }