Interesting that this question has not been answered since it was asked almost 5 years ago. Let me propose an answer and curate it as others comment on it.
A magnetometer is designed to detect the earth's magnetic field and if perfectly aligned (all sensors are orthogonal from one another but otherwise act exactly alike) and no near by metals perturb the earth's magnetic field, we can simply sample the magnetometer. And if we know it orientation in the earth's frame of reference, derive magnetic north through calculations.
Of course nothing is perfect. The magnetometer's X, Y & Z sensors are not exactly alike and there are likely near by metals that perturb the earths magnetic field.
Simply put, a magnetometer should be calibrated as it is expected to be used. If you are going to use it in a car then you need to calibrate while securely mounted in the car. In the same place in the car. Preferably as far away from metal objects as possible. There is a reason most car (and airplane) compasses are located in the middle of the front windshield. Finally, if you do not expect the car to flip over, then you do not expect the magnetometer to have to work under such circumstances.
Hard Iron corrects for individual sensor offset differences. This offset calibration value is added to a sensor sample such that its absolute maximum and minimum samples are equal. Point each sensor directly at and directly away from magnetic north to obtain these readings. Do not forget magnetic declination and inclination when determining where magnetic north is at your location on earth.
Soft Iron correct for individual sensor sensitivity differences. Each sample is multiplied by its normalization value such that all sensors report the same value while that sensor is in the same orientation with respect to magnetic north.
At this point, we have described 3 offset values and 3 normalization values. Or a 1x3 offset matrix and a 1x3 normalization matrix. For a sensor that needs no adjustment these matrices would look like this:
offset = [0, 0, 0]
normalization = [1, 1, 1]
Many applications can use this information to derive a suitable magnetic north vector. However, some may want to use a 3x3 normalization matrix. The extra 6 values in this 9 value normalization matrix takes into account the non perfect orthogonal arrangement of the 3 magnetometer sensors. Simply put, how much of sensor X and Y readings can contribute to sensor Z's reading. And X and Z to Y's. And Z and Y to X's. The 1x3 and 3x3 matrices for a perfect magnetometer would look like this:
offset = [0, 0, 0]
normalization = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
Finding the missing calibration values when going from a 1x3 to a 3x3 normalization calibration matrix is not trivial.
We might be able to go further if there is interest in a more complete answer. Leave comments and I'll adjust this answer to better fit where people want to take this stackexchange question.