?? download.c
字號:
/* Set to do POST Monitor Mode if requested */ if (param_p->postMonitorMode == HFTC_TRUE) { printf("Set to run in POST Monitor Mode.\n"); status = setPostMonitorMode(unit, frameLen, sframe, rframe); if (status != HFTC_STATUS_OK) { printf("Set of POST Monitor Mode failed! status = %s (%d)\n", HFTC_Status_t_text(status), status); if (status == HFTC_INVALID_ENUM) { printf("Option not available for this firmware type,\n"); printf("thus the option is being ignored for this .cdl.\n"); status = HFTC_STATUS_OK; } else { break; } } } /* Run the code (unless told not to.) */ if (param_p->noRun == HFTC_TRUE) { printf("Downloaded code. Run not issued. (%s)\n", filename); break; } status = doRunCode(unit, frameLen, sframe, rframe); if (status != HFTC_STATUS_OK) { printf("Run failed! status = %s (%d)\n", HFTC_Status_t_text(status), status); break; } if (param_p->longSdramTest != HFTC_TRUE) { printf(" ok.\n"); } if (DL_DEBUG) { printf("Downloaded and running code. (%s)\n", filename); } /* Count that we've downloaded the image. */ ++imagesLoaded; } while (HFTC_FALSE); if (socket_fd_fs != HFTC_INVALID_SOCKET_FD) { /* Close socket */ if (DL_DEBUG) { printf(" %s close socket(%s)\n", __func__, param_p->interface); } closeStatus = HFTC_socket_close(socket_fd_fs); if (closeStatus != HFTC_STATUS_OK) { printf("Socket close failed. status = %s (%d)\n", HFTC_Status_t_text(closeStatus), closeStatus); if (status == HFTC_STATUS_OK) { status = closeStatus; } } socket_fd_fs = HFTC_INVALID_SOCKET_FD; } /* Free code buffer and frame. */ HFTC_free(codeBuffer); HFTC_free(sframe); HFTC_free(rframe); /* Close the input file. */ if (fileOpened == HFTC_TRUE) { fclose(f); } if (DL_DEBUG) { printf("<--%s status = %s (%d) loaded %d images.\n", __func__, HFTC_Status_t_text(status), status, imagesLoaded); } return status;} /* download_file *//*----------------------------------------------------------------------------* * download_ddl *----------------------------------------------------------------------------* * @ingroup CD_API_UTIL * @brief Download a .ddl image. * * This uses the download API to download one .ddl file to the specified * processor. * * @param filename RO: File to download. * @param processor RO: Target processor. * @param param_p RO: Parameters pointer * * @par Externals: * None. * * @return * HFTC_STATUS_OK Download success * * @par Errors: * HFTC_FILE_ERROR Couldn't open file, or no file. * * @par Assumptions: * Assumes the unit table file, if it exists, is the one that was sent to * the eSC. Also assumes if the unit table file does not exist, then the * default PPCI addresses are the correct ones to use. * * Assumes a single thread doing a download. This is because of the * file static socket data, and MII length pad workaround file static * data. * *----------------------------------------------------------------------------*/HFTC_Status_t download_ddl(char *filename, HFTC_Processor_t processor, download_param_t *param_p){ HFTC_Status_t status = HFTC_STATUS_OK; HFTC_Status_t closeStatus = HFTC_STATUS_OK; HFTC_Unit_t unit = 0; HFTC_PPCIAddress_t destPPCIAddr = 0; HFTC_Boolean_t authenticate = HFTC_FALSE; HFTC_AuthData_t authData = {0}; uint32_t maxFrameLen; uint32_t dataBlockLen; FILE *f = NULL; HFTC_Boolean_t fileOpen = HFTC_FALSE; uint32_t numberOfUnits = NUMBEROFUNITS; HFTC_UnitData_t *unitTable_p = NULL; HFTC_UnitData_t *localTable_p = NULL; if (DL_DEBUG) { printf("-->%s (%s)\n", __func__, filename); } do { /* Open the input file. If there is no file we can just return. */ if (strlen(filename) == 0) { break; } f = fopen(filename,"r"); if (f == NULL) { status = HFTC_FILE_ERROR; printf("** ERROR: Can't open %s.\n", filename); break; } fileOpen = HFTC_TRUE; /* Open up a socket for send/receive of download config data. */ socket_fd_fs = HFTC_socket_open(param_p->interface, &socket_addr_fs, HFTC_TRUE, HFTC_PPCI_DEFAULT_TIMEOUT_MILLISECONDS); if (socket_fd_fs == HFTC_INVALID_SOCKET_FD) { printf("** ERROR: socket open on interface '%s' failed!\n", param_p->interface); status = HFTC_SOCKET_ERROR; break; } /* We first do the HFTC_DD_InitCfgDataDownload call. We skip the authentication phase, it isn't yet supported. */ /* In order to do the init call, we first need to know the destination PPCI address of the target processor. Since that may have changed from the configure of the eSC, read the esc unit table file if it exists and get the information from there. Otherwise, we can use the command line parameter values. */ destPPCIAddr = param_p->destPPCIAddrDpu; if (processor == HFTC_ESC) { destPPCIAddr = param_p->destPPCIAddrEsc; } /* If we've got a unit table, use it. The esc unit table file uses unit 0 to reference the DPU and unit 1 to reference the eSC. See also the load_config_params file. */ if (strlen(param_p->unitTable) != 0) { status = HFTC_ReadUnitFile(param_p->unitTable, &numberOfUnits, &unitTable_p, &localTable_p); if (status != HFTC_STATUS_OK) { break; } if (processor == HFTC_DPU) { destPPCIAddr = unitTable_p[DPUINDEX].PPCIaddress; } else { destPPCIAddr = unitTable_p[ESCINDEX].PPCIaddress; } } /* Call the initialization API (HFTC_DD_InitCfgDataDownload() with authenticate set to FALSE to begin the download process. */ if (DL_DEBUG) { printf(" %s: Call init, destPPCI = %02x\n", __func__, destPPCIAddr); } status = HFTC_DD_InitCfgDataDownload(unit, processor, param_p->srcMACAddr, param_p->destMACAddr, param_p->srcPPCIAddr, destPPCIAddr, authenticate, &authData, &dataBlockLen, &maxFrameLen); if (status != HFTC_STATUS_OK) { printf("Init data config download failed. status = %s (%d).\n", HFTC_Status_t_text(status), status); break; } else if (DL_DEBUG) { printf(" %s: Called init, success.\n", __func__); } /* If the load is not over an MII, we don't need the MII length adjust. */ if (param_p->miiDownload == HFTC_FALSE) { MIIAdjust = HFTC_FALSE; } /* Download Config Data. */ status = doDownloadConfig(f, unit, maxFrameLen, dataBlockLen); if (status != HFTC_STATUS_OK) { printf("Download of configuration failed. status = %s (%d)\n", HFTC_Status_t_text(status), status); } } while (HFTC_FALSE); if (fileOpen == HFTC_TRUE) { /* Close the input file. */ fclose(f); } if (socket_fd_fs != HFTC_INVALID_SOCKET_FD) { /* Close socket */ if (DL_DEBUG) { printf(" %s close socket(%s)\n", __func__, param_p->interface); } closeStatus = HFTC_socket_close(socket_fd_fs); if (closeStatus != HFTC_STATUS_OK) { printf("Terminate of comm link failure.\n"); if (status == HFTC_STATUS_OK) { status = closeStatus; } } socket_fd_fs = HFTC_INVALID_SOCKET_FD; } if (DL_DEBUG) { printf("<--%s (%s) status=%s (%d)\n", __func__, filename, HFTC_Status_t_text(status), status); } return status;} /* download_ddl *//* End download.c *//*----------------------------------------------------------------------------*REV # DATE BY REVISION DESCRIPTION----- -------- ----- ------------------------------------------------------0001 07/06/05 msz Created.0002 08/03/05 msz Code review changes.0003 06/05/06 rlh V2.0 changes: - Changed to use common base porting layer instead of PPCI driver. Now uses socket send/receive wrapper functions to send frames to the chip. - Uses porting layer for OS calls. - Uses new HFTC_Get/SetPPCIInterface calls0004 08/03/06 bac Translate enums.0005 08/07/06 msz Adapted jpw's fix "Added statusCommLink to prevent error status from being overwritten and hiding download failures. Bugzilla 1657". Also adding Viper reset funcitonality to apply the Viper reset patch when downloading Viper hardware.0006 08/11/06 msz Timouts are now based on milliseconds instead of seconds. Use system default timeout.0007 08/22/06 msz Added download of Data Config (.ddl) files. Added support for long-sdram-test and post-monitor-mode.0008 08/29/06 msz Minor changes from mini code review done by Rich.0009 09/07/06 msz Adjust PPCI frame lengths if using MII on download. (Bug 1749). Fixed a minor problem found where we tried to close a socket that was not open (needed to mark socket as closed after it was closed).0010 09/14/06 msz Added a destination PPCI address for eSC so we can properly direct things to the eSC without having reset it first. (Bug 1769)0011 09/18/06 msz Temporarily use register_units_from_param, it will reset the unit table so we can apply the viper reset patch.0012 09/25/06 rlh Streamlined startup messages. Added '** Error: ' to error messages.0013 10/06/06 dws The message displayed when HFTC_CD_CheckCodeVersions returns HFTC_INVALID_VERSION more clearly states that the code and hardware are not compatible. download_file now returns an error status when the call to doInfoGathering fails. The string and the numeric value for the error code in the associated error message now match.0014 10/09/06 rlh Renamed configure_esc.[ch] -> load_config_params.[ch]0015 10/19/06 msz Don't print out error messages on viper_reset for writes that may fail anyhow due to the errata.0016 10/25/06 msz Added back in some messages to print out when DEBUG is compiled in. Moved viper_reset_patch to download_configure.h so it can be done every time for a viper load.0017 11/02/06 msz Added RETRANSMIT_RETRY_SECONDS, so we only retry for a limited time (rather than loop forever.)0018 11/17/06 msz Put printf back in for soft reset. It is valuable to know when the hardware has been reset.0019 02/08/07 msz More explanation on failure to run long sdram test. Don't exit on this type error. Bug-2251 Check for a reset on an image load other than the first, as this indicates a problem. Bug-22570020 03/28/07 msz Added a note that SDRAM test can take a while.*-----------------------------------------------------------------------------*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -