Debugging Pixhawk 4 mini with PX4 custom controls

I’ve created a custom quadcopter controller(Custom Position, Altitude and Control Allocation scheme) in PX4 and have succesfully validated the controller and implementation in PX4 by virtually flying our quadcopter model in Gazebo. I built the code and uploaded it to our Pixhawk 4 mini but after setting the airframe to our custom vehicle in QGroundControl, The red error light will begin blinking and the usb connection drops. I am looking for any advice on how to go about debugging and issue like this?