Algorithm for setting up the first flight

Greetings, experts!
Please tell me the algorithm for the initial setup and tuning for the first flight. On the official website of ArduPilot it is not very clear.

I assembled my first hexacopter based on Pixhawk 2.4.8. I read the instructions on the official website, but apparently not carefully (as I later realized). During the first flight in manual mode (Stabilization), he flew, but was constantly spinning around his axis. In LOITER mode and during RTL it began to sway and it turned over.
After the repair, I already started looking for information, Googled a plate in Excel with a calculation of the PID controller, set it up, but haven’t taken it into the air yet.

Maybe I’m missing something (repairs are expensive), but maybe somewhere there is an initial setup algorithm for the first flights to achieve stability in the air.
I have a hexacopter on a ZD-850 frame from AliExpress.
Thank you in advance!

Read and follow the How to methodically tune (almost) any multicopter guide. Download the methodic configurator, edit each file in the configurator to suit your copter and write them to the FC one by one as you read along. The guide and configurator tell you what to do at any given time. Do not skip any steps! Anything that might seem like a shortcut will result in a worse tuned copter in the end.

Thank you! I’ll study it!