1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 03:50:02 +03:00

MSC on-board flash: Persist RTC across reboot and use as file timestamp

Adds support to persist the RTC (if set) across the reboot if entering mass storage mode for on-board flash. The value is then used as the timestamp for the files exposed in the virtual FAT32 filesystem. The files will then have reasonable creation dates when copied to the host computer.

If the RTC is not set (or supported), then the default timestamp of 2018-01-01 will be used (unchanged from previous).

Included some improvements to the RTC functions and exposed the `tz_offsetMinutes` in the `timeConfig` PG. Support already existed for timezone offsets but the parameter wasn't exposed to the user and couldn't be set.

Move timezone offset up a layer as a parameter to systemResetToMsc()
Adds support for specifying a custom timezone offset from both the CLI and MSP calls to enter mass storage mode.

Added an option timezone offset minutes to the CLI `msc` command. If no parameter is specified then the default as specified by `timezone_offset_minutes` will be used. So to reboot into mass storage mode and force the file timestamps to be in UTC, use `msc 0`.

Added reboot message `MSP_REBOOT_MSC_UTC` to support rebooting into mass storage mode and forcing the timestamps to use UTC time (0 offset). The Configurator will need to be modified to use this message for operating systems that expect UTC times for FAT file systems (like Linux).
This commit is contained in:
Bruce Luckcuck 2018-12-01 10:07:22 -05:00
parent 1c50c317d6
commit b8085b170e
16 changed files with 138 additions and 14 deletions

View file

@ -4483,16 +4483,27 @@ static void cliDiff(char *cmdline)
#if defined(USE_USB_MSC)
static void cliMsc(char *cmdline)
{
UNUSED(cmdline);
if (mscCheckFilesystemReady()) {
#ifdef USE_RTC_TIME
int timezoneOffsetMinutes = timeConfig()->tz_offsetMinutes;
if (!isEmpty(cmdline)) {
timezoneOffsetMinutes = atoi(cmdline);
if ((timezoneOffsetMinutes < TIMEZONE_OFFSET_MINUTES_MIN) || (timezoneOffsetMinutes > TIMEZONE_OFFSET_MINUTES_MAX)) {
cliPrintErrorLinef("INVALID TIMEZONE OFFSET");
return;
}
}
#else
int timezoneOffsetMinutes = 0;
UNUSED(cmdline);
#endif
cliPrintHashLine("Restarting in mass storage mode");
cliPrint("\r\nRebooting");
bufWriterFlush(cliWriter);
waitForSerialPortToFinishTransmitting(cliPort);
stopPwmAllMotors();
systemResetToMsc();
systemResetToMsc(timezoneOffsetMinutes);
} else {
cliPrintHashLine("Storage not present or failed to initialize!");
}
@ -4598,7 +4609,11 @@ const clicmd_t cmdTable[] = {
#endif
CLI_COMMAND_DEF("motor", "get/set motor", "<index> [<value>]", cliMotor),
#ifdef USE_USB_MSC
#ifdef USE_RTC_TIME
CLI_COMMAND_DEF("msc", "switch into msc mode", "[<timezone offset minutes>]", cliMsc),
#else
CLI_COMMAND_DEF("msc", "switch into msc mode", NULL, cliMsc),
#endif
#endif
CLI_COMMAND_DEF("name", "name of craft", NULL, cliName),
#ifndef MINIMAL_CLI