dpiralis:
How can you write firmware for HC-05?
You can't able to write firmware for this one. The firmware belongs to the manufacturer and you can only able to upload a different firmware version into it. But I think what you mean is programming for it. Yes, you can by AT commands. You can set, check the communication speed, module name, operation mode, IO pins etc...