“Is there a way to jailbreak iPhone with firmware 3.1.2?”
I just came across a video recently of someone using a program called Blackra1n to jailbreak a 2nd generation iPod touch. Blackra1n can also jailbreak iPhones 3G and 3GS running 3.1.2 software or 3.1.
Blackra1n won’t unlock the iPhone for switching to a different carrier but it will give you the ability to run unofficial apps and features on the phone.
This video tutorial shows you the steps in detail on how to jailbreak the iPhone just in case you’re a bit hesitant. Watch the video a few times if you need to. There’s also a nice tutorial with images at iClarified.
There’s always a risk when you do something like this so be sure to back up your data before proceeding.