Skip to main content

Adding a new driver in WinCE

Here is a short guide on how to create your very own driver in Windows CE:

  •  In solution explorer, go to C:\WINCE800\platform\${whatever board}\SRC\DRIVERS
  • right click driver and press "Add"->"New subproject..."
  • Select WCE Dynamic Link library and empty project.
  • Add the following in ${drivername}.bib:
MODULES

IF BSP_DRIVERSHELL
IF _WINCEOSVER=600
    ${drivername}.dll $(_FLATRELEASEDIR)\${drivername}.dll NK K
ELSE
    ${drivername}.dll $(_FLATRELEASEDIR)\${drivername}.dll NK
ENDIF
ENDIF
  • Add the following in ${drivername}.reg:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\${drivername}]
    "Prefix"="XXX"
    "Dll"="${drivername}.dll"
    "Order"=dword:4
  • Add the following in ${drivername}.def:
LIBRARY ${drivername}

EXPORTS
    XXX_Init
    XXX_Deinit
    XXX_Read
    XXX_Open
    XXX_Close
    XXX_IOControl

Note that XXX should be fixed to 3 letters. The functions defined should match the functions in cpp file
  • Add the following in ${drivername}.cpp:
#include <stdAfx.h>
#include <windows.h>
#include <devload.h>
#include "bsp.h"

extern "C"
BOOL WINAPI DllMain(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{

UNREFERENCED_PARAMETER(lpvReserved);
    switch (dwReason) {
        case DLL_PROCESS_ATTACH:
            DEBUGREGISTER((HMODULE)hInstDll);
            DisableThreadLibraryCalls((HMODULE)hInstDll);
        break;
        case DLL_PROCESS_DETACH:
        break;
  }
    return TRUE;
}

DWORD XXX_Init(LPCTSTR pContext)
{
    return 1;
}

DWORD XXX_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
    return 0;
}

BOOL XXX_Deinit(DWORD hDeviceContext)
{
    return TRUE;
}

DWORD XXX_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
    return 1;
}

BOOL XXX_Close(DWORD hOpenContext)
{
    return TRUE;
}

BOOL XXX_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn, 
    DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
    return TRUE;
}

  • In Drivers\dir, add the DLL project name
  • In C:\WINCE800\platform\${whatever board}\FILES\platform.reg, Add the follwong line:
    •  #include "$(_winceroot)\platform\${whatever board}SRC\DRIVERS\USBMANAGER\${drivername}.reg"
  • In C:\WINCE800\platform\${whatever board}\FILES\platform.bib, Add the following line:
    • ${drivername}.dll $(_FLATRELEASEDIR)\${drivername}.dll
  • Try building the driver alone first for some minor bugs that might apear.
  • Build everything and the driver should work.

Comments

Popular posts from this blog

Setting up SSH Keys for Git Account

Here is a simple guide to Generate ssh key: $ ssh-keygen just enter or say yes for every questions Enter your public key into your git account: cat ~/.ssh/id_rsa.pub Paste all the content of the file to the designated git account. The place where to put it may differ depending on what you are using (e.g. gitlab, github, etc...)  Tip: Almost all of them will be around the settings page of the git account Done!

Getting Used to tmux!

This is a short guide to multiplexing in your terminal! Installation Install  $ sudo apt install tmux launch $ tmux Core Commands Here is a small list of the most useful set of commands. Just remember these and you shall be tmuxing around in no time! Adding panes Add panes vertically ctl + b % Add panes Horizontally ctl + b "  Moving around panes Move to the panes to the right ctl + b <Right> Move to the panes to the left ctl + b <LEFT> Move to the panes to the up ctl + b <UP> Move to the panes to the down ctl + b <DOWN> Closing Window  Close current panes ctl + d Tip!!! You can resize panes by pressing: $ ctl + b + <arrow button> Scroll: $ ctl + b [ press < UP > or < DOWN > Quit $ q  

Installing Qt Cross Compilation Toolchain for Beaglebone Black

This is the guide that I went through to successfully set the environment. If you get stuck on something, feel free to have a look at the references in the bottom most. These are the steps that worked for me so I hope it helps. Just making sure of the dependencies sudo apt-get update sudo apt-get upgrade sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 libstdc++6:i386 ia32-libs Assuming that you can get access to the root Set up Cross compiler Download and install wget -c https://releases.linaro.org/components/toolchain/binaries/6.4-2018.05/arm-linux-gnueabihf/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz tar xf gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf.tar.xz export CC=`pwd`/gcc-linaro-6.4.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- Test installation ${CC}gcc --version Download qt source #do this in a directory that is not in your root filesystem, i.e. ~ git clone git://code.qt.io...