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/

Changes

RevisionDateWhoCommit message
14:4b03106ece1f 2021-03-06 kenjiArai run on mbed-os6.8.0 default tip
13:c1f984932e98 2021-01-11 kenjiArai add boards
12:8cb1f89541d1 2021-01-06 kenjiArai run on mbed-os-6.6.0
11:2e514d955a2b 2020-08-01 kenjiArai changed RawSerial to BufferedSerial on mbed-os-6.2.0(mbed_version.h=set correct version)
10:806cfec92eb6 2020-07-18 kenjiArai run on mbed-os6.2.0 (mbed_version.h = os5.15.4)
9:6a64b0207f72 2017-01-16 kenjiArai 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!!
8:bf593344668e 2016-07-02 kenjiArai Added F746xx
7:27a1cf7f8921 2016-05-27 kenjiArai added L476RG.
6:5ada291037aa 2016-01-29 kenjiArai Use mbed-dev lib. (old rev. -> use mbed-src)
5:bc464a588c2e 2015-05-23 kenjiArai Change SetRTC parameter. Add F344R8 mbed.
4:a9cebfe4715f 2015-02-19 kenjiArai Bug fix when External Xtal is not avairable. In addtion change checking method for STM32xxx register status
3:7b3edf54c706 2015-02-18 kenjiArai Only for L152RE, change Deep sleep mode to Standby mode to reduce backup current
2:77ec44bf1fa5 2015-02-16 kenjiArai L152, Support an interrupt driven power down.
1:7a48c475bbd2 2015-02-14 kenjiArai support L152 mbed. Need to modify rtc_api.c in mbed-src.
0:0751c92c0f71 2015-02-07 kenjiArai 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.