From b99ca2cdde4e728308152028db9e67f2c33dde8f Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 9 Apr 2014 01:16:49 +0100 Subject: [PATCH] stmhal: Add windows cdc .inf driver to flash filesystem. --- stmhal/main.c | 13 ++++++- stmhal/pybcdc.h | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 stmhal/pybcdc.h diff --git a/stmhal/main.c b/stmhal/main.c index e5ba67dc1..64d9022ae 100644 --- a/stmhal/main.c +++ b/stmhal/main.c @@ -133,6 +133,10 @@ static const char fresh_main_py[] = "# main.py -- put your code here!\n" ; +static const char fresh_pybcdc_inf[] = +#include "pybcdc.h" +; + int main(void) { // TODO disable JTAG @@ -206,7 +210,9 @@ soft_reset: } HAL_Delay(20); if (i % 30 == 29) { - reset_mode = (reset_mode + 1) & 7; + if (++reset_mode > 3) { + reset_mode = 1; + } led_state(2, reset_mode & 1); led_state(3, reset_mode & 2); led_state(4, reset_mode & 4); @@ -310,6 +316,11 @@ soft_reset: // TODO check we could write n bytes f_close(&fp); + // create .inf driver file + f_open(&fp, "0:/pybcdc.inf", FA_WRITE | FA_CREATE_ALWAYS); + f_write(&fp, fresh_pybcdc_inf, sizeof(fresh_pybcdc_inf) - 1 /* don't count null terminator */, &n); + f_close(&fp); + // keep LED on for at least 200ms sys_tick_wait_at_least(start_tick, 200); led_state(PYB_LED_R2, 0); diff --git a/stmhal/pybcdc.h b/stmhal/pybcdc.h new file mode 100644 index 000000000..eda2aa0d9 --- /dev/null +++ b/stmhal/pybcdc.h @@ -0,0 +1,92 @@ +"; Windows USB CDC ACM Setup File\n" +"; Based on INF files which were:\n" +"; Copyright (c) 2000 Microsoft Corporation\n" +"; Copyright (C) 2007 Microchip Technology Inc.\n" +"; Likely to be covered by the MLPL as found at:\n" +"; .\n" +"\n" +"[Version]\n" +"Signature=\"$Windows NT$\"\n" +"Class=Ports\n" +"ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}\n" +"Provider=%MFGNAME%\n" +"LayoutFile=layout.inf\n" +"DriverVer=03/11/2010,5.1.2600.3\n" +"\n" +"[Manufacturer]\n" +"%MFGNAME%=DeviceList, NTamd64\n" +"\n" +"[DestinationDirs]\n" +"DefaultDestDir=12\n" +"\n" +";---------------------------------------------------------------------\n" +"; Windows 2000/XP/Server2003/Vista/Server2008/7 - 32bit Sections\n" +"\n" +"[DriverInstall.nt]\n" +"include=mdmcpq.inf\n" +"CopyFiles=DriverCopyFiles.nt\n" +"AddReg=DriverInstall.nt.AddReg\n" +"\n" +"[DriverCopyFiles.nt]\n" +"usbser.sys,,,0x20\n" +"\n" +"[DriverInstall.nt.AddReg]\n" +"HKR,,DevLoader,,*ntkern\n" +"HKR,,NTMPDriver,,usbser.sys\n" +"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\n" +"\n" +"[DriverInstall.nt.Services]\n" +"AddService=usbser, 0x00000002, DriverService.nt\n" +"\n" +"[DriverService.nt]\n" +"DisplayName=%SERVICE%\n" +"ServiceType=1\n" +"StartType=3\n" +"ErrorControl=1\n" +"ServiceBinary=%12%\\usbser.sys\n" +"\n" +";---------------------------------------------------------------------\n" +"; Windows XP/Server2003/Vista/Server2008/7 - 64bit Sections\n" +"\n" +"[DriverInstall.NTamd64]\n" +"include=mdmcpq.inf\n" +"CopyFiles=DriverCopyFiles.NTamd64\n" +"AddReg=DriverInstall.NTamd64.AddReg\n" +"\n" +"[DriverCopyFiles.NTamd64]\n" +"usbser.sys,,,0x20\n" +"\n" +"[DriverInstall.NTamd64.AddReg]\n" +"HKR,,DevLoader,,*ntkern\n" +"HKR,,NTMPDriver,,usbser.sys\n" +"HKR,,EnumPropPages32,,\"MsPorts.dll,SerialPortPropPageProvider\"\n" +"\n" +"[DriverInstall.NTamd64.Services]\n" +"AddService=usbser, 0x00000002, DriverService.NTamd64\n" +"\n" +"[DriverService.NTamd64]\n" +"DisplayName=%SERVICE%\n" +"ServiceType=1\n" +"StartType=3\n" +"ErrorControl=1\n" +"ServiceBinary=%12%\\usbser.sys\n" +"\n" +";---------------------------------------------------------------------\n" +"; Vendor and Product ID Definitions\n" +"\n" +"[SourceDisksFiles]\n" +"[SourceDisksNames]\n" +"[DeviceList]\n" +"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00\n" +"\n" +"[DeviceList.NTamd64]\n" +"%DESCRIPTION%=DriverInstall, USB\\VID_0483&PID_5740&MI_00\n" +"\n" +";---------------------------------------------------------------------\n" +"; String Definitions\n" +"\n" +"[Strings]\n" +"MFGFILENAME=\"pybcdc\"\n" +"MFGNAME=\"Micro Python\"\n" +"DESCRIPTION=\"Pyboard USB Comm Port\"\n" +"SERVICE=\"USB Serial Driver\"\n"