diff --git a/drivers/windows/README.md b/drivers/windows/README.md index c88e8df..7219abd 100644 --- a/drivers/windows/README.md +++ b/drivers/windows/README.md @@ -75,15 +75,42 @@ Studio, select **Build->Batch Build.** In the project list select: The installer is generated with [NullSoft NSIS](http://nsis.sourceforge.net/Main_Page). Use NSIS to run panda_install.nsi after building all the required projects. -# Installing +Before generating the installer, you must go to copy vscruntimeinfo.nsh.sample to +vscruntimeinfo.nsh and follow the instructions to bundle in the Visual Studio C +Runtime required by your version of Visual Studio. Without this runtime, the panda +code will not work, so without this file, the installer will refuse to build. + +# Installing: + +Either build the software yourself by following the steps in the +'Developing' section, or get the panda_installer.exe file and run +it. The wizard should correctly set up the drivers. + +Since this driver is still in development, there are some issues +that may occur. If after you install the driver and then plug in your +panda (unplug it first if it was already plugged in), Windows says +the driver is missing, refer to the section below 'Dealing with self +signed drivers.' + +# Using J2534: + +After installing the J2534 drivers for the panda, you can do... nothing. +You first need to get a J2534 client that can load the drivers and talk to +the panda for you. + +A simple tool for testing J2534 drivers is DrewTech's 'J2534-1 Bus Analysis +Tool' available in the 'Other Support Applications' section of their +[Download Page](http://www.drewtech.com/downloads/). + +# Dealing with self signed drivers: Installation would be straightforward were it not for the USB Driver that needs to be setup. The driver itself is only a WinUSB inf file (no actual driver), but it still needs to be signed. -Driver signing is a recent requirement of Windows (64 bit versions -only for some reason). If your Windows refuses to install the driver -(It almost certainly will), there are three choices: +Driver signing is a requirement of Windows starting in 8 (64 bit +versions only for some reason). If your Windows refuses to install +the driver, there are three choices: - Self Sign the Driver. - Disable Driver Signature Verification @@ -111,6 +138,15 @@ other two options. **Note that certificate issues apply no matter if you are building from source or running an insaller .exe file.** +Some people have reported that the driver installs without needing to +disable driver signing, or that visual studio correctly sets up a +temporary signing key for them. I call witchcraft because I have not +had that happen to me. The signed certificate is still the correct +thing to do in the end. + +Windows 7 will not force driver signing. This software is not tested +on anything before 7. + # Developing: - Edit and merge pandaJ2534DLL\J2534register_x64.reg to register your development J2534 DLL. @@ -136,6 +172,6 @@ other two options. - All Tx messages from a single Connection are serialized. This can be relaxed to allow serialization of messages based on their address (making multiple queues, effectively one queue per address). - + # Other: Panda head ASCII art by dcau \ No newline at end of file diff --git a/drivers/windows/panda_install.nsi b/drivers/windows/panda_install.nsi index 4956d7a..81ecc3c 100644 --- a/drivers/windows/panda_install.nsi +++ b/drivers/windows/panda_install.nsi @@ -1,6 +1,13 @@ !define J2534_Reg_Path "Software\PassThruSupport.04.04\comma.ai - panda" !define Install_Name "panda J2534 Drivers" +;NOTE! The panda software requires a VC runtime to be installed in order to work. +;This installer must be bundled with the appropriate runtime installer, and have +;the installation registry key set so the installer can tell if the runtime is +;already installed. Copy vscruntimeinfo.nsh.sample to vscruntimeinfo.nsh and edit +;it for your version of Visual Studio. +!include "redist\vscruntimeinfo.nsh" + ;-------------------------------- ;Include Modern UI !include "MUI2.nsh" @@ -22,13 +29,13 @@ Outfile "panda install.exe" ; The default installation directory InstallDir $PROGRAMFILES\comma.ai\panda -; Registry key to check for directory (so if you install again, it will -; overwrite the old one automatically) -InstallDirRegKey HKLM "SOFTWARE\${Install_Name}" "Install_Dir" - ; Request application privileges for UAC RequestExecutionLevel admin +; Registry key to check for directory (so if you install again, it will +; overwrite the old one automatically) +InstallDirRegKey HKLM "SOFTWARE\${Install_Name}" "Install_Dir" + ;-------------------------------- ; Pages !insertmacro MUI_PAGE_WELCOME @@ -52,49 +59,72 @@ VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalTrademarks" "Application released u ;VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "© ${PRODUCT_NAME} Team" ;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "Jessy Exum" ;VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${PRODUCT_VERSION}" -VIProductVersion "1.0.0.0" +VIProductVersion "1.0.0.0" ;-------------------------------- ; Install Sections Section "panda driver (required)" SectionIn RO - + + SetOutPath "$INSTDIR" + + + ;If the visual studio version this project is compiled with changes, this section + ;must be revisited. The registry key must be changed, and the VS redistributable + ;binary must be updated to the VS version used. + ClearErrors + ReadRegStr $0 HKLM ${VCRuntimeRegKey} "Version" + ${If} ${Errors} + DetailPrint "Installing Visual Studio C Runtime..." + File "${VCRuntimeSetupPath}\${VCRuntimeSetupFile}" + ExecWait '"$INSTDIR\${VCRuntimeSetupFile}" /passive /norestart' + ${Else} + DetailPrint "Visual Studio C Runtime already installed." + ${EndIf} + + ;Remove the now unnecessary runtime installer. + Delete "$INSTDIR\${VCRuntimeSetupFile}" + + ;Do the rest of the install SetOutPath "$INSTDIR\driver" - + ; The inf file works for both 32 and 64 bit. File "Debug_x86\panda Driver Package\panda.inf" File "Debug_x86\panda Driver Package\panda.cat" ${DisableX64FSRedirection} nsExec::ExecToLog '"$SYSDIR\PnPutil.exe" /a "$INSTDIR\driver\panda.inf"' ${EnableX64FSRedirection} - + SetOutPath $SYSDIR File Release_x86\panda.dll - + ${If} ${RunningX64} ${DisableX64FSRedirection} - File Release_x64\panda.dll + ;Note that the x64 VS redistributable is not installed to prevent bloat. + ;If you are the rare person who uses the 64 bit raw panda driver, please + ;install the correct x64 VS runtime manually. + File Release_x64\panda.dll ${EnableX64FSRedirection} ${EndIf} ; Write the installation path into the registry WriteRegStr HKLM "SOFTWARE\panda J2534 Drivers" "Install_Dir" "$INSTDIR" - + ; Write the uninstall keys for Windows ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayVersion" "" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayIcon" '"$INSTDIR\pandaJ2534_0404_32.dll"' + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayIcon" '"$SYSDIR\panda.dll",0' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "DisplayName" "panda J2534 Drivers" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "Publisher" "comma.ai" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "URLInfoAbout" "https://github.com/commaai/panda/" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" "NoRepair" 1 - + SetOutPath $INSTDIR WriteUninstaller "uninstall.exe" - + SectionEnd Section "panda devel lib/header" @@ -111,9 +141,9 @@ Section "panda devel lib/header" SectionEnd Section "J2534 Driver" - + SetOutPath $INSTDIR - + File Release_x86\pandaJ2534_0404_32.dll SetRegView 32 @@ -165,12 +195,12 @@ Section "Uninstall" RMDir "$INSTDIR\devel\x64" Delete "$INSTDIR\devel\panda.h" RMDir "$INSTDIR\devel" - + ; Remove registry keys DeleteRegKey HKLM "${J2534_Reg_Path}" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Install_Name}" DeleteRegKey HKLM "SOFTWARE\${Install_Name}" - + ; Remove files and uninstaller Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\pandaJ2534_0404_32.dll" diff --git a/drivers/windows/redist/.gitignore b/drivers/windows/redist/.gitignore new file mode 100644 index 0000000..90d431b --- /dev/null +++ b/drivers/windows/redist/.gitignore @@ -0,0 +1,2 @@ +*.exe +vscruntimeinfo.nsh diff --git a/drivers/windows/redist/README.md b/drivers/windows/redist/README.md new file mode 100644 index 0000000..69565f1 --- /dev/null +++ b/drivers/windows/redist/README.md @@ -0,0 +1,7 @@ +When building the installer, please put the relevant vc_redist.x86.exe file into this folder. +Make sure that the uninstall registry key is correct in the panda_install.nsi file. + +Here is a list of the VC runtime downloads: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads +An list of the registry keys has been maintained here: https://stackoverflow.com/a/34209692/627525 + +Copy vscruntimeinfo.nsh.sample to vscruntimeinfo.nsh and edit it for your version of Visual Studio. \ No newline at end of file diff --git a/drivers/windows/redist/vscruntimeinfo.nsh.sample b/drivers/windows/redist/vscruntimeinfo.nsh.sample new file mode 100644 index 0000000..3e74ab1 --- /dev/null +++ b/drivers/windows/redist/vscruntimeinfo.nsh.sample @@ -0,0 +1,13 @@ +;NOTE! The panda software requires a VC runtime to be installed in order to work. +;This installer must be bundled with the appropriate runtime installer, and have +;the installation registry key set so the installer can tell if the runtime is +;already installed. + +;Here is a list of the VC runtime downloads: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads +;An list of the registry keys has been maintained here: https://stackoverflow.com/a/34209692/627525 + + +;Microsoft Visual C++ 2015 Redistributable (x86) - 14.0.24123 +!define VCRuntimeRegKey "SOFTWARE\Classes\Installer\Dependencies\{206898cc-4b41-4d98-ac28-9f9ae57f91fe}" +!define VCRuntimeSetupPath "redist\" +!define VCRuntimeSetupFile "vc_redist.x86.exe" \ No newline at end of file