diff --git a/cross_arm.txt b/cross_arm.txt index fd774a78..05a48834 100644 --- a/cross_arm.txt +++ b/cross_arm.txt @@ -19,7 +19,6 @@ c_args = [ '-mthumb', # ARM Thumb2 ISA '-mfloat-abi=hard', # Hard floating point support '-mfpu=fpv4-sp-d16', - '-ffunction-sections', '-Os' ] diff --git a/minmea/minmea.c b/minmea/minmea.c index 32f78819..5b311ce6 100644 --- a/minmea/minmea.c +++ b/minmea/minmea.c @@ -632,7 +632,7 @@ int minmea_gettime(struct timespec *ts, const struct minmea_date *date, const st tm.tm_min = time_->minutes; tm.tm_sec = time_->seconds; - time_t timestamp = timegm(&tm); /* See README.md if your system lacks timegm(). */ + time_t timestamp = mktime(&tm); /* See README.md if your system lacks timegm(). */ if (timestamp != (time_t)-1) { ts->tv_sec = timestamp; ts->tv_nsec = time_->microseconds * 1000; diff --git a/platform/drivers/NVM/W25Qx.c b/platform/drivers/NVM/W25Qx.c index 4a83d903..5c33cce2 100644 --- a/platform/drivers/NVM/W25Qx.c +++ b/platform/drivers/NVM/W25Qx.c @@ -214,54 +214,51 @@ ssize_t W25Qx_writePage(uint32_t addr, void* buf, size_t len) bool W25Qx_writeData(uint32_t addr, void* buf, size_t len) { - // Fail if we are trying to write more than 4K bytes - if(len > 4096) - return false; - // Fail if we are trying to write across 4K blocks, - // this would erase two 4K blocks for one write, which is not good for flash life - // We calculate block address using integer division of start and end address + /* Fail if we are trying to write more than 4K bytes */ + if(len > 4096) return false; + + /* Fail if we are trying to write across 4K blocks: this would erase two 4K + * blocks for one write, which is not good for flash life. + * We calculate block address using integer division of start and end address + */ uint32_t startBlockAddr = addr / 4096 * 4096; uint32_t endBlockAddr = (addr + len - 1) / 4096 * 4096; if(endBlockAddr != startBlockAddr) return false; - // Read data from memory to check if it's already correct - // Allocate buffer for storing data read from memory - uint8_t *flashData; - flashData = (uint8_t *) malloc(len); + /* Before writing, check if we're not trying to write the same content */ + uint8_t *flashData = ((uint8_t *) malloc(len)); W25Qx_readData(addr, flashData, len); - // If data in flash corresponds to the passed data, do not perform the write if(memcmp(buf, flashData, len) == 0) { - // Free the buffer free(flashData); return true; } - // Free the flash data buffer + free(flashData); - // Perform the actual read-erase-write of flash data - // Allocate 4096 bytes block for storing flash block to be erased - uint8_t *flashBlock; - flashBlock = (uint8_t *) malloc(4096); - // Read the 4K block from flash + /* Perform the actual read-erase-write of flash data. */ + uint8_t *flashBlock = ((uint8_t *) malloc(4096)); W25Qx_readData(startBlockAddr, flashBlock, 4096); + + /* Overwrite changed portion */ uint32_t blockOffset = addr % 4096; - // Overwrite changed portion memcpy(&flashBlock[blockOffset], buf, len); - // Erase the 4K block + + /* Erase the 4K block */ if(!W25Qx_eraseSector(startBlockAddr)) { - // The erase operation failed, return failure + /* Erase operation failed, return failure */ free(flashBlock); return false; } - // Write back the modified 4K block in 256 bytes chunks + + /* Write back the modified 4K block in chunks of 256 bytes */ for(uint32_t offset = 0; offset < 4096; offset += 256) { W25Qx_writePage(startBlockAddr + offset, &flashBlock[offset], 256); } - // Free the 4K buffer + free(flashBlock); return true; } diff --git a/platform/drivers/NVM/nvmem_MDUV3x0.c b/platform/drivers/NVM/nvmem_MDUV3x0.c index f2c46e35..f5ebd9f4 100644 --- a/platform/drivers/NVM/nvmem_MDUV3x0.c +++ b/platform/drivers/NVM/nvmem_MDUV3x0.c @@ -34,7 +34,7 @@ const uint32_t contactBaseAddr = 0x140000; /**< Base address of contacts const uint32_t maxNumChannels = 3000; /**< Maximum number of channels in memory */ const uint32_t maxNumZones = 250; /**< Maximum number of zones and zone extensions in memory */ const uint32_t maxNumContacts = 10000; /**< Maximum number of contacts in memory */ -/* This address has been chosen by OpenRTX to store the settings +/* This address has been chosen by OpenRTX to store the settings * because it is empty (0xFF) and has enough free space */ const uint32_t settingsAddr = 0x6000;