System initialize sequence & I2C blocked

The original order of my system initialize step is:







6.nrf_drv_twi_init() + nrf_drv_twi_enable()





One day, I saw a document mentioned that clock init should be before APP_SCHED_INIT(),

so I rearrange the order to be 1-7-8-2-3-4-5-6-9.

After that, it cause following issue.

My device can't complete boot once about 10 to 20 times start-up,

It will be blocked in step 9 which I2C first time transfer data.

When it happened, It can't be recover even I update back to the original sequence image by bootloader.

Measuring I2C signal by scope, data pin(SDA) is pull-up initial by HW but is set and keep to be low during boot.

and clock pin (SCL) is always pull high by HW, no any clock generate.

After experiment, there are three method to recover,

One way is remove voltage source(battery).

Seconed method is update a image which SCL/SDA is set to be output pins before TWI initial.

The last method is measure voltage of SCL pin by multimeter. It continue and complete boot immediately once I touch SCL pin by multimeter's probe.

What could be the root cause about the issue? And what is the correct initialize sequence should be?