How to install Android to any phone very first time? I know this sounds weird one. But I have a Motorola Photon 4g which has got corrupted or some unstable ROM. I am facing 15-20 blackouts and restarts. This led to think like that.

I want to know the procedure for flashing the very first time to phone. That is when the company manufactures the phone. It is has nothing. So they must follow some steps to make it alive. OR Simply, how do they flash the phone? What are the tools and steps they follow? I want that. I knew it must be somewhere on google. But I am not able to find those stuffs. Any help on those direction will be a great help.

or 

Any generic way to completely format and install ROM as we do in our desktop. From boot completely erases the HDD , repartition and instally any desired OS to it (I know in case of Android ROMs, its is restricted to Phones and their basebands.)
The short answer is that it's different for each phone. There's no generic "install Android" procedure for two reasons:


Unlike on a PC, where the Windows installer or Debian installer has drivers to access (almost) any PC hardware, in embedded devices each model needs a ROM image specific to that combination of hardware. The first part of any installation procedure is to download or compile a ROM image for the device you're going to install it on.
The steps to follow to install the ROM are different for each device. Different devices have the internal storage configured and partitioned differently. Some manufacturers may use their own tool in place of fastboot. And of course some hardware might require special measures to access it, such as changing jumpers on the board, or connecting to special pins not normally accessible. Most devices don't need anything so extreme, but even in the easy cases it's important to get all the command parameters correct.


Manufacturers don't have a problem with this because each production line only needs to flash one kind of device. They don't actually have someone sitting there typing fastboot commands over and over again: they use special-purpose hardware and software to flash many devices as quickly as possible. Only those who design the production line or work in the factory know exactly what steps they take to initialize each device.