Cube 2.1 Constant compass error and Compass Variance, Loiter crash


Recently I assembled a Quad with Cube 2.1 with Here GPS on Yangda YD41000S. I installed Arducopter Quad 3.6.1 and did all the IMU and Compass calibration. The controller was positioned heading forward as the GPS too. However, during calibration many times I got ‘Bad AHRS’ and ‘Compass inconsistent’. Finally, after many calibrations it stopped. When i got out to try the new craft, it stayed stable in ‘Stabilize’, but when I put it in Loiter, the craft started turning a little left and right, tried to ascend and then flipped heads down. All the motors are organised correctly (sequence 1324 mounted on the airframe). I use both compasses with ROTATION_NONE.
Even when I downloaded the logs, the craft’s horizon was shifting in MP

Please help resolve the issue

Link to log:

Thank you guys in advance