Showing posts with label Debugging. Show all posts
Showing posts with label Debugging. Show all posts

Tuesday, January 13, 2009

Req : Using Windows CE Test Kit for Unit Testing

I would like to write a post about unit testing and the Windows CETK. To go deeply in this suject I would like to know your background experience with this tool or if you are using other tools for unit testing of your applications under Windows Embedded CE or Windows Mobile.

You can submit all your testimonials to nbesson.blog@gmail.com

Thanks for your help.

- Nicolas

Monday, November 24, 2008

Debugging Windows Mobile devices

Another boring notification while debugging Windows Mobile devices, is linked to the default security level of the OS. On every start of the debugger, VS2005 launch required applications on the device that are not digitally signed, so device warn you.
One solution to disable those warning messages, is to disable and change the security level. Of course this will completely remove all the security on the device... so make sure to revert your changes after debugging process to avoid any damages on your device.
On the device you have to set the following :
[HKEY_LOCAL_MACHINE\Security\Policies\Policies]
"00001001"=dword:1
"0000101a"=dword:1

- Nicolas

ActiveSync Tweak

If you are like me, connecting, disconnecting, all day long, various Windows Mobile and Windows CE devices to you computer through ActiveSync, at each connection ActiveSync bother you make a partnership !
Partnership are nice while it's your personal or business device and you bring it everywhere with you to get an updated schedule and email... but while you are debugging applications, you don't want to be prompted.
ActiveSync have a "secret" registry key to always associate connected device as guest and will never prompt you anymore for any partnership.
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows CE Services]
"GuestOnly"=dword:1

Set this value on your desktop computer and then plug your devices !!!

To revert this, just set GuestOnly to 0(zero) and partner ship will be enabled.
- Nicolas

Tuesday, October 14, 2008

Flash back to Windows CE .Net 4.2

Last few weeks I have been involved into a customer project running Windows CE 4.2…. Woooaa a big jump in the past. I don't know if you were already involved in Windows CE at this time, but a big gap is visible between this version of Windows CE and the latest one… Thanks to Microsoft for all those improvements… Connectivity options was Configure Remote Connection… so i took me 10 minutes to find the right menu, as every thing change… But one thing that I found really surprising is the time spent to do a sysgen under Windows CE 4.2 with the most up-to-date development Platform. It took me only 10 minutes, while it was around 40 minutes on the best computer available at the release of Windows CE 4.2… oups I should say Windows CE .Net 4.2, the time when the .Net revolution starts :-).

The KITL over serial implementation give me a big headache, as at the time of Windows CE 4.2 the frames sent and received by the target where created and checked by the OAL itself before forwarding them to the upper layer of KITL… meaning that you had to know exactly the format of the frames sent and received by Platform Builder, otherwise the default KITL over serial implementation of Platform Builder was not able to communicate with the target. You can imagine that finding this information is not so easy as the MSDN documentation at this time was not so complete as it is now. But thanks to free sample BSPs, and to my favorite web search engine , I found my grale : "The definition of the KITL frames".

So as an archive for the Windows CE community here is the KITL header definition for Windows CE 4.2 : Header - Data - Trailer

typedef struct _SERIAL_PACKET_HEADER
{
UCHAR headerSignature[HEADER_SIGNATURE_BYTES];
UCHAR pktType;
UCHAR Reserved;
USHORT payloadSize;
UCHAR crcData;
UCHAR crcHdr;
} SERIAL_PACKET_HEADER;

With :
  • headerSignature : the signature of the header : { 'k', 'I', 'T', 'L' }
  • pktType : use by KITL to identify the service associated to the frame
  • payloadSize : packet data size, not including this header
  • crcData : packet data check sum (simple, 8-bit crc)
  • crcHdr : header data checksum (simple, 8-bit crc)

The simple 8 bits check sum algorithm :
UCHAR ComputeChecksum(PUCHAR pBuf, USHORT len)
{
USHORT s = 0;
UCHAR csum = 0;

for(s = 0; s < len; s++)
csum += *(pBuf + s);

return csum;
}


- Nicolas

Monday, February 11, 2008

Dynamic JIT Debugging [Updated]

Booting a device with the debugger is sometime a real challenge due to the stability of the device. So loading the debugger later could be the solution. To do so, we have to include the JIT debugger files in the Windows Embedded CE binary image, to launch it when required.
If the debugger is not launched exceptions are not handled correctly, and second chance exceptions neither.

Inclusion of the JIT Debugger
In the project.bib file of the current OSDesign, add the following lines in the FILES section :
kd.dll $(_FLATRELEASEDIR)\kd.dll NK SHK
osaxst0.dll $(_FLATRELEASEDIR)\osaxst0.dll NK SHK
osaxst1.dll $(_FLATRELEASEDIR)\osaxst1.dll NK SHK

The files are added to the FILES instead of the MODULE section to ensure that the debugger will not be launched 'till you launch it manually.
[Update 07/25/08] You can also include the loaddbg.exe file to the runtime image to avoid the loading of this files over KITL. But do not include hd.dll, otherwise the debugger will be started automatically at startup.

OSDesign configuration
Select the following options for the OSDesign:
- Unselect Kernel debugger
- Enable KITL

Launch the debugger
To launch the debugger when required, you just have to launch the loaddbg.exe application using the target control window.
s loaddbg.exe
Note : When activating the debugger, the system may take few seconds load all the symbols files from your hard drive.

- Nicolas

Friday, December 28, 2007

Enable Remote Display Application - CERDisp

The "Remote Display Application" or CERDisp is a Windows CE functionality that gives you the possibility to see remotely the content of the Frame Buffer of your device, and to interact with it through the mouse and keyboard. This tool is composed of two part, a client and a server.

The server :
CERHost is the host part of this tool, and must be launched on your computer before the client. This tools will wait for client connections.
The application can be found in the following folder :
C:\WINCE600\PUBLIC\COMMON\OAK\BIN\I386



The Client :
CERDisp is the Windows CE client and must be integrated inside your Windows CE binary image, by selecting the "Remote Display Application" component in your OSDesign. The client will connect to a dedicated server, for which the settings are stored in the registry. Add the following registry settings to your Project.reg file to setup CERDisp.
[HKEY_LOCAL_MACHINE\SOFTWARE\CERDISP]
"Hostname"="nameoftheserver"

The Hostname is the name or the IP address of the server. Use ppp_peer the as Hostname if you want ot use CERDisp throught an ActiveSync connection.

Tip to use this tool :
As you have to launch CERDisp on your device, you need an access to your device through a command prompt. That's why in that case I suggest you to enable a Telnet server to have a network access to your device and be able to launch the client.
[HKEY_LOCAL_MACHINE\COMM\TELNETD]
"IsEnabled "=dword:1
"UseAuthentication"=dword:0
The above settings are enabling the telnet server and removing the authentication. So you may have network security risk to use those settings AS IS on your device.

Launch CERDisp :
Before launching CERDisp, you have to launch CERHost on your computer. To launch CERDisp you have to use the following command line :
Cerdisp –c
The -c parameter is used to specify that the application have to connect.


Note : Do not store any registry settings about the host if you do not have a specific dedicated host. You may be able to select your device in a list under CERHost (File -> Connect).

- Nicolas

Tuesday, November 20, 2007

Static IP address for KITL (VMINI)

When you want to connect to your Windows CE device using KITL over Ethernet and having the network support enable, you have to select the following components and settings in your OSDesign :
  • TCP/IP
  • Wired Local Area Network (802.3, 802.5)
  • KITL support in you OSDesign settings
At this time the VIMINI driver is mounted on your system to provide access to the network API and support even if your physical network interface is already handled by KITL. This Virtual network interface (Virtual Mini Adapter) requires an IP address like another network interface.
If your network have a DHCP server enable, this interface will get an IP Address automatically. If it's not the case, you will have a default IP address (169.254.50.67) associated to this network interface and unfortunately this interface cannot be used as is. You must provide a valid IP address to this VMINI network driver through the registry.
; Enable static IP address for VMINI1
[HKEY_LOCAL_MACHINE\Comm\VMINI1\Parms\Tcpip]
"EnableDHCP"=dword:0 ; Disable the DHCP/ enable static IP
"IPAddress"="192.168.1.3"
"SubnetMask"="255.255.255.0"
Note : VMINI1 is the correct key path to point to the registry settings used by this driver.
Those settings must be added to your project.reg as those settings are specific to your current OSDesign and not linked to the BSP.
Using the same technique you can set a Static IP address to other network interfaces available on your device.

In the case of the usage of the Emulator BSP, the network interface used in this case is not VMINI1 but the NE20001 driver provided by Microsoft, emulating the access to your real network interface. In this particular case the registry settings will be :
; Enable static IP address
[HKEY_LOCAL_MACHINE\Comm\NE20001\Parms\Tcpip]
"EnableDHCP"=dword:0 ; Disable the DHCP/ enable static IP
"IPAddress"="192.168.1.3"
"SubnetMask"="255.255.255.0"

- Nicolas

Tuesday, August 14, 2007

Debugging technics for Windows CE (Part 1)

Everybody want to reduce the time used to debug developments, so I will share with you my tips to spend less time in debugging for your drivers, applications ...
First things that we can avoid is to download the Windows CE image to the device every time we made a modification of the driver or the application. So the idea is to exclude the driver or the application from the nk.bin. So in that case how my driver or application can be loaded ?
If KITL is enable in your Windows CE image you have by default an NFS (Network Filesystem) mounted in the RAM filesystem under Release folder. This NFS is the content of you _FLATRELEASEDIR on you desktop computer. By using this NFS you can access the content of your _FLATRELEASEDIR directly from Windows CE. When accessing a file for loading, the OS is using this NFS partition to find missing files in the current RAM filesystem. In our case the file is not available in the RAM filesystem but in the NFS partition, so the OS will copy it from this network path to the RAM filesystem.
In other words, if your binary file is not in the NK.bin but available on your harddrive in the _FLATRELEASEDIR, the system will be able to load it.

You can imagine now how to avoid the download of the Windows CE image every time you modify your source code.

-Nicolas