Monday, November 26, 2012

Using #error macro in Compact 7 BSP Development

This post talks about checking whether a variable is CDEFINED or not using #error macro

We have a file test.c under the path _TARGETPLATROOT\SRC\DRIVERS\test\

When we build test folder it generates test.dll which is present in NK.bin and also the registry entries which corresponds to this DLL are also available in NK.bin. 

We have defined some macros as given below in test.c file

#ifdef BSP_TEST
#define SHARED_GPIO GPIO_81
#else
#define SHARED_GPIO GPIO_51
#endif

BSP_TEST was set in <Platform>.bat file and corresponding CDEFINE was done in sources.cmn

Issue: When we load the driver the interface which is controlled test.dll found not working. 

The following debug steps are identified to know what is causing the issue

  • Check if the driver is present or not in Active Registry
  • Enable messages in all the functions of the driver (Test.DLL) if the driver is unloading
  • Print SHARED_GPIO macro value using RETAILMSG

Tools used for the identified steps

  • For the first one we have used Remote Tools from Compact 7 and searched for the test.dll in HKLM\Active path
  • Used RETAIL Messages in all the functions
  • For the third I had come to know a useful macro that is #error
    • Use the below code to check BSP_TEST is enabled or not
    • Include the following lines of code in test.c 
                      #ifndef BSP_TEST 
                            #error "BSP_TEST is not enabled" 
                      #endif
    • With this if by chance the driver is not able to see the CDEFINE for BSP_TEST your build fails and you need not check by booting the system with the NK.bin
  • using #error while preliminary testing of the BSP will save significant amount of your time


Monday, November 5, 2012

Batch File To Clean Windows CE 6.0 BSP

Hi,

This post talks about cleaning the Windows CE 6.0 BSP.

Before shipping the BSP to the customer it is good to remove unwanted files from it. 

What I use to do is search for these files for each item and remove them. 

The below list shows the unwanted files
  • lib and target folders that are created under _TARGETPLATROOT
  • build.* files that are created when BSP is compiled 
  • *.bak files that might be created from WinMerge Tool
  • Intermediate folders such as OBJ
  • Sub-Version files such as .svn folders
The below windows batch file is written for cleaning the BSP
Note: Please take a backup of your BSP before running this batch file


Steps to be followed for cleaning the BSP


  • Copy the below contents to a notepad
@echo My first batch file
@echo Deleting *.bif files
del /s /f *.bif
@echo Deleting build.*
del /s /f build.*
@echo Deleting *.bak files
del /p /s /f *.bak
@echo Deleting *.user files
del /s /f *.user
@echo Deleting lib folder
rd /s/q lib
@echo Deleting lib folder
rd /s/q target
@echo Deleting obj folders
for /d /r . %%d in (obj) do @if exist "%%d" rd /s/q "%%d"
@echo Deleting .svn folders
for /d /r . %%d in (.svn) do @if exist "%%d" rd /s/q "%%d"

  • Save this text file as CleanBSP.bat in the following folder _WINCEROOT\Platform\_YOUR_BSPNAME_
  • Open a windows COMMAND Prompt and navigate to the following path _WINCEROOT\Platform\_YOUR_BSPNAME_
  • Now run CleanBSP.bat

Note: Please refer the following URL to refer how to eliminate all the above steps http://social.msdn.microsoft.com/Forums/en-US/winembplatdev/thread/743382e1-2ee1-4df1-9f01-524ee8ea5a80