Measuring time using an STM32F407VGT6 microcontroller
First of all, I added two header files inside main.c:

#include "chrtclib.h"
#include "rtc.h"


Secondly, in the makefile of the project, immediately after these 2 lines, 

# C sources that can be compiled in ARM or THUMB mode depending on the global setting.
CSRC = $(PORTSRC) \


I added this:

$(CHIBIOS)/os/various/chrtclib.c \


And, finally, I used two functions (from the ChibiOS RTC time conversion utilities) where I needed them inside main.c:
rtcGetTimeUnixSec(&amp;RTCD1) and rtcSetTimeUnixSec(&amp;RTCD1, unix_time)