I would be suspecting the glow plug controller.
Try this trick. this is a paste from another post but will give you some ideas. It relates to a M7040
but the M8540 is the same generation I think.
Kubota glow plug operation
In very cold weather, with the block heater plugged in, the glow plug...