Skip to content

Commit

Permalink
Merge pull request #140 from ubershy/lpc1768-sync-sd-card-before-unmo…
Browse files Browse the repository at this point in the history
…unting

Sync write buffer to SD card (LPC1768)
  • Loading branch information
benlye authored Jul 8, 2020
2 parents 81b5a38 + 367ab65 commit 6e902f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions octoprint_firmwareupdater/methods/lpc1768.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ def _flash_lpc1768(self, firmware=None, printer_port=None):
self._send_status("flasherror")
return False

# On some systems there is a problem: if we unmount the SD card immediately, the file may not end up actually copied.
# The code block below helps.
self._logger.info(u"Synchronizing cached writes to SD card")
try:
r = os.system('sync')
except:
e = sys.exc_info()[0]
self._logger.error("Error executing 'sync' command")
return False
time.sleep(1)

unmount_command = 'sudo umount ' + lpc1768_path
self._logger.info(u"Unmounting SD card: '{}'".format(unmount_command))
try:
Expand Down

0 comments on commit 6e902f0

Please sign in to comment.