VS2015 下面编译 SPB 驱动

差不多3年前的这个时候,我写过一篇介绍如何在 VS2013下面编译 Windows Driver Sample的文章【参考1】。今年的这个时候,我再一次尝试在 VS2015下面编译驱动。

For building Windows Sample you need below software

1. Windows 10 RS2: 15063.0.170317-1834.RS2_RELEASE_CLIENTPRO-CORE_OEMRET_X64FRE_EN-US (Note: VS2015 can’t be installed on Windows7)
2. 15063.0.170317-1834.rs2_release_amd64fre_WDK.iso
3. 15063.0.170317-1834.rs2_release_WindowsSDK.iso
4. Visual_Studio_Pro_2015_English.iso

1.Install Windows RS2
2.Install VS2015 (2 Hours),全默认配置

3.Install WDK 到默认的路径下

image001

安装完成后,用 VS2015打开驱动工程文件。编译会出现下面的错误

“—— Build started: Project: SpbTestTool (Exe\SpbTestTool), Configuration: Debug Win32 ——
Building ‘SpbTestTool’ with toolset ‘WindowsApplicationForDrivers10.0’ and the ‘Desktop’ target platform.
TRACKER : error TRK0005: Failed to locate: “CL.exe”. The system cannot find the file specified.

—— Build started: Project: SpbTestTool (Sys\SpbTestTool), Configuration: Debug Win32 ——
Building ‘SpbTestTool’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Universal’ target platform.
Stamping .\Debug\\SpbTestTool.inf [Version] section with DriverVer=05/18/2017,18.15.36.668
TRACKER : error TRK0005: Failed to locate: “CL.exe”. The system cannot find the file specified.

========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========”

根据我的研究,这是因为VS2015默认安装没有带C++编译器(有点莫名其妙)

image002

image003

image004

再进行一次编译:
—— Build started: Project: SpbTestTool (Exe\SpbTestTool), Configuration: Debug x64 ——
Building ‘SpbTestTool’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Desktop’ target platform.
command.cpp
command.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
main.cpp
main.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
util.cpp
util.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
Generating Code…
—— Build started: Project: SpbTestTool (Sys\SpbTestTool), Configuration: Debug x64 ——
Building ‘SpbTestTool’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Universal’ target platform.
Stamping .\x64\Debug\\SpbTestTool.inf [Version] section with DriverVer=05/18/2017,22.28.17.712
driver.cpp
driver.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
device.cpp
device.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
peripheral.cpp
peripheral.cpp : fatal error C1083: Cannot open include file: ‘C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared\warning.h’: No such file or directory
Generating Code…
========== Build: 0 succeeded, 2 failed, 0 up-to-date, 0 skipped ==========

这个错误是因为没有安装 SDK 导致的(VS2015自带SDK,但是可能版本和 WDK 的不匹配,所以有问题)。再安装 SDK,之后 Build again
—— Build started: Project: SpbTestTool (Exe\SpbTestTool), Configuration: Debug x64 ——
Building ‘SpbTestTool’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Desktop’ target platform.
command.cpp
main.cpp
util.cpp
Generating Code…
SpbTestTool.vcxproj -> C:\spb\SpbTestTool\exe\x64\Debug\SpbTestTool.exe
SpbTestTool.vcxproj -> x64\Debug\SpbTestTool.pdb (Full PDB)
Inf2Cat task was skipped as there were no inf files to process

—— Build started: Project: SpbTestTool (Sys\SpbTestTool), Configuration: Debug x64 ——
Building ‘SpbTestTool’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Universal’ target platform.
Stamping .\x64\Debug\\SpbTestTool.inf [Version] section with DriverVer=05/19/2017,0.46.12.487
driver.cpp
device.cpp
peripheral.cpp
Generating Code…
SpbTestTool.vcxproj -> C:\spb\SpbTestTool\sys\x64\Debug\SpbTestTool.sys
SpbTestTool.vcxproj -> x64\Debug\SpbTestTool.pdb (Full PDB)
Done Adding Additional Store
Successfully signed: C:\spb\SpbTestTool\sys\x64\Debug\SpbTestTool.sys

Driver is a Universal Driver.
……………………
Signability test complete.

Errors:
None

Warnings:
None

Catalog generation complete.
C:\spb\SpbTestTool\sys\x64\Debug\SpbTestTool\spbsamples.cat
Done Adding Additional Store
Successfully signed: x64\Debug\SpbTestTool\spbsamples.cat

========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

成功!

本文提到的驱动是 Windower Driver Sample【参考2】的一部分。

这里我放置一个 SPB 的Driver

SpbTestTool

参考:
1.http://www.lab-z.com/spbtesttool/
2.https://github.com/Microsoft/windows-driver-samples

《VS2015 下面编译 SPB 驱动》有12个想法

  1. 您好,最近在看 windows 上 i2c 驱动开发,一直云雾缭绕
    请问,假如硬件是ok 的,pc端的驱动只需要修改这个 spbtesttool 就可以实现应用读写了吗。还是需要再写一个类似之前 eeprom 基于 spb 的驱动
    感谢~

      1. 您看我理解对吗,Microsoft 的 driver sample 里面的 skeleton i2c 是驱动的参考实现,i2c slave 的 7bit 地址是在 acpi 定义的。
        然后 spbtesttool 的 EXE/SYS 是两种应用测试的方式,测试对象 skeleton i2c 驱动的

  2. 问题有点多。抱歉
    另外 windbg 看不到驱动的 Trace 日志。我 debug 远程的机器,在远程机器本地打开 windbg,debug 过程能看到但是 DriverEntry 里面的 Trace 日志看不到。使用其他工具看 i2c 驱动的日志吗
    或者有幸能加您联系吗,我本身是做 嵌入式方向的,最近需要做一个 windows 驱动,好几脸懵哈哈~

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注