I found a solution.
An example you can find at https://www.waveshare.com/wiki/BMM150_3-Axis_Magnetometer_Sensor (the one linked from Example Demo) with a proper modification worked with BMM150 in Env II Hat. Here is the procedure.
This is necessary if you are using a Hat version of ENV II HAT, which is connected to the GPIO pin side of the M5Stick variants. If you are using ENV II Hat connected the Grove port, you don't need to change it.
After this modification, the code should work.