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:
13:c1f984932e98
--- a/main.cpp	Mon Jan 11 07:55:27 2021 +0000
+++ b/main.cpp	Sat Mar 06 08:29:51 2021 +0000
@@ -6,7 +6,7 @@
  *  http://www7b.biglobe.ne.jp/~kenjia/
  *  https://os.mbed.com/users/kenjiArai/
  *      Created: January   17th, 2015
- *      Revised: January   11th, 2021
+ *      Revised: March      6th, 2021
  */
 
 /*  mbed library now suports RTC continuous operation at Reset & Power ON/OFF
@@ -51,11 +51,13 @@
 
 //  Include --------------------------------------------------------------------
 #include "mbed.h"
+#include "uart_as_stdio.h"
 
 //  Definition -----------------------------------------------------------------
 #if defined(TARGET_DISCO_F746NG)  \
  || defined(TARGET_NUCLEO_F746ZG) \
  || defined(TARGET_DISCO_F769NI)  \
+ || defined(TARGET_DISCO_F469NI)  \
  || defined(TARGET_NUCLEO_F446ZE) \
  || defined(TARGET_NUCLEO_H743ZI2)
 #define PUSHED_SW   1   // Active high
@@ -67,13 +69,11 @@
 #define PUSHED_SW   0   // Active low
 #endif
 
-#define LONGLONGTIME    2147483647
+#define LONGLONGTIME    2147483647s
 
 //  Object ---------------------------------------------------------------------
 DigitalIn userSW(USER_BUTTON);
 DigitalOut myled(LED1);                 // Indicate the sampling period
-// Create a BufferedSerial object to be used by the system I/O retarget code
-static BufferedSerial pc(USBTX, USBRX, 9600);
 
 //  RAM ------------------------------------------------------------------------
 
@@ -102,9 +102,9 @@
     puts("\r\n\r\nTest Nucleo RTC Function.");
     print_revision();
     myled = !myled;
-    thread_sleep_for(500);
+    ThisThread::sleep_for(500ms);
     myled = !myled;
-    thread_sleep_for(500);
+    ThisThread::sleep_for(500ms);
     while(true) {
         seconds = time(NULL);
         strftime(buf, 50, " %B %d,'%y, %H:%M:%S\r\n", localtime(&seconds));
@@ -114,15 +114,15 @@
         puts("\r");
         wait_counter = 0;
         while (seconds == time(NULL)) {
-            if (pc.readable() == 1) {
-                pc.read(buf,1);  // dummy read
+            if (readable() == 1) {
+                buf[0] = getc();    // dummy read
                 time_enter_mode();
             }
             if (userSW == PUSHED_SW) {  // goto sleep
                 while (userSW == PUSHED_SW) {
-                    thread_sleep_for(10);
+                    ThisThread::sleep_for(10ms);
                 }
-                thread_sleep_for(10);
+                ThisThread::sleep_for(10ms);
                 puts("Entered the standby mode. ");
 #if defined(TARGET_NUCLEO_F303K8) || defined(TARGET_NUCLEO_L432KC)
                 puts("Please change A0 level for wake-up(Reset).");
@@ -132,43 +132,28 @@
                 myled = 0;
  
                 InterruptIn usr_sw(USER_BUTTON);
-                thread_sleep_for(1000);
+                ThisThread::sleep_for(1s);
                 DigitalIn dmy0(LED1);
                 DigitalIn dmy1(USBTX);
                 DigitalIn dmy2(USBRX);
                 usr_sw.fall(&usr_sw_irq); // actual push or chattering
-                thread_sleep_for(LONGLONGTIME);
+                sleep_preparation();
+                ThisThread::sleep_for(LONGLONGTIME);
             }
-            thread_sleep_for(50);
+            ThisThread::sleep_for(50ms);
             if (++wait_counter > (2000 / 50)) {
                 break;
             }
         }
         // delete previous strings
-        printf("\033[2A");
-        puts("");   // null
-        uint8_t n = strlen(msg0) + strlen(msg1);
-        memset(buf, ' ', 64);
-        if (n > 64) {
-            n -= 64;
-            pc.write(buf, 64);
-        }
-        if (n > 64) {
-            pc.write(buf, 64);
-        } else {
-            pc.write(buf, n);
-        }
-        printf("\033[G");
+        // https://en.wikipedia.org/wiki/ANSI_escape_code#CSIsection
+        // \33[ = CSI sequences, 1A=Cursor Up (one line), 2K=Erase in Line(all)
+        //                       G=Cursor Horizontal Absolute
+        printf("\33[1A\033[2K\033[G");
         myled = !myled;
     }
 }
 
-//  the system I/O retarget
-FileHandle *mbed::mbed_override_console(int fd)
-{
-    return &pc;
-}
-
 //  Interrupt for wake up
 static void usr_sw_irq(void)
 {
@@ -182,13 +167,12 @@
     char linebuf[64];
 
     puts("Set time into RTC.");
-    puts(" e.g. >21 1 6 12 34 56 -> January 06,'21, 12:34:56");
+    puts(" e.g. >21 3 3 3 33 33 -> March  03,'21, 03:33:33");
     puts(" If time is fine, just hit enter key.");
-    linebuf[0] = '>';
-    pc.write(linebuf, 1);
+    putc('>');
     ptr = linebuf;
     get_line(ptr, sizeof(linebuf));
-    puts("\r");
+    putc('\r');
     chk_and_set_time(ptr);
 }
 
@@ -251,12 +235,10 @@
 static void get_line(char *buff, int32_t len)
 {
     char c;
-    char bf[8];
     int32_t idx = 0;
 
     for (;;) {
-        pc.read(bf, 1);
-        c = bf[0];
+        c = getc();
         //printf("0x%x \r\n", c);
         if (c == '\r') {
             buff[idx++] = c;
@@ -266,16 +248,15 @@
             idx--;
             const char bf_bs[] =
             {0x1b, '[', '1', 'D', ' ', 0x1b, '[', '1', 'D'};
-            pc.write(bf_bs, 9);
+            printf(bf_bs, 9);
         }
         if (((uint8_t)c >= ' ') && (idx < len - 1)) {
             buff[idx++] = c;
-            pc.write(bf, 1);
+            putc(c);
         }
     }
     buff[idx] = 0;
-    bf[0] = '\n';
-    pc.write(bf, 1);
+    putc('\n');
 }
 
 //  Check key input strings and set time