I don't know your application with BMI160. For static offset calibration, our common suggestion is save value in your flash but not BMI160's NVM, because NVM have wirte times limitation.
If you could check that accel static offset will not change along with product liftime, you can save value in NVM. It's decided by your application.
I am struggling with the offsets.
I did as you suggested saving the offsets given by bmi160_start_foc() in my local flash then applied them to the raw data - this didn't work for me.
I tried to learn the offset myself. I put the device on a flat surface, g is on z axis, I read the raw data on x and y for X time (I did 5 to 10 seconds). The avergare over this period of time is the offset. I've been appliying it as follows: a = ((a_raw - offset)*g)/sensitivty. This method didn't work for me either.
The only way for me to get sensible results is to use the FOC. I am not sure what I am missing here?
Can you please help me?
I think your methord is right, maybe some mistake you didn't get.
Please show me your log, the offset value before and after offset compensation. Before offset compensation, the accel output value offset is lagger.