Skip to content

Commit

Permalink
Make lpc1768 pre-flash reset optional
Browse files Browse the repository at this point in the history
  • Loading branch information
benlye committed Apr 26, 2019
1 parent c8cc905 commit 22cdeeb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
17 changes: 8 additions & 9 deletions octoprint_firmwareupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,12 @@ def _flash_lpc1768(self, firmware=None, printer_port=None):
lpc1768_path = self._settings.get(["lpc1768_path"])
working_dir = os.path.dirname(lpc1768_path)

# reset the board before we try to flash it - should ensure that it's mounted by usbmount
self._send_status("progress", subtype="boardreset")
self._logger.info(u"Pre-flash reset: attempting to reset the board")
if not self._reset_lpc1768(printer_port):
self._logger.error(u"Reset failed")
return False

# Short wait before we try to relese the SD card
#time.sleep(3)
if self._settings.get_boolean(["lpc1768_preflashreset"]):
self._send_status("progress", subtype="boardreset")
self._logger.info(u"Pre-flash reset: attempting to reset the board")
if not self._reset_lpc1768(printer_port):
self._logger.error(u"Reset failed")
return False

# Release the SD card
if not self._unmount_sd(printer_port):
Expand All @@ -528,6 +525,7 @@ def _flash_lpc1768(self, firmware=None, printer_port=None):
timeout = 60
interval = 1
sdstarttime = time.time()
self._logger.info(u"Waiting for SD card to be avaialble at '{}'".format(lpc1768_path))
self._send_status("progress", subtype="waitforsd")
while (time.time() < (sdstarttime + timeout) and not os.access(lpc1768_path, os.W_OK)):
self._logger.debug(u"Waiting for firmware folder path to become available [{}/{}]".format(count, int(timeout / interval)))
Expand Down Expand Up @@ -739,6 +737,7 @@ def get_settings_defaults(self):
"bossac_commandline": "{bossac} -i -p {port} -U true -e -w {disableverify} -b {firmware} -R",
"bossac_disableverify": None,
"lpc1768_path": None,
"lpc1768_preflashreset": True,
"postflash_delay": "0",
"postflash_gcode": None,
"run_postflash_gcode": False,
Expand Down
6 changes: 5 additions & 1 deletion octoprint_firmwareupdater/static/js/firmwareupdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ $(function() {

// Config settings for lpc1768
self.configLpc1768Path = ko.observable();
self.configLpc1768ResetBeforeFlash = ko.observable();

self.lpc1768PathBroken = ko.observable(false);
self.lpc1768PathOk = ko.observable(false);
Expand Down Expand Up @@ -416,7 +417,9 @@ $(function() {

// Load the lpc1768 settings
self.configLpc1768Path(self.settingsViewModel.settings.plugins.firmwareupdater.lpc1768_path());

if(self.settingsViewModel.settings.plugins.firmwareupdater.lpc1768_preflashreset() != 'false') {
self.configLpc1768ResetBeforeFlash(self.settingsViewModel.settings.plugins.firmwareupdater.lpc1768_preflashreset());
}
self.configurationDialog.modal();
};

Expand Down Expand Up @@ -444,6 +447,7 @@ $(function() {
bossac_disableverify: self.configBossacDisableVerification(),
bossac_commandline: self.configBossacCommandLine(),
lpc1768_path: self.configLpc1768Path(),
lpc1768_preflashreset: self.configLpc1768ResetBeforeFlash(),
enable_preflash_commandline: self.configEnablePreflashCommandline(),
preflash_commandline: self.configPreflashCommandline(),
enable_postflash_commandline: self.configEnablePostflashCommandline(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@
<span class="help-block">{{ _('Customize the avrdude command line.') }}</span>
</div>
</div>
<div class="control-group">
<label class="control-label">{{ _('Disable bootloader warning') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" class="input-block-level" data-bind="checked: configDisableBootloaderCheck">
</div>
<span class="help-block">{{ _('If checked the bootloader warning will be suppressed.') }}</span>
</div>
</div>
</div>
<!-- End advanced avrdude options -->

Expand Down Expand Up @@ -252,15 +261,21 @@
</div>
<!-- End advanced bossac options-->

<div class="control-group">
<label class="control-label">{{ _('Disable bootloader warning') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" class="input-block-level" data-bind="checked: configDisableBootloaderCheck">
<!-- Advanced lpc1768 options -->
<div data-bind="visible: showLpc1768Config">
<div class="control-group">
<label class="control-label">{{ _('Reset before flashing') }}</label>
<div class="controls">
<div class="input">
<input type="checkbox" data-bind="checked: configLpc1768ResetBeforeFlash">
</div>
<span class="help-block">{{ _('If checked the board will be reset before a firmware update is attempted. Helps to ensure that the SD card is properly mounted.') }}</span>
</div>
<span class="help-block">{{ _('If checked the bootloader warning will be suppressed.') }}</span>
</div>
</div>
<!-- Advanced lpc1768 options -->

<!-- End advanced bossac options-->
<hr>
</div>
<!-- End advanced options-->
Expand Down

0 comments on commit 22cdeeb

Please sign in to comment.