mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge branch 'fwupdate'
This commit is contained in:
commit
58ea8be932
BIN
bin/openmv.bin
BIN
bin/openmv.bin
Binary file not shown.
@ -76,7 +76,20 @@ defined in linker script */
|
||||
.section .text.Reset_Handler
|
||||
.weak Reset_Handler
|
||||
.type Reset_Handler, %function
|
||||
|
||||
Reset_Handler:
|
||||
ldr r0,=0x20002000 /* load magic number location */
|
||||
ldr r2,[r0, #0]
|
||||
str r0,[r0, #0] /* invalidate */
|
||||
ldr r1,=0xDEADBEEF /* if magic number found */
|
||||
cmp r2,r1
|
||||
bne EnableCCM /* run the bootloader, else... */
|
||||
|
||||
Reboot_Loader:
|
||||
ldr r0,=0x1FFF0000
|
||||
ldr sp,[r0, #0]
|
||||
ldr r0,[r0, #4]
|
||||
bx r0
|
||||
|
||||
EnableCCM:
|
||||
/* enable ccm clock */
|
||||
@ -122,6 +135,7 @@ LoopFillZerobss:
|
||||
/* Call the application's entry point.*/
|
||||
bl main
|
||||
bx lr
|
||||
|
||||
.size Reset_Handler, .-Reset_Handler
|
||||
|
||||
/**
|
||||
|
||||
@ -190,8 +190,15 @@ void usbdbg_control(void *buffer, uint8_t request, uint16_t length)
|
||||
NVIC_SystemReset();
|
||||
break;
|
||||
|
||||
case USBDBG_BOOT:
|
||||
*((uint32_t *)0x20002000) = 0xDEADBEEF;
|
||||
NVIC_SystemReset();
|
||||
break;
|
||||
|
||||
default: /* error */
|
||||
cmd = USBDBG_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ enum usbdbg_cmd {
|
||||
USBDBG_ATTR_READ,
|
||||
USBDBG_ATTR_WRITE,
|
||||
USBDBG_SYS_RESET,
|
||||
USBDBG_BOOT
|
||||
};
|
||||
void usbdbg_init();
|
||||
int usbdbg_script_ready();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.24"/>
|
||||
<!-- interface-requires vte 0.0 -->
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<!-- interface-requires gtksourceview 0.0 -->
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<!-- interface-requires vte 0.0 -->
|
||||
<!-- interface-naming-policy toplevel-contextual -->
|
||||
<object class="GtkAdjustment" id="brightness_adjust">
|
||||
<property name="lower">-2</property>
|
||||
<property name="upper">2</property>
|
||||
@ -51,6 +51,121 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkDialog" id="fw_dialog">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">Update Firmware</property>
|
||||
<property name="window_position">center-on-parent</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">1</property>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="fw_ok_button">
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="fw_cancel_button">
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinner" id="fw_spinner">
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkHBox" id="hbox21">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="fw_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">•</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<property name="primary_icon_activatable">False</property>
|
||||
<property name="secondary_icon_activatable">False</property>
|
||||
<property name="primary_icon_sensitive">True</property>
|
||||
<property name="secondary_icon_sensitive">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="fw_button">
|
||||
<property name="label" translatable="yes">...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<signal name="clicked" handler="on_fwpath_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">fw_ok_button</action-widget>
|
||||
<action-widget response="-6">fw_cancel_button</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="gainceiling_adjust">
|
||||
<property name="upper">6</property>
|
||||
<property name="step_increment">1</property>
|
||||
@ -484,6 +599,22 @@
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="bootloader_button">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="tooltip_text" translatable="yes">Enter bootloader</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="label" translatable="yes">toolbutton7</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-go-up</property>
|
||||
<signal name="clicked" handler="on_fwupdate_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorToolItem" id="separator1">
|
||||
<property name="visible">True</property>
|
||||
@ -646,8 +777,6 @@
|
||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hscrollbar_policy">automatic</property>
|
||||
<property name="vscrollbar_policy">automatic</property>
|
||||
<child>
|
||||
<object class="GtkSourceView" id="gtksourceview">
|
||||
<property name="visible">True</property>
|
||||
@ -777,7 +906,6 @@
|
||||
<object class="GtkHScale" id="hscale1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="update_policy">delayed</property>
|
||||
<property name="adjustment">contrast_adjust</property>
|
||||
<property name="show_fill_level">True</property>
|
||||
<property name="round_digits">0</property>
|
||||
@ -793,7 +921,6 @@
|
||||
<object class="GtkHScale" id="hscale2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="update_policy">delayed</property>
|
||||
<property name="adjustment">brightness_adjust</property>
|
||||
<property name="round_digits">0</property>
|
||||
<property name="digits">0</property>
|
||||
@ -810,7 +937,6 @@
|
||||
<object class="GtkHScale" id="hscale3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="update_policy">delayed</property>
|
||||
<property name="adjustment">saturation_adjust</property>
|
||||
<property name="lower_stepper_sensitivity">off</property>
|
||||
<property name="upper_stepper_sensitivity">off</property>
|
||||
@ -847,7 +973,6 @@
|
||||
<object class="GtkHScale" id="hscale5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="update_policy">delayed</property>
|
||||
<property name="adjustment">gainceiling_adjust</property>
|
||||
<property name="lower_stepper_sensitivity">off</property>
|
||||
<property name="upper_stepper_sensitivity">off</property>
|
||||
|
||||
@ -13,10 +13,14 @@ import usb.util
|
||||
import numpy as np
|
||||
import openmv
|
||||
from os.path import expanduser
|
||||
import subprocess
|
||||
|
||||
UI_PATH =os.path.dirname(os.path.realpath(__file__))+"/openmv-ide.glade"
|
||||
CONFIG_PATH = expanduser("~")+"/.openmvide.config"
|
||||
EXAMPLE_PATH = os.path.dirname(os.path.realpath(__file__))+"/examples"
|
||||
SCRIPTS_PATH = os.path.dirname(os.path.realpath(__file__))+"/scripts"
|
||||
FWBIN_PATH = ""
|
||||
DFU_CMD = "dfu-util -d 0483:df11 -c 1 -i 0 -a 0 -s 0x08000000 -D %s"
|
||||
|
||||
SCALE =1
|
||||
|
||||
@ -43,6 +47,7 @@ class OMVGtk:
|
||||
# set control buttons
|
||||
self.controls = [
|
||||
self.builder.get_object('reset_button'),
|
||||
self.builder.get_object('bootloader_button'),
|
||||
self.builder.get_object('exec_button'),
|
||||
self.builder.get_object('stop_button'),
|
||||
self.builder.get_object('zoomin_button'),
|
||||
@ -92,6 +97,8 @@ class OMVGtk:
|
||||
"on_top_window_destroy" : self.quit,
|
||||
"on_connect_clicked" : self.connect_clicked,
|
||||
"on_reset_clicked" : self.reset_clicked,
|
||||
"on_fwupdate_clicked" : self.fwupdate_clicked,
|
||||
"on_fwpath_clicked" : self.fwpath_clicked,
|
||||
"on_execute_clicked" : self.execute_clicked,
|
||||
"on_stop_clicked" : self.stop_clicked,
|
||||
"on_motion_notify" : self.motion_notify,
|
||||
@ -195,6 +202,61 @@ class OMVGtk:
|
||||
def connect_clicked(self, widget):
|
||||
self.connect()
|
||||
|
||||
def fwpath_clicked(self, widget):
|
||||
fw_entry = self.builder.get_object("fw_entry")
|
||||
dialog = gtk.FileChooserDialog(title=None,action=gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
|
||||
dialog.set_default_response(gtk.RESPONSE_OK)
|
||||
dialog.set_current_folder(SCRIPTS_PATH)
|
||||
ff = gtk.FileFilter()
|
||||
ff.set_name("dfu")
|
||||
ff.add_pattern("*.bin") #TODO change to DFU
|
||||
dialog.add_filter(ff)
|
||||
|
||||
if dialog.run() == gtk.RESPONSE_OK:
|
||||
fw_entry.set_text(dialog.get_filename())
|
||||
|
||||
dialog.destroy()
|
||||
|
||||
def fwupdate_clicked(self, widget):
|
||||
if (self.connected):
|
||||
dialog = self.builder.get_object("fw_dialog")
|
||||
fw_entry = self.builder.get_object("fw_entry")
|
||||
spinner = self.builder.get_object("fw_spinner")
|
||||
ok_button = self.builder.get_object("fw_ok_button")
|
||||
cancel_button = self.builder.get_object("fw_cancel_button")
|
||||
|
||||
spinner.stop()
|
||||
spinner.set_visible(False)
|
||||
ok_button.set_sensitive(True)
|
||||
cancel_button.set_sensitive(True)
|
||||
dialog.set_transient_for(self.window);
|
||||
|
||||
# default FW bin path
|
||||
fw_entry.set_text(FWBIN_PATH)
|
||||
|
||||
if dialog.run() == gtk.RESPONSE_OK:
|
||||
ok_button.set_sensitive(False)
|
||||
cancel_button.set_sensitive(False)
|
||||
spinner.set_visible(True)
|
||||
spinner.start()
|
||||
|
||||
# call dfu-util
|
||||
openmv.enter_dfu()
|
||||
sleep(1.0)
|
||||
|
||||
dfu_util = subprocess.Popen(DFU_CMD%fw_entry.get_text(), shell=True, stdout=subprocess.PIPE)
|
||||
|
||||
while dfu_util.poll() == None and gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
if (dfu_util.returncode):
|
||||
self.show_message_dialog(gtk.MESSAGE_ERROR, "Failed to update firmware\n")
|
||||
|
||||
openmv.exit_dfu()
|
||||
|
||||
dialog.hide()
|
||||
|
||||
def reset_clicked(self, widget):
|
||||
if (self.connected):
|
||||
openmv.reset()
|
||||
|
||||
@ -34,6 +34,7 @@ __USBDBG_DESCRIPTOR_SAVE=9
|
||||
__USBDBG_ATTR_READ=10
|
||||
__USBDBG_ATTR_WRITE=11
|
||||
__USBDBG_SYS_RESET=12
|
||||
__USBDBG_SYS_BOOT=13
|
||||
|
||||
ATTR_CONTRAST=0
|
||||
ATTR_BRIGHTNESS=1
|
||||
@ -60,8 +61,8 @@ def init():
|
||||
def release():
|
||||
global __dev
|
||||
try:
|
||||
# release __INTERFACE
|
||||
usb.util.release_interface(__dev, __INTERFACE)
|
||||
# Release device
|
||||
usb.util.dispose_resources(dev)
|
||||
|
||||
# reattach kernel driver
|
||||
#__dev.attach_kernel_driver(__INTERFACE)
|
||||
@ -153,6 +154,29 @@ def set_attr(attr, value):
|
||||
def get_attr(attr):
|
||||
return 0
|
||||
|
||||
def enter_dfu():
|
||||
try:
|
||||
# This will timeout.
|
||||
__dev.ctrl_transfer(0x41, __USBDBG_SYS_BOOT, 0, __INTERFACE, None, __TIMEOUT)
|
||||
except:
|
||||
pass
|
||||
|
||||
#See app note AN3156
|
||||
def exit_dfu():
|
||||
timeout = 1000
|
||||
dev = usb.core.find(idVendor=0x0483, idProduct=0xdf11)
|
||||
|
||||
# Claim DFU interface
|
||||
usb.util.claim_interface(dev, 0)
|
||||
|
||||
# Send DNLOAD with 0 length to exit DFU
|
||||
dev.ctrl_transfer(0x21, 0x01, 0, 0, None, timeout)
|
||||
# Execute last command
|
||||
dev.ctrl_transfer(0xA1, 0x03, 0, 0, 6, timeout)
|
||||
|
||||
# Release device
|
||||
usb.util.dispose_resources(dev)
|
||||
|
||||
def reset():
|
||||
try:
|
||||
# This will timeout.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user