waiting in queue guys
I am an expert in WinCE driver to BSP development. I am too excellent in Linux development. I offer my services as consultant. Do mail me: exebinary@gmail.com Deeply involve in debugging and development activity. I am also available for training in Asia and International destination.
Friday, October 23, 2009
Thursday, October 22, 2009
What is the difference between *.nb0 and *.bin(nk.nb0 or nk.bin) !!! [WinCE]
Whenever we run the command romimage with one of the bib file like ce.bib then we get two images.
- nk.nb0 ( in case of ce.bib but name can vary like sam.nb0 depending on the target image name you want)
- nk.bin
So what is the difference between these two -
In case of .bin file, the following stuffs getting added one by one -
1. Image hdr "B000FF"
2. Image start address and image size.
3. Now make entry of dll/files under module sections.
4. Make entry for dll/files under FILES section in bib file here( ce.bib) in nk.bin with proper offset and entry point with allignment.
5. Allocate the space for rom header but that will be filled later after toc and other stuff. And as all information related to toc and other stuff will be ready after build process hence we will fill it after build process.
6. Now make entry in TOC about all dll.
7. Now wrtite the toc information into kernel which is available for TOC entry.
8. Write ROM Signature with it's offset.
8. Next all xip or files get entered into files. Hence depending on the need only the size of the file grows. Not like the nknb0 which takes all space allocated to OS.
Now lets give a look at nk.nb0 -
1. There no compression or ToC in nk.nb0. So it does not require support to get executed. The nk.nb0 can execute on self.
2. It's size can be determine from config.bib by getting the size of OS size. If the image is lesser then also it will consume the whole space and filled the rest of the area with zero.
This apply to both nk.nb0 or any type of .nb0.
I am planning to add more stuff here related to differences.
Tuesday, October 20, 2009
A thought!!! [WinCE]
I was thinking about WinCE once. How can any improvement is possible in WinCE. I thought one part. Basically this part can be implemented by OEM as well but because of the special attribute of Microsoft to make OEM less worried about writing code and after that also they should get better performance by the WinCE compare to other competitive company.
Here I am going to suggest Microsoft that include DMA as native driver. These days every OEM always use DMA controller to do most of their transfer stuff and there is sort of standard in it too.Using those feature they can ask users to just fill some of their prototype and get the best DMA driver of it.
In the driver, even there can implement fuzzy logic which will increase the performance of the WinCE. As everybody know he benefit of fuzzy but many of coder don't use this technique as it is some what complex because it will affect RAM performance too. I guess MS can do it.
Saturday, October 17, 2009
What should be prefix name? [WinCE]
One day, I was writing a sample driver. In the registry file platform.reg, while making entry for my sample driver, by mistake, I used S8M as prefix and it works fine.
I was surprised. Because I referred the link http://msdn.microsoft.com/en-us/library/aa447463.aspx
Which clearly says that "When you implement the stream interface, you designate the three-letter prefix. It can be any three letters, although you should use a common prefix, if your driver is the same class of device as other drivers".
It means it should not support other type of prefix.But it does. Just by seeing at the logic, I think that is correct way as other name like SM8 or 8SM does not work.
I am thinking whether it is wrong or write. But logically I agree this bug or wrong logic is correct but at the same time, MS should clearify in the same in their msdn part too. I think the time has come when people rely on article to resolve their problem. At this time it is must.
I would like everybody to share their reason to support or not support.
I was surprised. Because I referred the link http://msdn.microsoft.com/en-us/library/aa447463.aspx
Which clearly says that "When you implement the stream interface, you designate the three-letter prefix. It can be any three letters, although you should use a common prefix, if your driver is the same class of device as other drivers".
It means it should not support other type of prefix.But it does. Just by seeing at the logic, I think that is correct way as other name like SM8 or 8SM does not work.
I am thinking whether it is wrong or write. But logically I agree this bug or wrong logic is correct but at the same time, MS should clearify in the same in their msdn part too. I think the time has come when people rely on article to resolve their problem. At this time it is must.
I would like everybody to share their reason to support or not support.
Thursday, October 15, 2009
How to remove all prints from WinCE Image!!! [WinCE]
It is a common practice to remove all prints from the image which is going to ship to customer.
Now, depending on the requirement you can disable prints.
Like, if you want to disable debugmsg and retailmsg, then set WINCE_SHIP=1. It does not mean that it will work for other OAL prints related funtion. But if you want that there should not be any prints at all then, you need to disable com port itself.
You need to check function OEMWriteDebugByte, which is taking care of debug port.
Now, depending on the requirement you can disable prints.
Like, if you want to disable debugmsg and retailmsg, then set WINCE_SHIP=1. It does not mean that it will work for other OAL prints related funtion. But if you want that there should not be any prints at all then, you need to disable com port itself.
You need to check function OEMWriteDebugByte, which is taking care of debug port.
Wednesday, October 14, 2009
A Shortcut to Build your image!!!! [WinCE]
Hi,
Many times we see a problem of this dll is missing. What we do. We just find out the module compile it again and get dll and then build rel then make image. But think a scenario, when you have to include a dll which you can get only after sysgen the project. Looks cumbersome but there is a solution for it. The solution will give just a temporary solution so don't blindly rely on it.
Simply open ce.bib, then comment the particular dll by using semicolon(;).
Then run the command by opening the command window from menu bar(I guess name is like release to with msdos option. )
romimage /location of ce.bib/ce.bib
This will give output file. Also you always need to modify ce,bib whenever you wan to build an image.
Many times we see a problem of this dll is missing. What we do. We just find out the module compile it again and get dll and then build rel then make image. But think a scenario, when you have to include a dll which you can get only after sysgen the project. Looks cumbersome but there is a solution for it. The solution will give just a temporary solution so don't blindly rely on it.
Simply open ce.bib, then comment the particular dll by using semicolon(;).
Then run the command by opening the command window from menu bar(I guess name is like release to with msdos option. )
romimage /location of ce.bib/ce.bib
This will give output file. Also you always need to modify ce,bib whenever you wan to build an image.
Why we should not use platform builder to include or exclude a module!!! [WinCE]
Many time we wish to remove or add a module in project. We usually follow two technique.
1. Edit the dirs file
2. Right click the module in platform builder and select exclude from build.
Both works fine.
But in few scenario, second option can cause problem.
Suppose you have two folder lets say A and B.
After building A, we get A.lib. And similarly after building B, we get B.dll but this B.dll uses A.lib to build successfully. Now if you want to remove B, so you would like to remove A and B, both. So you might use the sequence, First A then B or B first then A.
So in the same way, actually module get deleted from dirs file also. So once you plan to include, the module will be added at the end of dirs file. Hence once you choosed B first and then A. In that case, either the b.dll will not be build successfully or it will be build with old A.lib, hence your changes in A.Lib will not be reflected(if you are not going to build A.lib again).
Hence it is wisely suggested that always edit dirs directly.
1. Edit the dirs file
2. Right click the module in platform builder and select exclude from build.
Both works fine.
But in few scenario, second option can cause problem.
Suppose you have two folder lets say A and B.
After building A, we get A.lib. And similarly after building B, we get B.dll but this B.dll uses A.lib to build successfully. Now if you want to remove B, so you would like to remove A and B, both. So you might use the sequence, First A then B or B first then A.
So in the same way, actually module get deleted from dirs file also. So once you plan to include, the module will be added at the end of dirs file. Hence once you choosed B first and then A. In that case, either the b.dll will not be build successfully or it will be build with old A.lib, hence your changes in A.Lib will not be reflected(if you are not going to build A.lib again).
Hence it is wisely suggested that always edit dirs directly.
Tuesday, October 13, 2009
How VirtualAlloc works!!! [WinCE]
VirturlAlloc internally call SC_VirtualAlloc.
As you know that this api take parameters like the desired address of area assigned and size of file and flags related to action on the region given and access type on the region.
Now I will explain only the use case in which it will give the desired result not the else part.
;)
It start with checking the desired address whether it is inside kernel address and also check for access type and action on region whether it's supported or not.
Check if the request region is under secure VA. If not then calculate the base address of the region assigned just by left shifting the address asked for. Now check the address that it's come under first mapper add or not if yes then check for the process to check the remotely memory is accessed by the current process.
Now check for the allocate type.
Now check whether the request is for slot 0. If yes then take the 64k booundary. and check for the free region.
To check for NULL block.
If the request is not for Slot 0 then use filesystem to reserve the region.
Check the condition like requested region is more than 32MB then find the continuous memory.
* Still Not Completed
Saturday, October 10, 2009
How mounting works with FAT Filesystem [WinCE]
Mounting means attaching a disk to a filesystem.
When mount option get selected in the storage manager, these are following operations performed:
- It asked for device information. It will check against read only and set the variable as if after set, it will be read-only disk.
- Now it will get device info and will set FAT FS for the device flag variable.
- Find out the total number of sectors.
- There is read and write operation performed on the disk for which we allocate a buffer. It’s an interesting operation. There is two term FAT Cache and Data Cache comes into picture. FAT Cache is cache of actual sector which comprises the FAT table. Necessity of FAT Cache is that it allow to access very large chunk of files hence we have to traverse in the table of 2^17 for 32k clusters. So with increasing the FAT cache size will resolve the traversing so long. Data Cache is to keeping the cache of file names with a directory. Like to create a new file in a directory will lead to check all file name and then only we can use the new file name.
Using the registry you can increase or decrease
[HKEY_LOCAL_MACHINE\System\StorageManager\FATFS]
"FatCacheSize"=0xXXXXX - Size of the FAT Table Cache
"DataCacheSize"=0xXXXX - Size of the Data Cache
It also checks for cache ID. If it does not exist it also means that the area if for boot and it’s cache disable so there will be normal read and write operation will happen but if it is under cache ID the read or write operation will only perform on the cache. No direct access will be on the sector.
It also finished the reading and writing of disk.
- Now it will find the volume. It also means that it will check for the same volume name and will add the new disk name to the disk link list structure.
- It will now mount the volume with the filesystem. In turn will perform the following operation:
- Open the volume – It first tries to find the volume. If it does not exist then will create one. Then initialize the volume. This operation makes sure that all registry entry parameter is added with volume. Also the volume structure contains all information from size of volume to cluster related parameter. The cluster related value will contain take care of root directory to nested one.
- Refresh the volume – This operation required as it can have many open handle. We do even if we have invalid volume.
- Format volume if it unformatted or invalid or read only or other invalid conditions – This will format the volume again if required.
- Register the volume with filesystem – It will give a name to the volume.
- Close the volume – Close the volume handle. This operation comes in picture only if we can’t allocate enough buffers or there is any problem in registering with the file system.
Note: In all these operation, we are using HeapAlloc not VirtualAlloc. The reason is that it will allocate the size of memory asked for not in 4k chuck or what ever like VirtualAlloc.
Friday, October 9, 2009
How KernelRelocate works? [WinCE]
KernelRelocate is one of the most interesting function I found in WinCE. Frankly, I am feeling happy to share the details and how exactly it works.
The pTOC variable is in nk.exe which is feed by ROMIMAGE
This function copies all the copy entries described by the pTOC to RAM. The process of changing an EXE or DLL program file after it has been loaded to reflect the actual load address is called “fixing up”. The variable pTOC actually have information about all dll and exe and where it has to be relocated. It know where RAM starts as ROMIMAGE use config.bib to feed the information. The information is feed by ROMIMAGE tool.
There is basic requirement of the relocation that when nk.exe call any of the dll or exe. It actually calls at RAM location to execution function instead of where it was copied by steploader. Also a steploader just copied data bit by bit although that is RAM. But NK.exe always access different address.
This is actually what is happening. pTOC variable have every information about RAM and where the dll and exe is lie in.
- //
- // KernelRelocate: move global variables to RAM
- //
- static BOOL KernelRelocate (ROMHDR *const pTOC)
- {
- ULONG loop;
- COPYentry *cptr;
- if (pTOC == (ROMHDR *const) -1) {
- return FALSE; // spin forever!
- }
- // This is where the data sections become valid... don't read globals until after this
- for (loop = 0; loop <>ulCopyEntries; loop++) {
- cptr = (COPYentry *)(pTOC->ulCopyOffset + loop*sizeof(COPYentry));
- if (cptr->ulCopyLen)
- memcpy((LPVOID)cptr->ulDest,(LPVOID)cptr->ulSource,cptr->ulCopyLen);
- if (cptr->ulCopyLen != cptr->ulDestLen)
- memset((LPVOID)(cptr->ulDest+cptr->ulCopyLen),0,cptr->ulDestLen-cptr->ulCopyLen);
- }
- return TRUE;
- }
Monday, October 5, 2009
Who calls all Stream interface function!!! [WinCE]
Hello Developers,
Since so many days, I was thinking that it will be better if everybody know, which function calls all stream interface function.. Like xxx_Init or whatever.
Find out the crisp form of information.
2. XXX_Open - Called by CreateFile which in turn return a handle for the Handle.
3. XXX_Close - Called by CloseHandle.
5. XXX_Write - Called by WriteFile
7. XXX_Seek - Called by SetFilePointer
8. DllEntry - Called by LoadLibrary.
10. XXX_PreClose - Same as case of XXX_PreDeinit
11. XXX_PowerUp - Called by DevMgrPowerOffHandler by Device manager. In turn, OS kernel.
12. XXX_PowerDown - Called by DevMgrPowerOffHandler by Device manager. In turn, OS kernel.
Sunday, October 4, 2009
How Warm Boot is Implemented? [WinCE]
Usually Images stored in Flash media in the following manner:
1. Store eboot(include piece of code which will copy NK.BIN to RAM too) and NK.BIN in FLASH together.
2. At startup, eboot copy nk.bin into RAM and then jump to address (0x800XYYYY address of NK.BIN in RAM) when image is copied.
3. In warm boot, we issue JUMP instruction to PC to start from NK.BIN address at RAM(0x800XYYYY).
Warm boot is use to retain data into image even after reset. Cold boot will restored the system to it's previous state.
4. Before validating the warm boot, re validate flow as well.
Note: the following line
memset((LPVOID)RomHdr.ulRAMStart, 0, RomHdr.ulRAMEnd - RomHdr.ulRAMStart)
Clears the RAM addresses, make sure it is not getting called.
Subscribe to:
Posts (Atom)