Lesson 4, xip and hive
Power
Our image mainly consists of two parts: xipkernel. BIN and NK. bin, xipkernel. bin contains some programs and DLL files that are core and frequently loaded in wince. These files will be copied to ram by the boot loader at startup, in this way, you can use the xip (excute in place) in Ram. Hosts can also be stored here. These files are copied to the memory for execution only when necessary, saving the memory and accelerating the startup time. Hey, here we will probably know the working principle and importance of binfs.
Binfs automatically saves xipkernel and NK to the specific logical sector of flash when burning the image. at startup, the boot handler is in NK. in bin, then you can use/binfs/device.exe (/binfs is a hypothetical installation package to invoke it. If the binfs is not successfully completed at this time, device.exe cannot be executed, then the system will surely fail.
Now let's talk about hive. In fact, hive is a very simple thing. It's strange that we have been working together with binfs to make many problems wrong. in this case, there are two types of registries, Ram-based and hive-based. The former is used by default. If the former is used, Pb will compile the common. reg and platform. reg is called reginit. INI files are then compressed to default. * ** the file is placed in xipkernel. When the image is up, it will decompress the file to ram to form a ram-based registry, since it is Ram-based, all changes will evaporate after power failure, haha. What should we do? Actually, you can think of it again. Isn't it enough to save it to the disk !? It's too clever for you, but if you want to put the entire registry on a disk (sdmmc, HDD, or flash), how does wince read the Registry without loading the drive of your disk? In general, the driver for loading the disk also requires registry support! Hey, by the way, this is what hive thought of. It depends on how it is done. It divides the Registry into two parts (in fact, three parts. At that time, there were two steps to divide the user. HV and system. the first part is boot. the HV registry contains some settings required for booting before obtaining the Registry saved on the disk. The Registry and ram-based are the same, after the change, the power is lost, so the registry keys in this part do not need to be changed. All the changes need to be placed in the second part, and the second part is system. HV and user. HV, that is, the Registry to be put on the disk. during compilation, Pb will be based on platform. reg and common. the label in Reg determines which table items are put in Boot. in HV, this label is; hive boot section; end boot section, which inserts the table item Pb between the labels into Boot during compilation. remove (boot. HV is a binary file. It depends on the tables in it. In NK. Bin, binfs must be available in the first stage. Otherwise, it is impossible to create conditions for system. HV. When wince is started for the first time, there is no Dongdong on the disk. At this time, WinCE will default the memory. HV and user. copy HV to the location specified by bootvars in the registry, default. HV is often renamed to system. for the second startup, check whether the HV on the disk is consistent with that in the memory. If they are inconsistent, load the table items on the disk.
The whole process is like this, but note that the hive Registry is also running in the memory. The difference is that the modified table items will be read from the disk at startup, this ensures the speed, so the Registry changes you make are also made in the memory, at this time, if you use flushregister to save the values in the memory to the disk, these changes will still be lost. Two methods to avoid loss. One is to call flushregister and set a flag so that wince will automatically flush after each registry change.
Summary:
1. Create a new project and select all the selected components.
2. Add hive support.
A. Add "hive-based registry" and "FAT file system" to Pb ".
B. Open Platform. Reg and complete the following information:
; Hive boot section
[HKEY_LOCAL_MACHINE/init/bootvars]
"Systemhive" = "Documents and Settings // system. HV"; system. HV is saved to/HDD/Documents and Settings/system. HV.
"Profiledir" = "Documents and Settings"; user. HV is saved to/HDD/Documents and Settings/default/user. HV.
"Start devmgr" = DWORD: 1 then this is to start device.exe, but it seems that wince 5.0 does not need this
"Defaultuser" = "default"; we only have one user default, which basically decides the path of user. HV.
"Flags" = DWORD: 3; this should be the table item in which device.exe is started under wince 5.0.
"Registryflags" = DWORD: 1; this is to set the Registry to automatically flush to system. HV after each change
; "Systemhiveinitialsize" = DWORD: 19000; initial size for hive-Registry File
; End hive boot section
; ######################################## ######################################## #####################
; Hive boot section
; Add binfs to partition table
[HKEY_LOCAL_MACHINE/system/storagemanager/partitiontable]
"21" = "binfs"
[HKEY_LOCAL_MACHINE/system/storagemanager/binfs]
"Folder" = "binfs"
"Friendlyname" = "bin filesystem"
"DLL" = "binfs. dll"
; Mountflags:
; 0x10 specifies that this file system is to be mounted as an external
; Rom filesystem shadowing the/Windows Directory
; 0x1 specifies that the mountpoint/binfs is to be hidden
;
"Mountflags" = DWORD: 10
"Bootphase" = DWORD: 0
[HKEY_LOCAL_MACHINE/system/storagemanager/autoload/smflash]
"Driverpath" = "drivers // blockdevice // smflash"
"Loadflags" = DWORD: 1
"Mountflags" = DWORD: 11
"Bootphase" = DWORD: 0
[HKEY_LOCAL_MACHINE/Drivers/blockdevice/smflash]
"Prefix" = "DSK"
"DLL" = "bibdrv. dll"
"Order" = DWORD: 0
"IOCTL" = DWORD: 4
"Profile" = "smflash"
"Friendlyname" = "Samsung Flash Driver"
"Mountflags" = DWORD: 11
"Bootphase" = DWORD: 0
; Bind binfs to the block driver
[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/smflash]
"Defaultfilesystem" = "binfs"
"Partitiondriver" = "mspart. dll"
"Automount" = DWORD: 1
"Autopart" = DWORD: 1
"Mountflags" = DWORD: 11
"Folder" = "residentflash"
"Name" = "Samsung flash disk"
"Bootphase" = DWORD: 0; binfs must be loaded in the first phase.
[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/nandflash/binfs]
"Mounthidden" = DWORD: 1
"Mountasrom" = DWORD: 1
[HKEY_LOCAL_MACHINE/system/storagemanager/autoload/smflash/filters/cachefilt]
"DLL" = "cachefilt. dll"
"Lockiobuffers" = DWORD: 1
; End hive boot section
; ######################################## ######################################## #####################
; 1st fat area
; Hive boot section
[HKEY_LOCAL_MACHINE/Drivers/builtin/FlashDisk]
"Prefix" = "DSK"
"DLL" = "ondisk. dll"
"Order" = DWORD: 1
; "Index" = DWORD: 1
"Iclass" = multi_sz: "{A4E7EDDA-E575-4252-9D6B-4195D48BB865 }"
"Profile" = "FlashDisk"
"Bmlvolumeid" = DWORD: 0; BML volume id = 0
"Bmlpartitionid" = DWORD: 8; BML parition id = partition_id_filesystem
"Wmrstartsector" = DWORD: 0
"Wmrnumofsector" = DWORD: 40000; 128 Mbyte
; "Flags" = DWORD: 11000; Do not load again in Boot Phase 2;
If imghivereg
"Flags" = DWORD: 1000; Do not load again in Boot Phase 2;
Endif imghivereg
[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/FlashDisk]
"Defaultfilesystem" = "fatfs"
"Partitiondriver" = "mspart. dll"
"Name" = "pocketmory MLC disk"
; "Folder" = "sys"
"Automount" = DWORD: 1
"Autopart" = DWORD: 1
"AutoFormat" = DWORD: 1
; "Mountflags" = DWORD: 0
; "IOCTL" = DWORD: 4
If imghivereg
"Mountasbootable" = DWORD: 1; for hive-based registry, which is the key to specifying this partition in wince 5.0 to store system. HV
Endif imghivereg
[HKEY_LOCAL_MACHINE/system/storagemanager/autoload/FlashDisk]
"Driverpath" = "drivers // builtin // FlashDisk"
; Loadflags 0x01 = load synchronously
"Loadflags" = DWORD: 1
"Bootphase" = DWORD: 0
[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/FlashDisk/fatfs]
"Friendlyname" = "pocketmory fat filesystem"
; "DLL" = "fatfsd. dll"
"Flags" = DWORD: 00000014; fatfs_enable_backup_fat | fatfs_disable_autoscan
"Folder" = "sys"
"Formatexfat" = DWORD: 1
; "Enablecachewarm" = DWORD: 0
"Checkforformat" = DWORD: 1
"Enablewriteback" = DWORD: 1
"Enablecachewarm" = DWORD: 0
[HKEY_LOCAL_MACHINE/system/storagemanager/autoload/FlashDisk/filters/cachefilt]
"DLL" = "cachefilt. dll"
"Lockiobuffers" = DWORD: 1
[HKEY_LOCAL_MACHINE/system/storagemanager/profiles/FlashDisk/fatfs/filters/cachefilt]
"DLL" = "cachefilt. dll"
"Lockiobuffers" = DWORD: 1
; End hive boot section
; ######################################## ######################################## #####################
3. Enable smdk6410/smdk6410.bat and xip
Set imgmultixip = 1
4. modify files/config. bib
The following layout can be changed as needed to adapt to your system. Pay attention to the layout rule.
# Define chain_address 806c0000
# Define chain_length 00004000
;-----------------------------------------------------
; Name address size type
;-----------------------------------------------------
Xipkernel 80100000 005c0000 ramimage
Chain $ (chain_address) $ (chain_length) Reserved
NK 80700000 03f00000 nandimage
Ram 80700000 05600000 Ram
Flash 92000000 00100000 Reserved
5. modify files/platform. bib.
Change all NK to $ (xipkernel). In order to load the peripheral driver to the memory at xipkernel startup, the peripheral device cannot be used.
6. Add the smallest system file. The files to be added include:
// Required
"Nk.exe ",
"Coredll. dll ",
"Filesys. dll ",
"Exfat. dll ",
"Diskcache. dll ",
"Fatutil. dll ",
"Binfs. dll ",
"Fsdmgr. dll ",
"Mspart. dll ",
"Ceddk. dll ",
"Cachefilt. dll ",
"Kernel. dll ",
"K. coredll. dll ",
"Fpcrt. dll ",
"K. fpcrt. dll ",
"Romfsd. dll ",
"Device. dll ",
"Udevice.exe ",
"Devmgr. dll ",
"Kitl. dll ",
"PM. dll ",
"Devmgr. dll ",
"Wince. NLS ",
"Initobj. dat ",
"Ondisk. dll ",
"Initdb. ini ",
"Boot. HV ",
// We recommend that you continue to add
"Busenum. dll ",
"Servicesenum. dll ",
"Servicesd.exe ",
"Services.exe ",
"Servicesstart.exe ",
"Oalioctl. dll ",
There are three ways to add:
1. compile the project once, modify common. bib under build, and change all corresponding items to xipkernel and make image. (Note: Only make image can be used)
2. compile the project once, modify Ce. bib under build, and change all corresponding items to xipkernel. In vs2005, run project-> open realkernel...
Romimage Ce. bib (note: this is the only option)
3.add processbib.exe and preromimage. bat in the attachment to files/and build the project. After compilation, you can directly make image. We recommend this method once and for all, and it is not easy to make operations and errors.
7. Use eboot to burn xip. Bin.