开发板作模拟网卡(RNDIS)与串口

首先配置内核  , 进入LINUX内核文件夹,输入命令

  make menuconfig

 

对内核做如下配置

选择 Device Drivers -->

          [*]USB support -->

               <*>USB Gadget Support -->

                        <M>USB Gadget Drivers

                         ....................................

                        <M>Ethernet Gadget (with CDC Ethernet support)

                         [*] RNDIS support

                         ...................................

                        <M>CDC Composite Device (Ethernet and ACM)

 

编译内核

make uImage ARCH=arm CROSS_COMPILE=arm-linux-

 

配置完之后,插在windows下,没反应。原因是对应的USB_EN引脚没有置高电平,所以检测不了。

 

下面对内核做修改

static struct platform_device *smdk2440_devices[] __initdata = {
 &s3c_device_usb,
 /**add to use mmc/sd**/
 &s3c_device_sdi,
 &s3c_device_lcd,
 &s3c_device_wdt,
 &s3c_device_i2c0,
 &s3c_device_iis,
 &s3c_device_usbgadget,  /*USB gadget device设备登记*/
};

 

/*add to use usb*/
#include <plat/pll.h>
#include <mach/regs-clock.h>
#include <asm/delay.h>
static void gt2440_udc_pullup(enum s3c2410_udc_cmd_e cmd)
{
 u8 *s3c2410_pullup_info[] = {
            " ",
            "Pull-up enable",
            "Pull-up disable",
            "UDC reset, in case of"
        };
 s3c2410_gpio_cfgpin(S3C2410_GPG12,S3C2410_GPIO_OUTPUT);
  printk("smdk2410_udc: %s/n",s3c2410_pullup_info[cmd]);
 switch (cmd)
        {
            case S3C2410_UDC_P_ENABLE :
            s3c2410_gpio_setpin(S3C2410_GPG12, 1);   //set gpg12 output HIGH
                break;
            case S3C2410_UDC_P_DISABLE :
                s3c2410_gpio_setpin(S3C2410_GPG12, 0);   //set gpg12 output LOW
                break;
            case S3C2410_UDC_P_RESET :
                //FIXME!!!
                break;
            default:
                break;
        }
}

static struct s3c2410_udc_mach_info gt2440_udc_cfg __initdata = {
        .udc_command    = gt2440_udc_pullup,
    };

 

static void __init smdk2440_map_io(void)
{
 s3c24xx_init_io(smdk2440_iodesc, ARRAY_SIZE(smdk2440_iodesc));

 /*add*/
 //s3c24xx_init_clocks(16934400);
 s3c24xx_init_clocks(12000000);
 s3c24xx_init_uarts(smdk2440_uartcfgs, ARRAY_SIZE(smdk2440_uartcfgs));
}

 

就可以了,下面在windows下就能检测

将内核模块g_serial.ko或者g_ether.ko放到文件系统里,开启后加载

insmod g_serial.ko

echo hello > /dev/ttyGS0

或者

insmod g_ether.ko

你可能感兴趣的:(c,windows,struct,cmd,output,linux内核)