Monday, February 25, 2013

Sparkfuns' Open Logic Sniffer

Sparkfun sells a Logic sniffer which is a low cost OLS (Open Logic Sniffer) platform that supports the sump logic analyser software. It uses a FPGA connected to a usb to serial adapater, and this is where the problem lies. The drivers required for the usb to serial adapter do not work with Windows 8 as they are not signed. The following procedure will sign the drivers:

  1. Obtain the driver to sign by downloading the ols software, found here. Either version (expert or full) contains the driver.
     
  2. Modifications to the inf file are needed in order to use the usbser.sys driver provided by windows. Extract the archive and find the driver directory. Locate mchpcdc.inf and copy it to another directory (for example C:\drivers). Edit the copied version and make the following changes:
     
    [DestinationDirs]
    FakeModemCopyFileSection=12 //add
    DefaultDestDir=12
    ...
    [DriverInstall.nt]
    include=mdmcpq.inf
    CopyFiles=DriverCopyFiles.nt  //remove
    CopyFiles=FakeModemCopyFileSection //add
    AddReg=DriverInstall.nt.AddReg
    ...
    [DriverCopyFiles.nt]  //remove
    usbser.sys,,,0x20     //remove

    ...
    [DriverInstall.NTamd64]
    include=mdmcpq.inf
    CopyFiles=DriverCopyFiles.NTamd64 //remove
    CopyFiles=FakeModemCopyFileSection //add
    AddReg=DriverInstall.NTamd64.AddReg
     
     
  3. The next steps sign the driver and require the Windows Driver Kit, found here.
     
  4. If you have Visual Studio 2012, open a Developer Command Prompt as an administrator. Otherwise open a command prompt as an administrator and use the following if you are running 64 bit windows:

    set PATH=PATH;C:\Program Files (x86)\Windows Kits\8.0\bin\x64
      

    or if you are running 32 bit windows:

    set PATH=PATH;C:\Program Files\Windows Kits\8.0\bin\x86
     

    This adds the path of the tools needed for the driver signing. The Developer Command Prompt already has these paths setup.
     
  5. The directory of the inf used in the following steps is in C:\drivers. The first step is to change the date of the driver in the inf using the following:

    C:\drivers>stampinf -f mchpcdc.inf -d 09/09/2012 -v 9.0.9999.0
    Stamping .\mchpcdc.inf [Version] section with
    DriverVer=09/09/2012,9.0.9999.0
     

    This sets the date of the driver so that it can be signed. The date needs to be newer than 21/04/2012 as we cannot sign software created before windows 8.
     
  6. Next create a catalog file for the driver:
     
    C:\drivers>inf2cat /driver:. /os:8_X86,8_X64
    ....................
    Signability test complete.
    Errors:
    None
    Warnings:
    None
    Catalog generation complete.
     
  7. A certificate is needed to sign the driver catalog, to create a certificate use:
     
    C:\drivers>Makecert -r -pe -ss PrivateCertStore -n "CN=TestCertforWDK" TestCert.cer
    Succeeded
     

    This creates the certificate to sign the driver catalog, it must now be added to the trusted certificates on the computer. This is what allows the driver to be installed as the certificate to sign the driver is also part of the trusted certificates on the computer. The following commands add the certificate to the root and to the trusted publishers:
     
    C:\drivers>certmgr.exe /add TestCert.cer /s /r localMachine root
    CertMgr Succeeded
    C:\drivers>certmgr.exe /add TestCert.cer /s /r localMachine trustedpublisher
    CertMgr Succeeded
     
  8. The driver catalog can now be signed with the certificate created in the previous step, using the following:
     
    C:\drivers>Signtool sign /v /s PrivateCertStore /n TestCertForWDK /t http://timestamp.verisign.com/scripts/timestamp.dll mchpcdc.cat
    The following certificate was selected:
        Issued to: TestCertforWDK
        Issued by: TestCertforWDK
        Expires:   Sun Jan 01 12:59:59 2040
        SHA1 hash: ...
    Done Adding Additional Store
    Successfully signed and timestamped: mchpcdc.cat
    Number of files successfully Signed: 1
    Number of warnings: 0
    Number of errors: 0

     
  9. The final step in signing the driver is to verify the driver catalog and associated inf, this is done using:
     
    C:\drivers>Signtool sign /v /s PrivateCertStore /n TestCertForWDK /t http://timestamp.verisign.com/scripts/timestamp.dll mchpcdc.cat
    The following certificate was selected:
        Issued to: TestCertforWDK
        Issued by: TestCertforWDK
        Expires:   Sun Jan 01 12:59:59 2040
        SHA1 hash: ...
    Done Adding Additional Store
    Successfully signed and timestamped: mchpcdc.cat
    Number of files successfully Signed: 1
    Number of warnings: 0
    Number of errors: 0
    C:\drivers>Signtool verify /pa /v /c mchpcdc.cat mchpcdc.inf
    Verifying: mchpcdc.inf
    File is signed in catalog: mchpcdc.cat
    Hash of file (sha1): ...
    Signing Certificate Chain:
        Issued to: TestCertforWDK
        Issued by: TestCertforWDK
        Expires:   Sun Jan 01 12:59:59 2040
        SHA1 hash: ...
    The signature is timestamped: Mon Feb 25 09:07:48 2013
    Timestamp Verified by:
        Issued to: Thawte Timestamping CA
        Issued by: Thawte Timestamping CA
        Expires:   Fri Jan 01 12:59:59 2021
        SHA1 hash: ...
            Issued to: Symantec Time Stamping Services CA - G2
            Issued by: Thawte Timestamping CA
            Expires:   Thu Dec 31 12:59:59 2020
            SHA1 hash: ...
                Issued to: Symantec Time Stamping Services Signer - G4
                Issued by: Symantec Time Stamping Services CA - G2
                Expires:   Wed Dec 30 12:59:59 2020
                SHA1 hash: ...
    Successfully verified: mchpcdc.inf
    Number of files successfully Verified: 1
    Number of warnings: 0
    Number of errors: 0
     
  10. The driver is now signed. Right click on the mchpcdc.inf and click install. Next time the Open Logic sniffer is plugged in it should be detected and the correct driver installed.
This guide was based on these links:

http://www.microchip.com/forums/m488342.aspx

http://msdn.microsoft.com/en-nz/library/windows/hardware/ff547089(v=vs.85).aspx

http://stackoverflow.com/questions/10832499/workaround-to-skip-driver-signing-in-64bit-windows
 

3 comments:

  1. couldn´t you post an already signed driver??

    ReplyDelete
  2. I get the following error:

    Verifying: mchpcdc.inf
    File is signed in catalog: mchpcdc.cat
    Hash of file (sha1): CEA6A077B60839CEBC4762BC1FBD6A2C06BB8E1E
    SignTool Error: No signature found.
    SignTool Error: File not valid: mchpcdc.inf

    Number of files successfully Verified: 0
    Number of warnings: 0
    Number of errors: 1

    I noticed that WDK and in2cat.exe installed on x86 folder, but my system is x64.. could you help me?

    ReplyDelete