Add an option to erase the filesystem sectors.

This commit is contained in:
iabdalkader 2016-05-06 23:47:07 +02:00
parent 62a44bde2a
commit 062947356f
2 changed files with 38 additions and 3 deletions

View File

@ -128,6 +128,8 @@ Kwabena W. Agyeman</property>
<property name="title" translatable="yes">Update Firmware</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">430</property>
<property name="default_height">162</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
@ -230,6 +232,32 @@ Kwabena W. Agyeman</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox22">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkCheckButton" id="erase_fs_check">
<property name="label" translatable="yes">Erase Filesystem</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
<action-widgets>

View File

@ -70,6 +70,7 @@ class Bootloader:
self.ok_button = builder.get_object("fw_ok_button")
self.cancel_button = builder.get_object("fw_cancel_button")
self.erase_fs_check = builder.get_object("erase_fs_check")
# Connect signals
self.dialog.connect("close", self.on_dialog_close)
@ -153,8 +154,9 @@ class Bootloader:
def task_erase(self, state):
sector = state["sector"]
state["bar"].set_fraction((sector-FLASH_SECTOR_START+1)/float(FLASH_SECTOR_END-FLASH_SECTOR_START+1))
state["bar"].set_text("Erasing sector %d/%d"%((sector-FLASH_SECTOR_START+1), FLASH_SECTOR_END-FLASH_SECTOR_START+1))
sector_offset = state["sector_offset"]
state["bar"].set_fraction((sector-sector_offset+1)/float(FLASH_SECTOR_END-sector_offset+1))
state["bar"].set_text("Erasing sector %d/%d"%((sector-sector_offset+1), FLASH_SECTOR_END-sector_offset+1))
openmv.flash_erase(sector)
sector += 1
if (sector == FLASH_SECTOR_END+1):
@ -204,7 +206,12 @@ class Bootloader:
self.last_fw_path = fw_path
self.config.set("main", "last_fw_path", self.last_fw_path)
self.state={ "next":self.task_init, "buf":buf, "sector":FLASH_SECTOR_START,
if self.erase_fs_check.get_active():
sector_offset = FLASH_SECTOR_START
else:
sector_offset = FLASH_SECTOR_START + 3
self.state={ "next":self.task_init, "buf":buf, "sector":sector_offset, "sector_offset": sector_offset,
"bar":self.fw_progress, "dialog":self.dialog, "xfer_bytes":0, "xfer_total":len(buf)}
self.flash_msg = 1