⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 otgsetup.c

📁 linux下的usb开发
💻 C
字号:
/************************************************************************ * Philips ISP1362 otg demo setup * * (c) 2002 Koninklijke Philips Electronics N.V., All rights reserved *  * This  source code and any compilation or derivative thereof is the * proprietary information of Koninklijke Philips Electronics N.V. * and is confidential in nature. * Under no circumstances is this software to be exposed to or placed * under an Open Source License of any type without the expressed * written permission of Koninklijke Philips Electronics N.V. * * File Name:	otgsetup.c * * History:	 * *	Version	Date		Author		Comments * ------------------------------------------------- * 	1.0		09/23/02	SYARRA		Initial Creation * * Note: use tab space 4 ************************************************************************/#include<fcntl.h>#include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<string.h>#include<sys/ioctl.h>#include<errno.h>#include "otgtool.h"int main() {	char	command[128];	int		fd;	FILE	*fp;	fd = open(OTG_DEV_DIR, O_RDONLY);	if(fd>0) {		close(fd);		printf("otgsetup: deleting '%s' directory\n",OTG_DEV_DIR);		sprintf(command,"rm -r -f %s\n",OTG_DEV_DIR);		system(command);	}	fd = open(LOCAL_OTG_DISK, O_RDONLY);	if(fd>0) {		close(fd);		printf("otgsetup: deleting '%s' directory\n",LOCAL_OTG_DISK);		sprintf(command,"rm -r -f %s\n",LOCAL_OTG_DISK);		system(command);	}	printf("otgsetup: creating '%s' directory\n",LOCAL_OTG_DISK);	sprintf(command,"mkdir %s\n",LOCAL_OTG_DISK);	system(command);	fd = open(RMT_OTG_DISK, O_RDONLY);	if(fd>0) {		close(fd);		printf("otgsetup: deleting '%s' directory\n",RMT_OTG_DISK);		sprintf(command,"rm -r -f %s\n",RMT_OTG_DISK);		system(command);	}	printf("otgsetup: creating '%s' directory\n",RMT_OTG_DISK);	sprintf(command,"mkdir %s\n",RMT_OTG_DISK);	system(command);	printf("otgsetup: creating '%s' directory\n",OTG_DEV_DIR);	sprintf(command,"mkdir %s\n",OTG_DEV_DIR);	system(command);	printf("otgsetup: creating otg local disk file '%s'\n",LOCAL_OTG_DEV_FILE);	sprintf(command,"dd if=/dev/zero of=%s bs=%d count=%d\n",LOCAL_OTG_DEV_FILE,BLOCK_SIZE,(LOGICAL_BLOCKS+4));	system(command);	printf("otgsetup: creating temporary data file 'tempOtgData'\n");	fp = fopen("tempOtgData","w");	fprintf(fp,"x\nh\n1\nc\n1024\ns\n%d\nr\nn\np\n1\n\n\np\nw\n",LINUX_UNIT_SIZE);	fclose(fp);	printf("otgsetup: partitioning the local otg disk\n");	sprintf(command,"/sbin/fdisk %s < tempOtgData \n",LOCAL_OTG_DEV_FILE);	system(command);	printf("otgsetup: removing temporary data file 'tempOtgData'\n");	strcpy(command,"rm -f tempOtgData\n");		system(command);	sprintf(command,"dd if=%s of=%s1 bs=%d skip=%d\n",LOCAL_OTG_DEV_FILE,LOCAL_OTG_DEV_FILE,BLOCK_SIZE,LINUX_UNIT_SIZE);	system(command);	printf("otgsetup: formatting local otg disk in 'dos' file system\n");	sprintf(command,"/sbin/mkdosfs -I %s1\n",LOCAL_OTG_DEV_FILE);	system(command);	sprintf(command,"dd if=%s1 of=%s bs=%d seek=%d\n",LOCAL_OTG_DEV_FILE,LOCAL_OTG_DEV_FILE,BLOCK_SIZE,LINUX_UNIT_SIZE);	system(command);	printf("otgsetup: Creating OTG fsm device file '%s'\n",OTG_FSM_FILE);	sprintf(command, "mknod %s c %d 0\n",OTG_FSM_FILE,USB_OTG_MAJOR);	system(command);	printf("otgsetup: Creating OTG usb device file '%s'\n","/dev/usb/otg/otgdev0");	sprintf(command, "mknod %s c %d 0\n",USBSLAVE_DEV_FILE,DEVMSCD_MAJOR);	system(command);	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -