Exemple #1
0
int main(int c, char **v)
{
	usb_init();
	usb_dev_handle *handle = device_open();
	
	if(handle == NULL){
		return 0;
	}
	switch(c){
	case 1:
		echo(handle);
		printf("work time %3.1f second\n", ((double) clock() / (double) CLOCKS_PER_SEC));
		fflush(stdout);
		system("pause");
		break;
	case 2:
		firmware_version(handle);
		break;
	case 3:
		switch(v[1][0]){
		case 'w':
			firmware_update(handle, v[2]);
			break;
		case 'r':
			firmware_download(handle, v[2]);
			break;
		case 'v':
			firmware_verify(handle, v[2]);
			break;
		case 'p':{
			if(DEBUG == 0){
				break;
			}
			int i = 0x1000;
			const char *ret = "test ok";
			while(i != 0){
				if(ppu_read(handle, i) == false){
					ret = "test ng";
					break;
				}
				if((i+1) % 100 == 0){
					fprintf(stderr, "\r%05d", i+1);
					fflush(stderr);
				}
				i--;
			}
			puts(ret);
			}break;
		case 'd':
			if(DEBUG == 1){
				write_memory(handle, REQUEST_FIRMWARE_PROGRAM, 0x200, 0x0000, 0, NULL);
			}
			break;
		}
		break;
	}
	usb_close(handle);
	return 0;
}
Exemple #2
0
eMFSRet_t MFS_ISC_update(void)
{
	extern void ts_power_enable(int en);
	eMFSRet_t ret;
	unsigned char paneltype, tspcomp, setcomp, redownload = 0;
	int i;
	MFS_I2C_set_slave_addr(mfs_i2c_slave_addr);

ENTRANCE:

	MFS_ms_delay(50);

#ifdef CONFIG_MACH_KYLE_I
	buf =& MELFAS_binary;
#else
	ret= check_panel_type(&paneltype);
	if (ret != MRET_SUCCESS && !redownload)
	{
		MFS_TSP_reboot();
		if (mass_erase() != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;

#ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2
		if (firmware_write(G2_BINARY) != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;			
#else
		if (firmware_write(G1F_BINARY) != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;
#endif

		MFS_TSP_reboot();
		if (enter_ISC_mode() != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;

#ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2
		if (firmware_verify(G2_BINARY) != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;
#else
		if (firmware_verify(G1F_BINARY) != MRET_SUCCESS)
			goto MFS_ISC_UPDATE_FINISH;
#endif

		MFS_TSP_reboot();
		redownload = 1;
		goto ENTRANCE;
	}
	else if (ret != MRET_SUCCESS)
	{
		goto MFS_ISC_UPDATE_FINISH;
	}

	if(paneltype == 0x4d)
	{
		buf = &G1M_BINARY;
		printk(KERN_ERR "<MELFAS> buf_G1M\n");
	}
	else if(paneltype == 0x46)
	{
		buf =& G1F_BINARY;
		printk(KERN_ERR "<MELFAS> buf_G1F\n");
	}
#ifdef CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2
	else if(paneltype == 0x58)
	{
		buf =& G2_BINARY;
		printk(KERN_ERR "<MELFAS> buf_G2\n");
		//goto MFS_ISC_UPDATE_FINISH;
	}
#endif
#endif

	// TSP HW Revision
	if( get_tsp_compatibility(&tspcomp) != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;


	printk(KERN_ERR "<MELFAS> paneltype=%c\n", paneltype);
	printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp);
#if defined(CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2)
	if((paneltype == 0x4d && tspcomp > 0x0E) 
		|| (paneltype == 0x46 && ( tspcomp < 0x0F || tspcomp > 0x14 )) 
		|| (paneltype == 0x58 && ( tspcomp < 0x15 || tspcomp > 0x19 )) )
#else
	if((paneltype == 0x4d && tspcomp > 0x0E) || (paneltype == 0x46 && tspcomp <= 0x0E))
#endif
		goto START_DOWNLOAD;

	get_main_compatibility(buf, &setcomp);

#ifdef CONFIG_MACH_KYLE_I
	setcomp = TSP_SET_COMP;
	printk(KERN_ERR "<MELFAS> setcomp=%x\n", setcomp);
	printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp);
	if(tspcomp != setcomp){
		goto MFS_ISC_UPDATE_FINISH;		
	}
#else
#if defined(CONFIG_TOUCHSCREEN_MELFAS_KYLE_G2)
	if( paneltype == 0x58 )
	{
		setcomp = TSP_SET_COMP_G2;
		printk(KERN_ERR "<MELFAS> setcomp=%x\n", setcomp);
		printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp);
		if(tspcomp != setcomp)
			goto MFS_ISC_UPDATE_FINISH;
	}
	else
#endif		
	{
		printk(KERN_ERR "<MELFAS> setcomp=%c\n", setcomp);
		printk(KERN_ERR "<MELFAS> tspcomp=%x\n", tspcomp);	
		if(tspcomp != (setcomp-55))
			goto MFS_ISC_UPDATE_FINISH;
	}
#endif

	if (check_firmware_version(0, buf) != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;

START_DOWNLOAD:
	if (mass_erase() != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;

	ret = firmware_write(buf);
	if (ret != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;

	MFS_TSP_reboot();
	printk(KERN_ERR "<MELFAS> TOUCH IC REBOOT!!!\n");
	
	if (enter_ISC_mode() != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;

	if (firmware_verify(buf) != MRET_SUCCESS)
		goto MFS_ISC_UPDATE_FINISH;

	printk(KERN_ERR "<MELFAS> FIRMWARE_UPDATE_FINISHED!!!\n\n");

MFS_ISC_UPDATE_FINISH:

	MFS_TSP_reboot();
	printk(KERN_ERR "<MELFAS> TOUCH IC REBOOT2!!!\n");
	check_firmware_version(1, buf);

	MFS_I2C_set_slave_addr(mfs_i2c_slave_addr);

	return ret;
}