What is the best way to completely wipe a P4?

The reason for asking is I had some issues, but since its been upgraded a couple of times so it might be my fault.

I would like to see if the best way could be to completely wipe the P4, firmware and everything to make sure its completely clean before starting over. (I tried a reset, but I would like to do the firmware too, internal storage etc too) and hopefully that will solve my problems.