void vt_sync(MPI_Comm comm, uint64_t* ltime, int64_t* offset) { VT_MPI_INT myrank, myrank_host, myrank_sync; VT_MPI_INT numnodes; uint64_t time; MPI_Comm host_comm; MPI_Comm sync_comm; VT_SUSPEND_IO_TRACING(VT_CURRENT_THREAD); /* mark begin of clock synchronization */ time = vt_pform_wtime(); vt_enter(VT_CURRENT_THREAD, &time, vt_trc_regid[VT__TRC_SYNCTIME]); /* barrier at entry */ PMPI_Barrier(comm); *offset = 0; *ltime = vt_pform_wtime(); PMPI_Comm_rank(comm, &myrank); /* create communicator containing all processes on the same node */ PMPI_Comm_split(comm, (vt_pform_node_id() & 0x7FFFFFFF), 0, &host_comm); PMPI_Comm_rank(host_comm, &myrank_host); /* create communicator containing all processes with rank zero in the previously created communicators */ PMPI_Comm_split(comm, myrank_host, 0, &sync_comm); PMPI_Comm_rank(sync_comm, &myrank_sync); PMPI_Comm_size(sync_comm, &numnodes); /* measure offsets between all nodes and the root node (rank 0 in sync_comm) */ if (myrank_host == 0) { VT_MPI_INT i; for (i = 1; i < numnodes; i++) { PMPI_Barrier(sync_comm); if (myrank_sync == i) *offset = sync_slave(ltime, 0, sync_comm); else if (myrank_sync == 0) *offset = sync_master(ltime, i, sync_comm); } } /* distribute offset and ltime across all processes on the same node */ PMPI_Bcast(offset, 1, MPI_LONG_LONG_INT, 0, host_comm); PMPI_Bcast(ltime, 1, MPI_LONG_LONG_INT, 0, host_comm); PMPI_Comm_free(&host_comm); PMPI_Comm_free(&sync_comm); /* barrier at exit */ PMPI_Barrier(comm); /* mark end of clock synchronization */ time = vt_pform_wtime(); vt_exit(VT_CURRENT_THREAD, &time); VT_RESUME_IO_TRACING(VT_CURRENT_THREAD); }
INT32 sys_upgrade_process(void (*callback)(INT32 type, INT32 process, UINT16 *str), UINT32 (*GetExitKey)(void), int nType) { UINT32 result = SUCCESS; INT32 i; INT32 retry_count=0; BOOL bReboot = TRUE; BOOL bBurn = TRUE; char strTmp[30]; char strTmp1[30]; char strTmp2[30]; char strTmp3[30]; char strTmp4[30]; char strTmp5[30]; char strTmp6[30]; char strTmp7[30]; char strTmp8[30]; char strTmp9[30]; char strTmp10[30]; char strTmp11[30]; char strTmp12[30]; char strTmp13[30]; char strTmp14[30]; if(nType == 2 || nType == 3) bReboot = FALSE; if(nType == 3) bBurn = FALSE; get_exit_key = GetExitKey; callback_fun = callback; LV_pPanDev = (struct pan_device *) dev_get_by_type(NULL, HLD_DEV_TYPE_PAN); if(NULL == LV_pPanDev) { PRINTF("dev_get_by_name failed\n"); return !SUCCESS; } if(pan_open(LV_pPanDev)!=SUCCESS) { PRINTF("pan_open failed\n"); return !SUCCESS; } //pan_display(LV_pPanDev, "up9 ", 4); #ifdef THREE_DIGITS_PANEL pan_display(LV_pPanDev, " up9", 4); #else pan_display(LV_pPanDev, "up9 ", 4); #endif #ifdef ENABLE_EROM init_buffer(); // uart_reset(); osal_task_sleep(100); uart_high_speed_config(UART_SPEED_NORMAL); do { if(!sync_slave((UPGRADE_MULTI==upgrade_mode)?M2S_MODE:P2P_MODE, 1000)) return !SUCCESS; ; //uart_high_speed_config(UART_HIGH_SPEED_2M); if(!init_slave()) // after init slave, uart 6M high bitrate is applied return !SUCCESS;; }while(0); #endif MG_Setup_CRC_Table(); /* Check sci port */ ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MSG_UPGRADE_CHECK_SERIAL_PORT),strTmp); callback(3,0,strTmp); result = cmd_comtest(&g_protocol_version, NULL, GetExitKey); if(result != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_CONNECT_FAILED),strTmp1); callback(2,0,strTmp1); return !SUCCESS; } p2p_delay(); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_COLLECTING_VERSION_INFO),strTmp2); callback(2,0,strTmp2); if((result = cmd_version(&g_protocol_version)) != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp3); callback(2, 0, strTmp3); return !SUCCESS; } p2p_delay(); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_COMPARE_SLAVE_REORG),strTmp4); callback(2,0,strTmp4); if((result =SlaveReorg(callback)) != SUCCESS) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp5); callback(2,0,strTmp5); return !SUCCESS; } p2p_delay(); UINT32 addr = 0x0; if(pslave_reorg_list[0].type == 2) //transfer bootloader { addr = 0x0; } else { #if (SYS_PROJECT_FE == PROJECT_FE_DVBT && SYS_SDRAM_SIZE == 2) addr = 0x7800; #else #if (SYS_CHIP_MODULE == ALI_M3327C && SYS_SDRAM_SIZE == 2) //addr = 0xc000; //add logo data, so the address is changed addr = 0x8000; #else addr = pslave_list[0].offset; #endif #endif } if((result = cmd_address(addr)) != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp6); callback(2, 0, strTmp6); return !SUCCESS; } trans_size = 0; prog = 0; ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TRANSFERING_DATA),strTmp7); callback(3,0,strTmp7); #if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2) pan_display(LV_pPanDev, "u0 ", 4); #endif for(i=0; i<slave_reorg_number;i++) { p2p_delay(); if(pslave_reorg_list[i].type==1) //move { if(i==0) continue; result = command_move(pslave_reorg_list[i].index, pslave_reorg_list[i].offset, callback); if(result != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MOVE_FAILED_TRY_AGAIN),strTmp8); callback(2,0,strTmp8); return !SUCCESS; } } else //transfer { result = command_transfer(pslave_reorg_list[i].index,callback); if(result != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_TRANSFER_FAILED_TRY_AGAIN),strTmp9); callback(2,0,strTmp9); return !SUCCESS; } } } #if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2) pan_display(LV_pPanDev, "100 ", 4); #endif p2p_delay(); /* Send command to burn flash */ ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_MSG_UPGRADE_BURN_FLASH),strTmp10); callback(3,0,strTmp10); pan_display(LV_pPanDev, "burn ", 4); #if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2) pan_display(LV_pPanDev, "b0 ", 4); #endif if((result = command_burn_new(callback, bBurn)) != SUCCESS) { pan_display_error(result); ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp11); callback(2,0,strTmp11); return !SUCCESS; } #if (SYS_CHIP_MODULE != ALI_M3327C || SYS_SDRAM_SIZE != 2) pan_display(LV_pPanDev, "100 ", 4); #endif pan_display(LV_pPanDev, "end ", 4); /*reboot slaver*/ if(bReboot) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_REBOOTING_SLAVER),strTmp12); callback(2,0,strTmp12); if(command_reboot(callback) != SUCCESS) { ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_FAILED_TRY_AGAIN),strTmp13); callback(2,0,strTmp13); return !SUCCESS; } } ComUniStrToAsc((UINT8 *)OSD_GetUnicodeString(RS_UPDATE_SUCCESSFUL),strTmp14); callback(2, 0, strTmp14); return SUCCESS; }