diff --git a/src/modules/systemlib/param/param_shmem.c b/src/modules/systemlib/param/param_shmem.c index a3d3d453b2..3a82864443 100644 --- a/src/modules/systemlib/param/param_shmem.c +++ b/src/modules/systemlib/param/param_shmem.c @@ -857,7 +857,16 @@ param_save_default(void) goto exit; } + // After writing the file, also do a fsync to prevent loosing params if power is cut. + res = fsync(fd); + if (res != 0) { + PX4_ERR("failed to do fsync: %s", strerror(errno)); + goto exit; + } + PARAM_CLOSE(fd); + + fd = -1; exit: