Note: Use an xHCI debug port for Kernel debugging on Windows/Linux

xHCI 在Intel 平台已經是標準內建的功能,Intel 早期在EHCI 就有加入一個Debug Port 功能,但是基於 EHCI 的Host<->Client半雙工模式設計,它必須透過外部一個USB Device 去做Host/Target的資料交換,又EHCI Controller 上只有 Port 0 可以提供這個功能,變成硬體設計與使用設定上都相對複雜,所以只有相對少數的工程師會去使用這個功能,通常是開發Windows Kernel Driver 的才會需要。

而Intel 在發展XHCI 時,因為USB3 已經是TX/RX分離,所以這次規格變成可以直接兩個Host Port 對接, 一條USB 3 的Debug Cable 實際上就是把 USB 2.0 的 D+/D- 跟Power(VBUS) 斷掉, 然後把USB 3的SS TX/SS RX 交換而已
enter image description here

所以現在開發UEFI/Windows/Linux Kernel mode driver 都支援透過xHCI 的這個內建功能去做,不過有些外接的xHCI Host Controller 並沒有實作這個 DbC (Debug Capability Class)

Microsoft 關於Kernel Debug 的設定
Intel 關於Linux 的Kernel mode 設定 — 這已經併入Vanilla Kernel stream 的文件目錄了,可以看到Linux 下就是把它當tty用

廣告

Note: Vendor ACPI Driver on Windows

之前寫了一些 ACPI Driver 相關的紀錄, 最近看到USB Type C connector for Windows 10 如果不做PD State Machine,下面也需要ACPI Driver 去協調 MCU/EC 所以整理一下手上有的資料 順便重新整理一下網路上很多消失的檔案

ACPIDriver Vista — 這個是Microsoft 最早提供的文件,不過根據實際經驗應該Windows XP 就支援這些功能
ACPI in Vista — 這是早期 WinHEC 2006 的 Presatations
BIOS implement of UCSI — Intel 這是Intel 講如何實作USB Type C Connector System Interface

older WDM/DDK Sample from Windows 2000

這邊提供實際原始碼的實作內容

Older WDM driver implement – 實作了Customer GPIO Button/Indicator LED, 應該是 Intel 用來Demo MID (Mobile Internal Device)做的
Current WDF Driver implement for UCSI - 這就是Microsoft 實作UCSI 的參考Driver了 可以搭配Intel 文件跟 Microsoft 網站資料一起看

下面是想更了解UCSI可以參考的資料
https://www.usb.org/developers/presentations/  — 2017 USB Developer Days  in Taipei

Update:
Linux 下的實作也有 Intel 提交的標準
https://github.com/torvalds/linux/tree/master/drivers/usb/typec/ucsi
所以盡可能透過在使用ACPI/ASL implement 去做這個功能,這樣Windows/Linux 下都有inbox driver 不用另外提供特殊的 customization driver
不過要透過標準UCSI 有一個地方考慮的是成本, 標準UCSI 界面是由 ACPI + EC + PD Controller 構成的,需要付出比較多的成本,目前已經有一個新的方式透過提供軟體的TCPM 取代PD Controller 如下圖 這個架構仍然需要一個MCU 去控制Type C 的界面行為, 系統透過I2C之類的下PD Policy 的行為給MCU

TCPCx

ref. https://www.mail-archive.com/linux-usb@vger.kernel.org/msg92179.html

FTDI USB to Serial VCP Drivers registry for WinCE 4.2 or later and TAPI/Unimodem setting

From  http://www.ftdichip.com/Drivers/VCP.htm get for wince version drivers

[HKEY_LOCAL_MACHINE\Drivers\USB\FTDI_DEVICE]
; in my platform not include device serial number, please to check readme of driver

      "InitialIndex"=dword:5     ; device from COM5: count

      "Prefix"="COM"             ; driver name

      "Dll"="ftdi_ser.dll"       ;

      "Version"="1.0.2.9"        ;

      "DeviceArrayIndex"=dword:0 ;

      "LatencyTimer"=dword:10    ;

[HKEY_LOCAL_MACHINE\Drivers\USB\FTDI_DEVICE\Unimodem]

      "Tsp"="unimodem.dll"

      "DeviceType"=dword:0       ; null modem

; for Control(Setting)/Connections

[HKEY_LOCAL_MACHINE\Drivers\USB\FTDI_DEVICE\Unimodem\Hayes]

      "Tsp"="unimodem.dll"

      "DeviceType"=dword:1       ; ext. modem

[HKEY_LOCAL_MACHINE\Drivers\USB\LoadClients\1027_24577\Default\Default\FTDI_DEVICE]

      "Dll"="ftdi_ser.dll"

The registry must to built in OS image due to when USB host to FTDI driver will delete FTDI_DEVICE registry
Technorati tags: , , , ,

Work Note : EHCI Driver for Windows Embedded 5.0/6.0

在WinCE 5.0 上的 EHCI Host Driver 有很多的 bugs. 就算是目前最新的 QFE (Monthly update Apr. 2007)仍然未解決這些問題,目前採取的作法是拿 Windows CE 6.0 的 host dirver 來使用,基本上這部份 Windows CE 5.0 與 Windows CE 6.0並未有太大差異點。

當然使用不同的 EHCI Host IC 仍然需要針對不同的部份做修改。例如個人所使用的NXP ISP1761,由 Vendor 提供的 Driver 是基於 WinCE 5.0 那個有許多潛藏 bugs 的Driver Code,所以需要修改的地方有些許不同。

目前確認 USBD & EHCI Driver 可以簡單的將 Windows CE 6.0 移植到 Windows CE 5.0上,基本上這兩個Driver Architecture變動不大,因此移植一個Windows CE 5.0/6.0共用的Source Code 是很容易的一件事情。

Work Note: Mirgation WinCE 6.0 USBD.DLL to WinCE 5.0 at 2007/6/21

基本上 USBD Driver 在目前 WinCE 6.0 是所謂的 USBD v1.3 版(可見 usbdi.h)

新增了一個函式 GetClientRegistryPath

主要問題是 WinCE 6.0 的 Memory Map 已經跟 WinCE 5.0 不一樣,增加了更多系統核心安全性的東西。

目前是簡單的將使用 CeAllocAsynchronousBuffer(Only WinCE 6.0) 的指標都直接指定到原本Buffer。

有什麼 Side effect 還需要經過 CETK測試。今天只是讓它能Build、能動而已。

原本想將 WinCE 6.0 的 USB Storage Class 也 弄到 WinCE 5.0 ,目前進度非常不樂觀很多東西,看起來比較複雜設計的與 WinCE 5.0 裡面不同。不過 WinCE 5.0的Storage Class 問題蠻多,也不認得 USB CDROM,雖然有現成的東西可用(WM 版本的M$有做過一些修改)。

至於為啥會想做這件事情,是因為公司目前幾乎所有的Device 都走 USB BUS ,在經過 Suspend/Resume or Pulg In/Out 後,發生很多問題,跟據M$ CE Development Team 的Blog 建議是換成Windows Embedded CE 6.0比較好,但是目前的情況下,這不是我能決定的事情,因此想將 Windows CE 6.0 的 EHCI Host Driver & Class Driver Mirgation to Windows CE 5.0 上,一般應該是將 Windows CE 5.0 BSP porting to Windows Embedded 6.0 才是,這個算是反其道而行吧。

下一步可能先將 EHCI Driver 組成弄乾淨一點,將 NXP 的 ISP1761 HOST Driver 重寫過,NXP提供的 Driver 還是有 Memory Poll Allocate/Release 的問題。

Work Todo: NXP ISP1761

ISP1761 and PXA270 connection on Windows CE 5.0

  1. Read Datasheet of ISP1761/USB 2.0 Spec./EHCI 1.0 Spec, go to NXP/Intel/USB org  website get documents.
  2. Check schematic and inteface to PXA27x. cowork with HW engineer.
  3. How to configuration PXA27x DMA and ISP1761 PIO Mode. (read PXA27x datasheet)
  4. Suspend/Resume issues, How to reinitialization HCD driver on WinCE 5.0 platform.
  5. optimization USB throughput.

Now, start step 1 at June 15 2007.

WinCE 5.0 的3 種 USB Function Driver

Win CE 5.0 下面 USB Client Function Driver 目前有提供
  • Serial Profile (Emulator a Serial Port, @CESYSGEN_MODULE_SERIALUSBFN, set SYSGEN_USBFN_SERIAL)
  • RNDIS Profile (Emulator a Network Card, @CESYSGEN CE_MODULE_RNDISFN, set SYSGEN_USBFN_ETHERNET=1)
  • Mass Storage (Emulator a Disk Device, , @CESYSGEN CE_MODULE_USBMSFN, set SYSGEN_USBFN_STORAGE=1)
如果 OS 選擇要使用那一個 Profile 是透過 下面的 Registry 決定。
[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers] 

“DefaultClientDriver"="Serial_Class"

or
“DefaultClientDriver"="RNDIS"
or
“DefaultClientDriver"="Mass_Storage_Class"

USB Function Client Driver Registry Settings

Send Feedback

The registry settings for each USB function client driver are in the %_WINCEROOT%PublicCommonOAKFilesCommon.reg file. To modify these settings for your hardware platform, add the registry keys you need to alter to your hardware platform’s Platform.reg file. The Platform.reg file for each platform is in %_WINCEROOT%Platform%_TGTPLAT%Files. Registry keys placed in Platform.reg override matching registry keys in Common.reg.

Note For all USB function client drivers, in the Platform.reg file for your hardware platform, appropriately update the default Manufacturer and Product strings.

The following table describes the USB function client driver registry settings common to all USB function client drivers. The USB function mass storage client driver registry settings are under [HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers].

Registry key Description
DefaultClientDriver Use to specify the default client driver. USBFunctionDriverSubkey is a placeholder string that represents a client driver. 

Specify a DefaultClientDriver for each type of USB function client.

USBFunctionDriverSubkeyDll DLL name for the USB function client driver.
USBFunctionDriverSubkeyDeviceName Identifies the name of the store to expose to the USB host.
USBFunctionDriverSubkeyFriendlyName Friendly name for the USB function client.
USBFunctionDriverSubkeyidVendor idVendor must be changed. 045E belongs to Microsoft and is only to be used for prototype devices in your labs. Visit http://www.usb.org to obtain a vendor identifier.
USBFunctionDriverSubkeyManufacturer Name of the USB function client device manufacturer. Replace appropriately.
USBFunctionDriverSubkeyidProduct Product identifier to be defined by the manufacturer.
USBFunctionDriverSubkeyProduct Name of the USB function client device. Replace appropriately.
USBFunctionDriverSubkeybcdDevice USB device’s release number, in binary-coded decimal (BCD) format.

USB Function Mass Storage Client Driver Registry Settings

The following table describes the USB function mass storage client driver registry settings. The USB function mass storage client driver registry settings are under [HKEY_LOCAL_MACHINEDriversUSBFunctionDriversMass_Storage_Class].

Registry key Description
InterfaceSubClass USB host uses this value to identify the class of an enumerated device. 

06h corresponds to the USB mass storage client.

InterfaceProtocol USB-IF defined value that the USB host uses to determine the USB mass storage transport protocol supported by the device. 

50h corresponds to bulk-only transport (BOT).

The following registry keys show the default USB function mass storage client driver registry settings.

[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"=- ; erase previous default
[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"="Mass_Storage_Class"

[HKEY_LOCAL_MACHINEDriversUSBFunctionDriversMass_Storage_Class]
   "Dll"="usbmsfn.dll"
   "InterfaceSubClass"=dword:06
   "InterfaceProtocol"=dword:50
   "DeviceName"="DSK1:"
   "FriendlyName"="Mass Storage"
   "idVendor"=dword:045E
   "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
   "idProduct"=dword:FFFF
   "Product"="Generic Mass Storage (PROTOTYPE--Remember to change idVendor)"
   "bcdDevice"=dword:0

USB Function Serial Client Driver Registry Settings

The following table describes the USB function serial client driver registry settings. The USB function serial client driver registry settings are under [HKEY_LOCAL_MACHINEDriversUSBFunctionDriversSerial_Class].

Registry key Description
DeviceArrayIndex Use to load different USB function serial client driver objects.

The following registry keys show the default USB function serial client driver registry settings.

[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"=- ; erase previous default
[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"="Serial_Class"

[HKEY_LOCAL_MACHINEDriversUSBFunctionDriversSerial_Class]
   "Dll"="serialusbfn.dll"
   "DeviceName"="USBFNS1:"
   "Prefix"="COM"
   "DeviceArrayIndex"=dword:0 ; Use to load different USB function serial client driver objects.
   "IClass"="{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}"
; idVendor must be changed. 045E belongs to Microsoft and is only to be used for
; prototype devices in your labs. Visit http://www.usb.org to obtain a vendor id.
   "idVendor"=dword:045E
   "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
   "idProduct"=dword:00ce
   "Product"="Generic Serial (PROTOTYPE--Remember to change idVendor)"
   "bcdDevice"=dword:0
   "Tsp"="Unimodem.dll"
   "DeviceType"=dword:0

[HKEY_LOCAL_MACHINEDriversUSBFunctionDriversUSBSER_Class]
   "Dll"="serialusbfn.dll"
   "DeviceName"="USBFNS2:"
   "Prefix"="COM"
   "DeviceArrayIndex"=dword:1
   "IClass"=multi_sz:"{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}","{C375C787-B721-4b8e-B67F-A112D5C0A404}"
   "idVendor"=dword:045E
   "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
   "idProduct"=dword:0079
   "Product"="Generic Serial (PROTOTYPE--Remember to change idVendor)"
   "bcdDevice"=dword:90
   "Tsp"="Unimodem.dll"
   "DeviceType"=dword:0

USB Function RNDIS Client Driver Registry Settings

The following table describes the USB function RNDIS client driver registry settings. The USB function RNDIS client driver registry settings are under [HKEY_LOCAL_MACHINEDriversUSBFunctionDriversRNDIS].

Registry key Description
UseActiveSyncIds If this value is set to anything besides zero (0), RNDIS sets the Device Class, Device Subclass, and Device Protocol codes in the USB device descriptor and interface descriptor to the values recognized by ActiveSync on the desktop computer. 

If this value is not in the registry or is set to 0, the standard communication class values are used.

For Pocket PC and Smartphone, this value is set by default.

Priority256 Determines the priority of incoming packets for RX thread processing.

The following registry keys show the default USB function RNDIS client driver registry settings. For information about the RNDIS client driver specific registry settings, see RNDIS Registry Settings.

[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"=- ; erase previous default
[HKEY_LOCAL_MACHINEDriversUSBFunctionDrivers]
   "DefaultClientDriver"="RNDIS"

[HKEY_LOCAL_MACHINEDriversUSBFunctionDriversRNDIS]
   "UseActiveSyncIds"=dword:1

[HKEY_LOCAL_MACHINEDriversUSBFunctionDriversRNDIS]
   "Dll"="rndisfn.dll"
   "FriendlyName"="Rndis"
   "idVendor"=dword:045E
   "Manufacturer"="Generic Manufacturer (PROTOTYPE--Remember to change idVendor)"
   "idProduct"=dword:0301
   "Product"="Generic RNDIS (PROTOTYPE--Remember to change idVendor)"
   "bcdDevice"=dword:0