Switch runtime LFCLK RC to XTAL

Enviroment : nRF52833, ncs v3.1.1

The custom board is connected to a DCDC and a 32.768kHz XTAL. However, during the module manufacturing process, the DCDC and XTAL are not connected, which causes a problem where we cannot verify operation after downloading the firmware.

Therefore, I would like to modify the firmware so that the board boots using RC, but switches the LFCLK to XTAL after a certain period of time.

I have already looked into a few cases, but I was not successful in changing it at runtime.

Is there a way to do this?



  • Hi Ben,
    Dynamically switching the LFCLK source between RC and XTAL is not supported out of the box. 

    The configuration of the clock source is defined in the device tree and that is used by the kernel when booting. 

    The easiest to solve this is to flash the test firmware when you want to verify the operation and flash a new firmware after you have populated the XTAL and DCDC. I would assume you want to find a solution that you don't have to do 2 phases programming, correct ? 

    I don't see an easy way to get around this. It's possible to access the register directly to change the clock source. But it's not recommended as Zephyr OS can change the clock source back. And also it's not something we support when you use with NCS. 

    I am thinking of another solution where you can embed your test functionality in the bootloader (for example MCBoot) and you can run the MCUBoot with RC and when you have the chip populated you can jump to the application which is running on XTAL. If you don't want to add your application to MCUBoot, you can think of having a separated application as bootloader before jumping to MCUBoot. This is similar to the situation we have now with the nRF52840 dongle where we have a legacy bootloader from nRF5 SDK boot first and then jump to MCUBoot/application after that. 

Related