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/

Revisions of main.cpp

Revision Date Message Actions
14:4b03106ece1f 2021-03-06 run on mbed-os6.8.0 File  Diff  Annotate
13:c1f984932e98 2021-01-11 add boards File  Diff  Annotate
12:8cb1f89541d1 2021-01-06 run on mbed-os-6.6.0 File  Diff  Annotate
11:2e514d955a2b 2020-08-01 changed RawSerial to BufferedSerial on mbed-os-6.2.0(mbed_version.h=set correct version) File  Diff  Annotate
10:806cfec92eb6 2020-07-18 run on mbed-os6.2.0 (mbed_version.h = os5.15.4) File  Diff  Annotate
9:6a64b0207f72 2017-01-16 mbed supports RTC function during RESET & Power ON/OFF. You don't need any modification for mbed library source code. You can just check RTC!! File  Diff  Annotate
8:bf593344668e 2016-07-02 Added F746xx File  Diff  Annotate
7:27a1cf7f8921 2016-05-27 added L476RG. File  Diff  Annotate
6:5ada291037aa 2016-01-29 Use mbed-dev lib. (old rev. -> use mbed-src) File  Diff  Annotate
5:bc464a588c2e 2015-05-23 Change SetRTC parameter. Add F344R8 mbed. File  Diff  Annotate
4:a9cebfe4715f 2015-02-19 Bug fix when External Xtal is not avairable. In addtion change checking method for STM32xxx register status File  Diff  Annotate
3:7b3edf54c706 2015-02-18 Only for L152RE, change Deep sleep mode to Standby mode to reduce backup current File  Diff  Annotate
2:77ec44bf1fa5 2015-02-16 L152, Support an interrupt driven power down. File  Diff  Annotate
1:7a48c475bbd2 2015-02-14 support L152 mbed. Need to modify rtc_api.c in mbed-src. File  Diff  Annotate
0:0751c92c0f71 2015-02-07 This is a RTC additional function. This is only for F401RE & F411RE. If you connected battery backup circuit for internal RTC, you can make a power-off and reset condition. RTC still has proper time and date.; You can set the time & date by PC Com. File  Diff  Annotate