In the past, you need modify rtc_api.c in mbed-dev source code. From this revision, you can just use RTC function all of conditions (Normal, Reset, Stand-by, Power OFF).

Note

From now on, you do NOT need any modification for mbed-dev library because STM team updates rtc_api.c source code and support RTC function under reset & standby condition includes power off condition (You need additional VBAT back-up hardware).

Please refer following NOTE information.
/users/kenjiArai/notebook/nucleo-series-rtc-control-under-power-onoff-and-re/

Revision:
14:4b03106ece1f
Parent:
12:8cb1f89541d1
--- a/check_revision.cpp	Mon Jan 11 07:55:27 2021 +0000
+++ b/check_revision.cpp	Sat Mar 06 08:29:51 2021 +0000
@@ -1,22 +1,22 @@
 /*
  * Check Mbed revision
  *
- * Copyright (c) 2019,'20, '21 Kenji Arai / JH1PJL
+ * Copyright (c) 2019,'20,'21 Kenji Arai / JH1PJL
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created:    July      17th, 2019
- *      Revised:    January    6th, 2021
+ *      Revised:    March      5th, 2021
  */
 
 #include "mbed.h"
- 
-//    RUN ONLY ON mbed-os-6.6.0
-//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.6.0
+
+//    RUN ONLY ON mbed-os-6.8.0
+//      https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.8.0
 #if (MBED_MAJOR_VERSION == 6) &&\
-    (MBED_MINOR_VERSION == 6) &&\
+    (MBED_MINOR_VERSION == 8) &&\
     (MBED_PATCH_VERSION == 0)
 #else
-#   error "Please use mbed-os-6.6.0"
+#   error "Please use mbed-os-6.8.0"
 #endif
 
 void print_revision(void)