static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- if (unLength >= MELFAS_FIRMWARE_MAX_SIZE) { nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" - Starting download...\n"); #endif //--------------------------------- // Make it ready //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Ready\n"); #endif mcsdl_set_ready(); //--------------------------------- // Erase Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Erase\n"); #endif printk(" > Erase - Start \n"); preempt_disable(); nRet = mcsdl_erase_flash(IdxNum); preempt_enable(); printk(" > Erase- End \n"); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; //goto MCSDL_DOWNLOAD_FINISH; //lcs_test //--------------------------------- // Program Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Program "); #endif preempt_disable(); nRet = mcsdl_program_flash((UINT8*) pBianry, (UINT16) unLength, IdxNum); preempt_enable(); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Verify flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Verify "); #endif preempt_disable(); nRet = mcsdl_verify_flash((UINT8*) pBianry, (UINT16) unLength, IdxNum); preempt_enable(); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; nRet = MCSDL_RET_SUCCESS; MCSDL_DOWNLOAD_FINISH: #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); // Show result #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Rebooting\n"); printk(" - Fin.\n\n"); #endif mcsdl_reboot_mcs(); return nRet; }
int mcsdl_download_binary_file(void) { int nRet; UINT8 *pBinary = NULL; UINT16 nBinary_length =0; //================================================== // // 1. Read '.bin file' // 2. *pBinary : Binary data // nBinary_length : Firmware size // 3. Run mcsdl_download( pBinary, nBinary_length); // //================================================== #if 0 // TO DO : File Process & Get file Size(== Binary size) // This is just a simple sample FILE *fp; INT nRead; //------------------------------ // Open a file //------------------------------ if( fopen( fp, "MELFAS_FIRMWARE.bin", "rb" ) == NULL ){ return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Get Binary Size //------------------------------ fseek( fp, 0, SEEK_END ); nBinary_length = (UINT16)ftell(fp); //------------------------------ // Memory allocation //------------------------------ pBinary = (UINT8*)malloc( (INT)nBinary_length ); if( pBinary == NULL ){ return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Read binary file //------------------------------ fseek( fp, 0, SEEK_SET ); nRead = fread( pBinary, 1, (INT)nBinary_length, fp ); // Read binary file if( nRead != (INT)nBinary_length ){ fclose(fp); // Close file if( pBinary != NULL ) // free memory alloced. free(pBinary); return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Close file //------------------------------ fclose(fp); #endif if( pBinary != NULL && nBinary_length > 0 && nBinary_length < 32*1024 ){ #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_mcs7000_delay(MCSDL_DELAY_100US); #endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer //------------------------ // Run Download //------------------------ nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength ); MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer }else{ nRet = MCSDL_RET_WRONG_BINARY; } #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); #endif #if 0 if( pData != NULL ) // free memory alloced. free(pData); #endif return ( nRet == MCSDL_RET_SUCCESS ); }
int mcsdl_download_binary_file(void) { int nRet; int i; UINT8 *pBinary[2] = { NULL, NULL }; UINT16 nBinary_length[2] = { 0, 0 }; UINT8 IdxNum = MELFAS_2CHIP_DOWNLOAD_ENABLE; //================================================== // // 1. Read '.bin file' // 2. *pBinary[0] : Binary data(Master) // *pBinary[1] : Binary data(Slave) // nBinary_length[0] : Firmware size(Master) // nBinary_length[1] : Firmware size(Slave) // 3. Run mcsdl_download( pBinary[IdxNum], nBinary_length[IdxNum], IdxNum); // IdxNum : 0 (Master Chip Download) // IdxNum : 1 (2Chip Download) // //================================================== #if 0 // TO DO : File Process & Get file Size(== Binary size) // This is just a simple sample FILE *fp; INT nRead; //------------------------------ // Open a file //------------------------------ if( fopen( fp, "MELFAS_FIRMWARE.bin", "rb" ) == NULL ) { return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Get Binary Size //------------------------------ fseek( fp, 0, SEEK_END ); nBinary_length = (UINT16)ftell(fp); //------------------------------ // Memory allocation //------------------------------ pBinary = (UINT8*)malloc( (INT)nBinary_length ); if( pBinary == NULL ) { return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Read binary file //------------------------------ fseek( fp, 0, SEEK_SET ); nRead = fread( pBinary, 1, (INT)nBinary_length, fp ); // Read binary file if( nRead != (INT)nBinary_length ) { fclose(fp); // Close file if( pBinary != NULL ) // free memory alloced. free(pBinary); return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Close file //------------------------------ fclose(fp); #endif #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); #endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer for (i = 0; i <= IdxNum; i++) { if (pBinary[i] != NULL && nBinary_length[i] > 0 && nBinary_length[i] < 32 * 1024) { //------------------------ // Run Download //------------------------ nRet = mcsdl_download((const UINT8 *) pBinary[i], (const UINT16) nBinary_length[i], i); } else { nRet = MCSDL_RET_WRONG_BINARY; } } MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); #endif #if 0 if( pData != NULL ) // free memory alloced. free(pData); #endif return (nRet == MCSDL_RET_SUCCESS); }
int mcsdl_download_binary_file(char *fileName) { int ret; UINT8 *pData = NULL; UINT16 nBinary_length =0; //================================================== // // Porting section 7. File process // // 1. Read '.bin file' // 2. When make binary buffer, make Size 'EVEN'. // Add 0xFF on last if binary size is odd. // 3. Run mcsdl_download_binary_data(); // //================================================== #if 1 // TO DO : File Process & Get file Size(== Binary size) // This is just a simple sample FILE *fp; INT nRead; //------------------------------ // Open a file //------------------------------ if( fopen( fp, fileName, "rb" ) == NULL ){ return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Get Binary Size //------------------------------ fseek( fp, 0, SEEK_END ); nBinary_length = (UINT16)ftell(fp); //------------------------------ // Memory allocation //------------------------------ pData = (UINT8*)malloc( (INT)nBinary_length + (nBinary_length%2) ); if( pData == NULL ){ return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Read binary file //------------------------------ fseek( fp, 0, SEEK_SET ); nRead = fread( pData, 1, (INT)nBinary_length, fp ); // Read binary file if( nRead != (INT)nBinary_length ){ fclose(fp); // Close file if( pData != NULL ) // free memory alloced. free(pData); return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Close file //------------------------------ fclose(fp); #endif if( pData != NULL && nBinary_length > 0 && nBinary_length < 62*1024 ){ MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer ret = mcsdl_download( (const UINT8 *)pData, (const UINT16)nBinary_length ); MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer }else{ ret = MCSDL_RET_WRONG_PARAMETER; } #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( ret ); #endif #if 0 if( pData != NULL ) // free memory alloced. free(pData); #endif return ( ret == MCSDL_RET_SUCCESS ); }
static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum ) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- // wcjeong - modified //if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ){ if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ){ dbg("ISP - mcsdl firmware size error: %u(0x%X) [limit: %u(0x%X)] \n", unLength, unLength, MELFAS_FIRMWARE_MAX_SIZE, MELFAS_FIRMWARE_MAX_SIZE ); nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } #if MELFAS_ENABLE_DBG_PROGRESS_PRINT dbg(" - Starting ISP download...\n"); #endif //--------------------------------- // Make it ready //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT dbg(" > Ready\n"); #endif mcsdl_set_ready(); //--------------------------------- // Erase Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT dbg(" > Erase: %d\n", IdxNum); #endif nRet = mcsdl_erase_flash(IdxNum); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Program Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Program "); #endif // if(IdxNum > 0) // mcsdl_set_ready(); nRet = mcsdl_program_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Verify flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Verify "); #endif nRet = mcsdl_verify_flash((UINT8*)pBianry, (UINT16)unLength, IdxNum); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; nRet = MCSDL_RET_SUCCESS; MCSDL_DOWNLOAD_FINISH : #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); // Show result #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT dbg(" > Rebooting\n"); dbg(" - Fin.\n\n"); #endif mcsdl_reboot_mcs(); return nRet; }
int mms100_ISP_download_binary_data(int dl_mode) { int nRet = 0; int retry_cnt = 0; /* //get gpio info _S printk("[JHLog] SDA GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d", mt_get_gpio_mode(GPIO_I2C0_SDA_PIN), mt_get_gpio_dir(GPIO_I2C0_SDA_PIN), mt_get_gpio_pull_enable(GPIO_I2C0_SDA_PIN), mt_get_gpio_pull_select(GPIO_I2C0_SDA_PIN) ); printk("[JHLog] SCA GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d", mt_get_gpio_mode(GPIO_I2C0_SCA_PIN), mt_get_gpio_dir(GPIO_I2C0_SCA_PIN), mt_get_gpio_pull_enable(GPIO_I2C0_SCA_PIN), mt_get_gpio_pull_select(GPIO_I2C0_SCA_PIN) ); printk("[JHLog] EINT GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d", mt_get_gpio_mode(GPIO_CTP_EINT_PIN), mt_get_gpio_dir(GPIO_CTP_EINT_PIN), mt_get_gpio_pull_enable(GPIO_CTP_EINT_PIN), mt_get_gpio_pull_select(GPIO_CTP_EINT_PIN) ); //get gpio info _E */ //set GPIO SDA/SCA/EINT_S // #if 0 // ori mt_set_gpio_mode(GPIO_I2C0_SDA_PIN, GPIO_I2C0_SDA_PIN_M_GPIO); mt_set_gpio_dir(GPIO_I2C0_SDA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C0_SDA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C0_SDA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_I2C0_SCA_PIN, GPIO_I2C0_SCA_PIN_M_GPIO); mt_set_gpio_dir(GPIO_I2C0_SCA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C0_SCA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C0_SCA_PIN, GPIO_PULL_DOWN); mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, 2); #else // blood V3 RevA test mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_GPIO); mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_GPIO); mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_DOWN); mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO); mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, 2); #endif // //set GPIO SDA/SCA/EINT_E #if 0 #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); #endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer #endif //------------------------ // Run Download //------------------------ //nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0); //printk("mmsdownload ret =%d", nRet); for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) { if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0); else //MELFAS_ISC_DOWNLOAD { // nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 0); } #if MELFAS_2CHIP_DOWNLOAD_ENABLE if(!nRet) { if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength, 1); // Slave Binary data download else //MELFAS_ISC_DOWNLOAD // nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 1); } #endif if (!nRet) break; } MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer //Restore GPIO Setting_S // #if 0 // ori mt_set_gpio_mode(GPIO_I2C0_SDA_PIN, GPIO_I2C0_SDA_PIN_M_SDA); // joohyung.lee mt_set_gpio_dir(GPIO_I2C0_SDA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C0_SDA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C0_SDA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_I2C0_SCA_PIN, GPIO_I2C0_SCA_PIN_M_SCL); // joohyung.lee mt_set_gpio_dir(GPIO_I2C0_SCA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C0_SCA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C0_SCA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); // joohyung.lee mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); #else // blood V3 RevA test mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_SDA); // joohyung.lee mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_SCL); // joohyung.lee mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT); mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_UP); mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT); // joohyung.lee mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN); mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE); mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP); #endif // //Restore GPIO Setting_E fw_error: if (nRet) { mcsdl_erase_flash(0); mcsdl_erase_flash(1); } return nRet; } int mms100_ISP_download_binary_file(void) { int nRet; int i; UINT8 *pBinary[2] = {NULL,NULL}; UINT16 nBinary_length[2] ={0,0}; UINT8 IdxNum = MELFAS_2CHIP_DOWNLOAD_ENABLE; //================================================== // // 1. Read '.bin file' // 2. *pBinary[0] : Binary data(Core + Private Custom) // *pBinary[1] : Binary data(Public Custom) // nBinary_length[0] : Firmware size(Core + Private Custom) // nBinary_length[1] : Firmware size(Public Custom) // 3. Run mcsdl_download( pBinary[IdxNum], nBinary_length[IdxNum], IdxNum); // IdxNum : 0 (Master Chip Download) // IdxNum : 1 (2Chip Download) // //================================================== #if 0 // TO DO : File Process & Get file Size(== Binary size) // This is just a simple sample FILE *fp; INT nRead; //------------------------------ // Open a file //------------------------------ if (fopen(fp, "MELFAS_FIRMWARE.bin", "rb") == NULL) { return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Get Binary Size //------------------------------ fseek( fp, 0, SEEK_END ); nBinary_length = (UINT16)ftell(fp); //------------------------------ // Memory allocation //------------------------------ pBinary = (UINT8*)malloc( (INT)nBinary_length ); if (pBinary == NULL) { return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Read binary file //------------------------------ fseek( fp, 0, SEEK_SET ); nRead = fread( pBinary, 1, (INT)nBinary_length, fp ); // Read binary file if (nRead != (INT)nBinary_length) { fclose(fp); // Close file if (pBinary != NULL) // free memory alloced. free(pBinary); return MCSDL_RET_FILE_ACCESS_FAILED; } //------------------------------ // Close file //------------------------------ fclose(fp); #endif #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); #endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer for (i = 0;i <= IdxNum;i++) { if (pBinary[0] != NULL && nBinary_length[0] > 0 && nBinary_length[0] < MELFAS_FIRMWARE_MAX_SIZE) { //------------------------ // Run Download //------------------------ nRet = mcsdl_download((const UINT8 *)pBinary[0], (const UINT16)nBinary_length[0], i); } else { nRet = MCSDL_RET_WRONG_BINARY; } } MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); #endif return ( nRet == MCSDL_RET_SUCCESS ); }
static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum ) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- if( unLength > MELFAS_FIRMWARE_MAX_SIZE ){ nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" - Starting download...\n"); #endif //--------------------------------- // Make it ready //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Ready start \n"); #endif mcsdl_set_ready(); // printk("[JHLog]set ready finished \n"); //--------------------------------- // Erase Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Erase start : IdxNum = %d\n", IdxNum); #endif nRet = mcsdl_erase_flash(IdxNum); printk(" > Erase end %d\n", nRet); //return 0; if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; printk(" > Erase succes\n"); //--------------------------------- // Program Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Program "); #endif // if(IdxNum > 0) // mcsdl_set_ready(); nRet = mcsdl_program_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Verify flash //--------------------------------- // #if 0 // Desc : skip verify to reduce down load time. #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Verify "); #endif nRet = mcsdl_verify_flash((UINT8*)pBianry, (UINT16)unLength, IdxNum); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; #endif // nRet = MCSDL_RET_SUCCESS; MCSDL_DOWNLOAD_FINISH : #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); // Show result #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Rebooting\n"); printk(" - Fin.\n\n"); #endif mcsdl_reboot_mcs(); return nRet; }
static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum ) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ){ nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" - Starting download...\n"); #endif //--------------------------------- // Make it ready //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Ready\n"); #endif mcsdl_set_ready(); // mcsdl_delay(MCSDL_DELAY_1MS); //--------------------------------- // Erase Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Erase\n"); #endif nRet = mcsdl_erase_flash(IdxNum); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; // mcsdl_delay(MCSDL_DELAY_1MS); //--------------------------------- // Program Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Program "); #endif // if(IdxNum > 0) // mcsdl_set_ready(); nRet = mcsdl_program_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; // mcsdl_delay(MCSDL_DELAY_1MS); //--------------------------------- // Verify flash //--------------------------------- /*if (IdxNum == 0)*/ { #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Verify=== "); #endif nRet = mcsdl_verify_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; } // mcsdl_delay(MCSDL_DELAY_1MS); nRet = MCSDL_RET_SUCCESS; MCSDL_DOWNLOAD_FINISH : #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); // Show result #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Rebooting\n"); printk(" - Fin.\n\n"); #endif if(IdxNum == 0) mcsdl_reboot_mcs(); else { MCSDL_RESETB_SET_LOW(); MCSDL_RESETB_SET_OUTPUT(1); mcsdl_delay(MCSDL_DELAY_25MS); // Delay for Stable VDD MCSDL_RESETB_SET_INPUT(); MCSDL_VDD_SET_HIGH(); } return nRet; }
int mcsdl_download_binary_data(int hw_ver) { int ret; #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); #endif //MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. //MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer //------------------------ // Run Download //------------------------ uint8_t* pfirmware = NULL; size_t firmware_size = 0; #ifdef TSP_SDCARD_UPDATE uint8_t fromsdcard = false; if((firmware_size=tsp_firmware_load("/sdcard/ts/firmware/_ts_firmware_.bin", &pfirmware)) > 1024) { printk("[TOUCH] firmware loaded from sdcard (%d)\n",firmware_size); printk("[TOUCH] %02x %02x %02x %02x \n", pfirmware[0], pfirmware[1], pfirmware[2], pfirmware[3]); printk("[TOUCH] %02x %02x %02x %02x \n", pfirmware[4], pfirmware[5], pfirmware[6], pfirmware[7]); fromsdcard = true; } else #endif { pfirmware = MELFAS_binary_V06; firmware_size = MELFAS_binary_nLength_V06; printk(KERN_WARNING "[TOUCH] Updated H/W version: 0x%X. firmware is selected![firmware_size:0x%X.]\n", hw_ver, firmware_size); } if(firmware_size >= 0 && pfirmware != NULL) { printk("###############################\n"); printk("[TOUCH] Firmware Download START\n"); //printk("system rev is %x\n", system_rev); //Quattro hasn't system_rev value ret = mcsdl_download( pfirmware, firmware_size ); #ifdef TSP_SDCARD_UPDATE if(fromsdcard) tsp_firmware_unload(pfirmware); #endif printk("[TOUCH] Firmware Download END\n"); printk("#############################\n"); } //MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. //MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( ret ); // Show result #endif return ( ret == MCSDL_RET_SUCCESS ); }
static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum ) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- if( unLength > MELFAS_FIRMWARE_MAX_SIZE ){ nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" - Starting download...\n"); #endif //--------------------------------- // Make it ready //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Ready\n"); #endif mcsdl_set_ready(); //--------------------------------- // Erase Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("\n > Erase\n"); #endif nRet = mcsdl_erase_flash(IdxNum); //printk(" ------ mcsdl_erase_flash is ...%d ------\n ", nRet); //----------------------------------------------------- //@@@ [WONJINHAN : [email protected] - 2011.11.08] //return nRet; //----------------------------------------------------- if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Program Flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("\n > Program "); #endif // if(IdxNum > 0) // mcsdl_set_ready(); nRet = mcsdl_program_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Verify flash //--------------------------------- #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("\n > Verify "); #endif nRet = mcsdl_verify_flash((UINT8*)pBianry, (UINT16)unLength, IdxNum); if (nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; nRet = MCSDL_RET_SUCCESS; MCSDL_DOWNLOAD_FINISH : #if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); // Show result #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Rebooting\n"); printk(" - Fin.\n\n"); #endif mcsdl_reboot_mcs(); return nRet; }