Skip to content

Commit

Permalink
small fixes for a clean build with the "10-2020-q4" toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
aegean-odyssey committed Jan 20, 2021
1 parent b82e09e commit fcadd48
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
19 changes: 19 additions & 0 deletions marlin_changes/SdBaseFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@
*
*/

/* HACK!
the 10-2020-q4 toolchain generates a warning when compiling this file;
finding the way the code writes date and time into the FAT structure a
little sketchy. Since we don't use this facility (dateTime_ is always
NULL), we just remove the code rather than fix it. Timestamps are not
likely to make it into our application without an overhaul of this SD
card/file system code anyway.
*/
#define USE_DATETIME_FUNCTION 0

/**
* Arduino SdFat Library
* Copyright (C) 2009 by William Greiman
Expand Down Expand Up @@ -646,6 +656,7 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
memset(p, 0, sizeof(*p));
memcpy(p->name, dname, 11);

#if USE_DATETIME_FUNCTION
// set timestamps
if (dateTime_) {
// call user date/time function
Expand All @@ -656,6 +667,10 @@ bool SdBaseFile::open(SdBaseFile* dirFile, const uint8_t dname[11], uint8_t ofla
p->creationDate = FAT_DEFAULT_DATE;
p->creationTime = FAT_DEFAULT_TIME;
}
#else
p->creationDate = FAT_DEFAULT_DATE;
p->creationTime = FAT_DEFAULT_TIME;
#endif
p->lastAccessDate = p->creationDate;
p->lastWriteDate = p->creationDate;
p->lastWriteTime = p->creationTime;
Expand Down Expand Up @@ -1432,11 +1447,13 @@ bool SdBaseFile::sync() {
d->firstClusterLow = firstCluster_ & 0xFFFF;
d->firstClusterHigh = firstCluster_ >> 16;

#if USE_DATETIME_FUNCTION
// set modify time if user supplied a callback date/time function
if (dateTime_) {
dateTime_(&d->lastWriteDate, &d->lastWriteTime);
d->lastAccessDate = d->lastWriteDate;
}
#endif
// clear directory dirty
flags_ &= ~F_FILE_DIR_DIRTY;
}
Expand Down Expand Up @@ -1709,10 +1726,12 @@ int16_t SdBaseFile::write(const void* buf, uint16_t nbyte) {
fileSize_ = curPosition_;
flags_ |= F_FILE_DIR_DIRTY;
}
#if USE_DATETIME_FUNCTION
else if (dateTime_ && nbyte) {
// insure sync will update modified date and time
flags_ |= F_FILE_DIR_DIRTY;
}
#endif

if (flags_ & O_SYNC) {
if (!sync()) goto FAIL;
Expand Down
8 changes: 8 additions & 0 deletions stm32f0xx/stm32f0xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@

/* we use the default configuration as is */
#include "stm32f0xx_hal_conf_template.h"

/* HACK!
the 10-2020-q4 toolchain generates a warning when compiling
the HAL crc module. Since we don't use this module, disable
it rather than fix it to avoid the warning and limit changes
to STM32Cube-1.10.1 to those that are essential.
*/
#undef HAL_CRC_MODULE_ENABLED

0 comments on commit fcadd48

Please sign in to comment.