Monday, September 28, 2009

Released a new ROM for the i780

I've just released a new ROM for the Samsung i780 on XDA-Developers. The ROM is based on WM6.5 23053 build and the focus has been on having really nice revamped graphics and performance! The ROM is a 96dpi build, but features 128 dpi high res icons with a 3 column programs list.

Here are the features -
- Fixed initial buttons default config
- 128 DPI bigger 3 column programs list with high res icons!
- New custom theme designed for the i780
- Square soft key buttons (no more oval crap!), Checkboxes, radio buttons, buttons etc. with new cool graphics (choose dt39AllBlack theme to activate these)
- Softkey menu popups are the right size and have shadowed menu borders (not too big or too small )
- Lots of reg tweaks to improve performance
- Programs list scrolls seamlessly till the end
- Separate version with English ROM and Russian keyboard

Check out the XDA-Developers thread here -


Sunday, September 20, 2009

Part IV: Removing packages!

In the previous section, we went through the SYS folder in detail. Now, its time to dab a little into how you can remove packages from your ROM to clean up unwanted stuff!

Removing Packages
To remove a package, simply delete the directory with the app! Now, the caveats -
1. If this package is cross referenced by some other application/module, that'll have issues
2. Its a bad idea to remove certain core applications (For example, removing the phone application is just a crazy idea ;))
3. Lets run through an example here. We could remove "WindowsLive" application/package by just deleting the following folders from your SYS folder - "WindowsLive", "WindowsLive_DPI_96", "WindowsLive_Lang_0409", "WindowsLiveIM". Doing this is safe, and does not affect any other application - so you could go ahead and get rid of this altogether without compromising runtime integrity.

Why remove packages?
Its a good idea to keep the device clean and weed out all the rubbish! The idea is to free up space for some other custom application we can put into it instead which is of more value!

What does a package folder contain?
A package normally contains the following contents -
1. A .dsm file -
This file defines "what is present in that folder". You can build a .dsm file using the tool "buildDSM". Not populating DSM files just make it harder to extract the rom correctly and hence is a good practice to generate these files. When you dump a ROM, you will find .dsm files with each package. Its only when you create your own custom package to insert into a ROM, its a good idea to generate .dsm files. This is however made easy using Ervius' package creator tool. I shall cover creating and adding packages in the next post in detail!
2. A .rgu file -
A .rgu file contains the registry information that needs to be added for this package. This is a standard registry settings file. One could use this to add custom registry entries to tweak the OS and deploy it in this manner! So, a package can sometimes contain just a .rgu file with some registry keys/info to apply onto the device!
3. Files/folders
Now, this calls for talking a little about "Modules" and "Files"!
Some of the files (.exe, .dll, .mui, .cpl files) can exist either as a "Module" or as a "File". You can identify a "Module" when you see a directory which has the name of a file! For example, look inside the "Phone" package - you see a bunch of directories which are actually names of files! An executable/dll/mui/cpl file can be converted into a "Module" and this makes it much quicker to execute at runtime. Thats an advantage right, so we can have all of them saved up as modules right? Whats the catch?

Modules - the catch!
The number of modules we can have should not exceed 32Megs in total on a WM6.1 kernel! So, the total number of modules you have in your rom should never go beyond this limit! For our Samsung i780 devices, we still have a WM6.1 kernel and we have to thereby live with this memory limitation. There is a tool called Recmod.exe which helps you convert a "Module" to a file. So, a ROM chef needs to convert some modules to files to make sure that you don't go over the limit. An easy way of finding if you're in the safe zone is by just checking folder properties of the SYS folder and ensuring the total number of directories are under 510.

IMPORTANT: Some "Modules" don't like being converted to files! They don't convert properly OR have problems at runtime! So, its best practice to leave all the core operating system components as modules and not convert them to files. Examples -
1. BASE_DPI_96 folder
DO NOT convert the modules in this folder to files - you would like to leave core OS components as modules to get better performance, and also not risk the probability of run time failures/issues
2. AdobeFlash folder
Feel free to convert whatever modules you have into files! You really don't need run time performance for this!
3. WindowsLive and all its collateral crap!
All these are non-critical apps, convert all the modules you can find into files to save on memory available!

What I basically do is, I leave BASE_DPI, BASE_LANG, OS, MediaOS, CHome, Redist, BaseApps, Enterprise, NetCF, Riched, Phone folders as modules - DO NOT convert them to files as they're bound to throw some errors at runtime! What you should do is clean up the other application packages to bring your rom to have the number of modules under the limit that we have!

More on this later, in another post! I shall explain how to convert files/modules back and forth, best practices, tools you need etc.!

A quick recap on removing packages - Just delete the folder! Simple :) You need to be sure that they are not cross referenced, or we might have issues at runtime/bootup etc. Another example I can think of is a package called "SQM". This stands for System Quality Metrics (Customer feedback as we all know it ;)). You might think you could just delete this and get rid of customer feedback within the OS....but it turns out that the DLL files are cross referenced and used by many other apps! So, getting rid of it is not as straight forward ;)

Thats it for now guys! cheers :)

Friday, September 18, 2009

Part III: Understanding whats going on in the "SYS" folder!

In my previous post, I've shown how to organize the dump folder by segregating all files/folders/apps/modules under two main top level folders "OEM" & "SYS" folders. A quick recap tells us that OEM folders are device manufacturer specific files which are specific to your device. These are usually different drivers for your device hardware along with certain software customization (new apps, reg tweaks etc.) that your manufacture has thrown in.

The SYS folder contains the core operating system built by windows. It can be compared to the "Windows" folder on your desktop, for instance, on a broad level to help understand better :)

In this part, I shall cover details of what you'll find in the SYS folder, what can be tweaked, the folder structure etc. This is important to know especially if you are trying to -

  1. Port a new build of the operating system! (Every time a new build of Windows mobile is released, a cook replaces contents of the SYS folder with the updated files and prepares a new build! All the WM6.5 230xx builds are all new set of files and folders dumped into the SYS folder which are made in redmond and leaked ;))
  2. Customize, hack, modify contents here to tweak the OS
  3. Create a build to support a different language


SYS Folder: Explaining further!
Here's a screenshot of the folders that are present in the SYS folder (click on graphic to enlarge) -

The main things you should notice in this screenshot are the following -
  1. Different folders thrown in with the name of the app/module. For example - "BROWSING". This, obviously, contains files and content related to your internet browse MS provides as default : that is, IE (Internet Explorer). Similarly you have many other apps out there that you can see, which all make the OS that we use on our device!
  2. You can also see that the folder "BROWSING" has two more folders alongside called "Browsing_DPI_128" and "Browsing_Lang_0409". More on this in a bit!
  3. Sometimes you'll find a folder defining the resolution of the device instead or along with the DPI folder, such as "Phone_dpi_128_resh_320_resv_320".

Explaining this structure
The main folder contains the base application. Example: "BROWSING" folder that you see. The other two folders that are provided along are basically content/data that is picked up by the application (in the example "IE or iexplore.exe").

The "Browsing_Lang_0409" folder provides language customization. Here the code "0409" is for "English". So all your language customization folders for "English" will ALWAYS end with "0409"! So, if you want to change the OS' language to some other language, you'll need to knock off all the 0409 folders, and replace with corresponding "XXXX" code folders that are taken from the same build of Windows Mobile! For example, if you're using WM6.5 23049 OS build in your SYS folder, then all the Lang files should be taken by what was issued by Microsoft specific for 23049 build. Sometimes, you could use lang folders from a different/other build and port, but you might have issues/bugs within the OS at runtime.

The "Browsing_DPI_128" basically will contain graphic resources, dialog boxes designed and other related visual media/content which is designed for "128 DPI". The concept of "DPI" is explained further at the end. So, if you are trying to create a 128 DPI build of the OS, you need to drop all the folders which say "DPI_128" into the sys folder.

Sometimes, applications have different sets of graphics not just differentiated based on the target DPI, but target DPI AND Resolution. This purely depends on the way the application is written! So, to give you an example, see the "Phone" application! The Phone application has both a DPI folder with bunch of resources/graphics designed for 128 dpi AND some more graphics and resources for a "320x320" resolution device! You'll find two folders - Phone_dpi_128_resh_320_resv_320 & "Phone_DPI_128"!

Some apps/modules do not require/have any language or DPI customizations and might have these folders missing, which normal - just the way the application is designed. For instance, the application might have ONLY english support and is resolution aware and doesnt have separate folders/graphics for different resolutions.

A quick recap - taking the "Phone" application as an example here. The folders related to the phone app are -
  1. Phone - the base application!
  2. Phone_DPI_128 - 128 dpi specific graphics/content
  3. Phone_dpi_128_resh_320_resv_320 - some more graphics/content specific to 320x320 resolution devices, with 128 dpi graphics
  4. Phone_Lang_0409 - Language files for English

So the Phone module here, will run on "English language" at "128 dpi" designed for "320x320" resolution. Its usually the job of the cook to decide which dpi he would cook the rom, and take appropriate folders from the files provided by Microsoft.

IMPORTANT: YOU WILL FIND TWO FOLDERS NAMED ".ROM" & ".VM". These folders should always be taken from your original working ROM that you disassembled! DO NOT replace with any other .ROM or .VM folder!

Get your self well acquainted with the SYS folder! In terms of what apps you can find, the lang files etc. I'll try and cover the OEM folder in detail in my next post ;)

Monday, September 14, 2009

Part II: Organizing your dump folder!


The BIN file of your ROM (assuming only PDA section - not covering Phone/EBOOT) has the following partitions/info sandwiched into it -
**************************************
Part-0 type: BOOT SECTION image
Part-1 type: XIP RAM Image
Part-2 type: IMGFS file system
Part-3 type: legit DOS partition
**************************************

All these partitions are contained in "i780.nb0.payload" file that you had generated in the dump process (as explained in my previous post). So, to start modifying the ROM, you need to be able to extract separate portions of this, modify and put them back together with various different tools. In the previous post, I've explained how to use "prepare_imgfs" & "ImgfsToDump" to take the "Part-2 section" (the IMGFS file system part) and dump its
contents. The dump folder now contains all the files and folders "disorganized" inside of it. Now, its time to clean this up and put them into "SYS" & "OEM" folders. Remember, here, we aren't yet messing around with the XIP section! I shall cover the XIP section, porting, tweaking and modifying in a later post ;)

The Next Step!
Now, its time to segregate the files, modules and folders into OEM and SYS folders. To do this, you'd need "Ervius' PkgToolsBuildOs tool". I use version 5.3 (which is the latest at the moment). The file name is PkgToolsBuildOS-5.3.exe. Start this tool and click on "Open". Point it to your "dump" folder that you generated as explained in the previous post. Here's a picture of what it should look like -

Once you've clicked "OK" PkgTools should show some details. Click on "Build Packages" button on top, leaving all other settings as it is. This should take a while, and once its done, your "dump" folder is now cleaned up with all modules/files going into a nice folder structure. You have two main folders now in your "dump" folder - OEM & SYS folders.

The OEM Folder
In this folder, you'll find all customization, drivers, extra applications that your device manufacturer has added. Some folders are important for the device to function correctly (for instance the Drivers folder) and care should be taken while modifying contents in the OEM folder. I shall cover details on customization of the contents in your OEM/SYS folders in a separate post. I'd recommend that you start browsing around these folders to get a handle on how things are organized!

The SYS Folder
This folder contains the Operating System that Microsoft has provided. Ideally this will be common on all devices, and all of this comes from Microsoft. However, some cooks might have dropped in some of their customizations into this folder as well, which you might end up finding! The SYS folder contains all your applications (Phone, MS Office, CORE OS, etc. etc.), the language specific folders, DPI specific folders (Depending on the resolution of the device). These shall be covered in detail in a future post!

Do this for a few custom ROMs out there, and get your feet wet on how each ROM has its dumped contents!

Thats it for now, if you have trouble finding any of the tools or understanding, write under comments!

Part 1: How To DUMP an Existing ROM


Here's the first installment of the series :) This flowchart above clearly shows the 1st Phase in ROM Development. The steps taken above takes an existing i780 ROM (this can be one of the custom ROMS created by other chefs, or can be one of the stock ROMs provided by Samsung). The basic idea is to start with a template ROM which is good/stable/well customized and then customize this with your changes.

The main steps, at a birds eye level, that you would do is -
1. Start with a good existing ROM as a template ROM to customize
2. "Dump" the ROM
3. Segregate the "dumped files" into OEM/SYS folders (more on this later!)
4. Customize different applications/media/registry entries within the OEM/SYS folders
5. Rebuild the BIN (ROM) file

The first step for dumping is explained in the flowchart above! The tools you'd need for this are -
1. BinToNB0.exe
2. NBSplit.exe
3. Split.exe
4. prepare_imgfs.exe
5. ImgfsToDump.exe

The flowchart is self explanatory, post any questions in the comments if something doesn't make sense ;)



The traditional "First" post!

I've decided to start a separate blog dedicated to i780 ROM cooking and development. I shall slowly post info on how to cook ROMS, tools that you'd need to use, and detailed steps on how to cook your own custom ROMS for the Samsung i780. The blog will also act as a journal for my own self ;)

The i780 happens to be one of the best WinMo devices i've ever used in terms of stability (No soft resets, crashes, lock ups, nothing!!! Unlike all other HTC built devices), performance (Video performance, overall usability is unmatched) and form factor.

Thats it for now! On my next blog post, I'll write about the basics of ROM cooking.

Cheers!