Wednesday, May 3, 2017

.nb0 Files

Files with NB0 extension are primarily the ROM foot print. 

We would be referring to primary bootloader for a AM335x processor. The first 4-Bytes of the image contains a jump to location address which is nothing but equals to 4K offset from the starting location.

The nb0 image also contains a ROM Signature "CECE", ROM TOC Pointer offset which is at an offset of 0x44 and ROM TOC Offset which is at a offset of 0x48.

The advantage of nb0 file is it can be downloaded to SRAM present on device and the Program Counter can be set to the starting address of the image. After wards either we can do step debugging to see which instruction is causing issues to boot the device from X-Loader and then we can trace back to the C source code.

Sleep + GetTickCount

In this article I will discuss one of the problem that I was facing with Sleep API

I had written a small piece of code which is shown below


DWORD dwCnt, dwCurTick;

dwCurTick = GetTickCount();

for(dwCnt = 0; dwCnt < 100; dwCnt++)

RETAILMSG (1,(L"Tick Diff:%d\r\n",GetTickCount()-dwCurTick));


I was expecting Tick Diff:200 since we kept Sleep(2) for hundred times. But the result is seen as 300.

When we modify the code as given below


DWORD dwCnt, dwCurTick;

for(dwCnt = 0; dwCnt < 100; dwCnt++)
    dwCurTick = GetTickCount();

    RETAILMSG (1,(L"Tick Diff:%d\r\n",GetTickCount()-dwCurTick));


Result:Tick Diff:3 is printed for hundred times.


DWORD dwCnt, dwCurTick;

dwCurTick = GetTickCount();while(GetTickCount() - dwCurTick <= 200);
RETAILMSG (1,(L"Tick Diff:%d\r\n",GetTickCount()-dwCurTick));

Result: Tick Diff:201

So for accurate Tick Delays use the GetTickCount API.

Delay in Showing Windows Compact 7 Desktop Screen

We have created a new OS Design for our custom device.

The OS that we used is Windows Compact 7.

As part of the bring up process we are not adding all the catalog items but required catalog items only are added.

Somehow the touch driver got included and it takes almost 3 minutes to show up the Windows Compact 7 desktop. When we build a debug build it shows that TOUCH PROXY Driver is looking for something for 3 minutes.

When we add the BSP_NOTOUCH the display is shown quickly.

Some differences between Windows CE and Windows Desktop

The below table shows the some of the differences that I have thought of between Windows CE and Windows Desktop.

Windows CE
Windows Desktop
Componentized OS
OS is not Componentized
512 MB for CE 6.0 and 
3GB on Windows Compact 7

4 GB assuming 32-bit processors
Must have a display
ARM, MIPS, SH4 and x86
x86 and ARM
General Purpose OS
1mS Timer
15.6 mS Timer
Not based on Foreground process
Given priority to foreground process
Requires very less RAM order of MB
Order of MHz
Order of GHz
Less Storage Resources
More Resources
One root directory
Several root directories
Resolution of display can't be changed
Resolution can be changed at run time

Wednesday, November 26, 2014

Failed to initialize from CECONFIG.H


Today I noticed the following error: Failed to initialize from CECONFIG.H in Windows Compact 7.

I have added a new driver and thought of rebuilding only it. When I right click on it and gave a Rebuild command this error has occurred. When I verified the current configuration it shows as Debug. After that I opened the FLATRELEASE Directory and observed that the folder is empty (contains only three .bif files)

I realized that Clean Sysgen was not done in DEBUG mode.

When we switch the OS Design to Release mode, rebuild for the newly added driver succeeds.

So, the reason seems to be if Clean Sysgen is not performed in a configuration, performing a rebuild of a driver generates this error.

Thank you for visiting.

Thursday, May 22, 2014

Aborts in Windows CE

This article shows how to generate Prefetch Abort, Data Abort and Undefined Exception in Windows CE 6.0 R3

Data Abort

To generate the below exception a NULL pointer is written with some value

unsigned int *pu32Ptr = 23;

Exception 'Data Abort' (4): Thread-Id=08df001a(pth=847b8000), Proc-Id=08de001a(pprc=848059cc) 'Test.exe', VM-active=08de001a(pprc=848059cc) 'Test.exe'
PC=00011020(Test.exe+0x00001020) RA=000110f4(Test.exe+0x000010f4) SP=0002fbb4, BVA=00011040

Prefetch Abort

When a function pointer is assigned with a NULL Pointer Prefetch Abort is generated. This is learned after reading the following blog:

Exception 'Prefetch Abort' (3): Thread-Id=096d005e(pth=847b8000), Proc-Id=096b005e(pprc=848059cc) 'Test_NullFP.exe', VM-active=096b005e(pprc=848059cc) 'Test_NullFP.exe'
PC=00000000(???+0x00000000) RA=0001103c(Test_NullFP.exe+0x0000103c) SP=0002fba4, BVA=00000000

Undefined Instruction

When a function pointer is assigned with a variable's address the below exception is generated
Exception 'Undefined Instruction' (1): Thread-Id=09be0032(pth=8a86e0ac), Proc-Id=09bd0032(pprc=848059cc) 'Test.exe', VM-active=09bd0032(pprc=848059cc) 'Test.exe'
PC=0002fd14(???+0x0002fd14) RA=00011034(Test.exe+0x00001034) SP=0002fbb0, BVA=00000000


Thursday, March 27, 2014

Mutex, Semaphore and Spinlock

Some of the differences between Mutex and Semaphore in Windows CE

  • Is used for Mutual Exclusion
  • It has either TRUE or FALSE state
  • It is possible that if a thread takes the Mutex, then the same thread can unblock on the same Mutex
  • Mutex implements Priority Inheritance

  • It can be either binary or counting semaphore
  • Each time the thread waits on semaphore the count is decremented, once the count reaches zero it can't unblock on the same semaphore even though it is owned by the same thread
  • Semaphore doesn't implements the Priority Inheritance

  • From Windows Compact 7 documentation it shows that spin locks are supported as they have added SMP support