If the domain controllers were not able to communicate when you demoted DC01, then you need to take the followings steps. You can google the specifics of each step.
1) Use DC02 to seize the FSMO roles (assuming they belonged to DC01 before the demotion).
2) Clean the orphaned DC from active directory
3) Promote DC01 to a domain controller
4) Move the 5 FSMO roles to DC01 (there are no Primary Domain controller anymore, but this is what most people want when they say they want a DC to be the primary one. If you are thinking along those lines, you might also be interested in reviewing which DC is authoritative for DNS zones and which one does DNS scavenging if it is enabled)