connectcore-demo-example: fix firmware update from local web
Use the same command independently of the boot system. Fix the way dual boot is detected to use 'dualboot' U-Boot variable. Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
parent
cab26c39e7
commit
d9e0146e41
|
|
@ -513,19 +513,15 @@ class RequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||||
path = json.loads(data.decode("utf-8")).get("file", None)
|
path = json.loads(data.decode("utf-8")).get("file", None)
|
||||||
|
|
||||||
log.debug("Update firmware with file %s", path)
|
log.debug("Update firmware with file %s", path)
|
||||||
|
if not is_dual_system() and not path.startswith(get_fw_store_path())\
|
||||||
if is_dual_system():
|
and shutil.disk_usage(get_fw_store_path())[2] >= os.path.getsize(path):
|
||||||
cmd = "firmware-update-dual.sh %s" % path
|
# Move the package to /mnt/update to avoid permission problems
|
||||||
else:
|
|
||||||
if not path.startswith(get_fw_store_path()):
|
|
||||||
# Move the package to /mnt/update
|
|
||||||
update_path = os.path.join(get_fw_store_path(), os.path.basename(path))
|
update_path = os.path.join(get_fw_store_path(), os.path.basename(path))
|
||||||
if os.path.exists(update_path):
|
if os.path.exists(update_path):
|
||||||
os.remove(update_path)
|
os.remove(update_path)
|
||||||
shutil.move(path, update_path)
|
shutil.move(path, update_path)
|
||||||
path = update_path
|
path = update_path
|
||||||
cmd = "update-firmware --reboot-timeout=1 %s" % path
|
cmd = "update-firmware %s" % path
|
||||||
|
|
||||||
log.debug("Update cmd: %s", cmd)
|
log.debug("Update cmd: %s", cmd)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -806,8 +802,8 @@ def is_dual_system():
|
||||||
Returns:
|
Returns:
|
||||||
Boolean: True for dual systems, False otherwise.
|
Boolean: True for dual systems, False otherwise.
|
||||||
"""
|
"""
|
||||||
res = exec_cmd("fdisk -l | grep recovery")
|
res = exec_cmd("fw_printenv -n dualboot")
|
||||||
return res[0] != 0
|
return res[0] == 0 and res[1] == "yes"
|
||||||
|
|
||||||
|
|
||||||
def get_fw_store_path():
|
def get_fw_store_path():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue