I had the same issue (drone flipped) seems I inverted a connection on one of the motors. Would be great to have a way to control before take off.
Following.
A flip is 99.9% of the time related to getting the motor order and/or spin direction wrong.
Use MissionPlanner motor test to check the spin of the props and the motor order.
The letters in motor test are different to the servo numbering of motors.
The letters always start at front right and go around clockwise no matter if you have a quad, hex or octo.
So you wire it all up according to the NUMBERS then test according to the LETTERS - pressing the MotorB test button should spin motor4 in the case of a Quad/X