RegFlushKey does not work

When trying to persist the registry to flash, the API call to RegFlushKey(HKEY_LOCAL_MACHINE) fails.
Calling the same API a second time, it succeeds.
After a reboot, the changed keys/values are no longer present.

While booting the OS display the following messages on the debug serial port:

[8.22 14:37:22.0]Toradex Windows CE 8.0 1.6b1
[8.22 14:37:22.0] for iMX6 Built on Aug  8 2019
[8.22 14:37:22.0]Colibri iMX6 DualLite 512MB
[8.22 14:37:22.2]Multi-core mode is disabled in module configuration.
[8.22 14:37:22.2]Wait mode Disabled
[8.22 14:37:22.2]SMP support disabled
[8.22 14:37:22.2]RTC origin set to: 2006/01/01.
[8.22 14:37:22.2]Registry is empty or invalid. Loading default values.
[8.22 14:37:22.2]Registry loaded.
[8.22 14:37:22.3]Loading GPIO Multiplexer...

When calling RegFlushKey for the first time after chaning a registry value, we get the following on the debug output:

[8.22 14:45:26.7]Registry - Saving is disabled.

This looks like a problem in the BSP.

Latest Toradex provided BSP has a version 1.5
And RegFlushKey() works there as expected.
Looks like you broke something during your custom OS design.

Making sure that the bootloader config is set as followed solves the problem:

dbg.regread 1	
dbg.regwrite 1

I just would like to add that dbg.regread = dbg.regwrite = 1 are the default settings. You only need to care about this if you modified the default.