Hello @martinzhang
I hope you are doing well!
From the description, it seems that the external crystal/resonator is not being able to get the sufficient stability or number of clock cycles in certain units. See this section below.

I am thinking in the following things:
What is the frequency of your external crystal or resonator? This to will also give us opportunity to review the oscillator circuitry according to Table 36-2 of the RM.
When the MCU gets stop at oscillator initialization , did it have low power mode setting/transition ; transition of MCG mode ; or was coming out of a Power on cycle?
This app note Crystal Oscillator Troubleshooting Guide could also be worthy for our trouble shooting task . Here is an excerpt , that is related to the hypothesis that I mentioned above.

Please accept my apologies for the delay
Diego.