mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Add FW version command
* Add FW version command to usbdbg. * Add FW version function to openmv.py * Check for major version in the IDE.
This commit is contained in:
parent
0d0086f6b3
commit
182a844cd2
@ -60,6 +60,15 @@ void usbdbg_clr_script()
|
||||
void usbdbg_data_in(void *buffer, int length)
|
||||
{
|
||||
switch (cmd) {
|
||||
case USBDBG_FW_VERSION: {
|
||||
uint32_t *ver_buf = buffer;
|
||||
ver_buf[0] = FIRMWARE_VERSION_MAJOR;
|
||||
ver_buf[1] = FIRMWARE_VERSION_MINOR;
|
||||
ver_buf[2] = FIRMWARE_VERSION_PATCH;
|
||||
cmd = USBDBG_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
case USBDBG_TX_BUF_LEN: {
|
||||
uint32_t tx_buf_len = usbd_cdc_tx_buf_len();
|
||||
memcpy(buffer, &tx_buf_len, length);
|
||||
@ -185,6 +194,11 @@ void usbdbg_control(void *buffer, uint8_t request, uint32_t length)
|
||||
{
|
||||
cmd = (enum usbdbg_cmd) request;
|
||||
switch (cmd) {
|
||||
case USBDBG_FW_VERSION:
|
||||
xfer_bytes = 0;
|
||||
xfer_length = length;
|
||||
break;
|
||||
|
||||
case USBDBG_FRAME_SIZE:
|
||||
xfer_bytes = 0;
|
||||
xfer_length = length;
|
||||
|
||||
@ -8,8 +8,30 @@
|
||||
*/
|
||||
#ifndef __USBDBG_H__
|
||||
#define __USBDBG_H__
|
||||
/**
|
||||
* Firmware major, minor and patch versions.
|
||||
* Increment the major version if the ABI has changed.
|
||||
* Increment the minor version when a new command is added.
|
||||
* Increment the patch version for fixes that don't affect the ABI.
|
||||
*
|
||||
* Note: incrementing the major version will require a fw upgrade,
|
||||
* the IDE will Not connect if the major version number is different.
|
||||
*/
|
||||
#define FIRMWARE_VERSION_MAJOR (1)
|
||||
#define FIRMWARE_VERSION_MINOR (1)
|
||||
#define FIRMWARE_VERSION_PATCH (0)
|
||||
|
||||
/**
|
||||
* To add a new debugging command, increment the last command value used.
|
||||
* Set the MSB of the value if the request has a device-to-host data phase.
|
||||
* Add the command to usr/openmv.py using the same value.
|
||||
* Handle the command control and data in/out (if any) phases in usbdbg.c.
|
||||
*
|
||||
* See usbdbg.c for examples.
|
||||
*/
|
||||
enum usbdbg_cmd {
|
||||
USBDBG_NONE=0,
|
||||
USBDBG_NONE =0x00,
|
||||
USBDBG_FW_VERSION =0x80,
|
||||
USBDBG_FRAME_SIZE =0x81,
|
||||
USBDBG_FRAME_DUMP =0x82,
|
||||
USBDBG_FRAME_LOCK =0x83,
|
||||
|
||||
@ -26,6 +26,10 @@ if hasattr(sys,"frozen") and sys.frozen in ("windows_exe", "console_exe"):
|
||||
else:
|
||||
IDE_DIR=os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
FIRMWARE_VERSION_MAJOR = 1
|
||||
FIRMWARE_VERSION_MINOR = 1
|
||||
FIRMWARE_VERSION_PATCH = 0
|
||||
|
||||
DATA_DIR = os.path.join(os.path.expanduser("~"), "openmv") #use home dir
|
||||
SCRIPTS_DIR = os.path.join(DATA_DIR, "scripts")
|
||||
EXAMPLES_DIR = os.path.join(IDE_DIR, "examples")
|
||||
@ -223,6 +227,14 @@ class OMVGtk:
|
||||
return
|
||||
|
||||
openmv.init(self.serial)
|
||||
|
||||
# check firmware version
|
||||
fw_ver = openmv.fw_version()
|
||||
print("fw_version:" + str(fw_ver))
|
||||
if (fw_ver[0] != FIRMWARE_VERSION_MAJOR):
|
||||
self.show_message_dialog(gtk.MESSAGE_ERROR, "Firmware version mismatch! Please upgrade the firmware")
|
||||
return
|
||||
|
||||
# interrupt any running code
|
||||
openmv.stop_script()
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ __FB_HDR_SIZE =12
|
||||
|
||||
# USB Debug commands
|
||||
__USBDBG_CMD = 48
|
||||
__USBDBG_FW_VERSION = 0x80
|
||||
__USBDBG_FRAME_SIZE = 0x81
|
||||
__USBDBG_FRAME_DUMP = 0x82
|
||||
__USBDBG_FRAME_LOCK = 0x83
|
||||
@ -135,6 +136,10 @@ def tx_buf(bytes):
|
||||
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_TX_BUF, bytes))
|
||||
return __serial.read(bytes)
|
||||
|
||||
def fw_version():
|
||||
__serial.write(struct.pack("<BBI", __USBDBG_CMD, __USBDBG_FW_VERSION, 12))
|
||||
return struct.unpack("III", __serial.read(12))
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv)!= 2:
|
||||
print ('usage: openmv.py <script>')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user