diff options
author | George Kraft <george.kraft@calxeda.com> | 2012-08-02 11:40:48 -0500 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2012-08-02 11:40:48 -0500 |
commit | 7611de59736ad6c26f60885a7cdb436b86725656 (patch) | |
tree | e91e4f0c0b1c6f84763cf282032953f6a4724e46 | |
parent | 5918a331523e11142ac55fa953366c7feab1255a (diff) | |
download | cxmanage-7611de59736ad6c26f60885a7cdb436b86725656.tar.gz |
Simplify boot order preservation during firmware updates
Remove usage of the bootcmd0 variable, so now bootcmd_default
is the only variable that cxmanage ever touches.
Also preserve bootcmd_default directly during firmware updates.
No need to parse it. And if it fails, just upload the new u-boot
environment with no modifications.
-rw-r--r-- | cxmanage/target.py | 20 | ||||
-rw-r--r-- | cxmanage/ubootenv.py | 14 |
2 files changed, 17 insertions, 17 deletions
diff --git a/cxmanage/target.py b/cxmanage/target.py index 8652651..b089662 100644 --- a/cxmanage/target.py +++ b/cxmanage/target.py @@ -251,14 +251,18 @@ class Target: factory_slot = self._get_slot(fwinfo, image.type, "SECOND") # Update running ubootenv - boot_order = self._download_ubootenv(tftp, - running_slot).get_boot_order() - contents = open(image.filename).read() - if image.simg: - contents = contents[28:] - ubootenv = self.ubootenv_class(contents) - ubootenv.set_boot_order(boot_order) - self._upload_ubootenv(tftp, ubootenv, running_slot, version) + old_ubootenv = self._download_ubootenv(tftp, running_slot) + if "bootcmd_default" in old_ubootenv.variables: + bootcmd = old_ubootenv.variables["bootcmd_default"] + contents = open(image.filename).read() + if image.simg: + contents = contents[28:] + ubootenv = self.ubootenv_class(contents) + ubootenv.variables["bootcmd_default"] = bootcmd + self._upload_ubootenv(tftp, ubootenv, + running_slot, version) + else: + self._upload_image(tftp, image, running_slot, version) # Update factory ubootenv self._upload_image(tftp, image, factory_slot, version) diff --git a/cxmanage/ubootenv.py b/cxmanage/ubootenv.py index 3cfe98d..bcd0af4 100644 --- a/cxmanage/ubootenv.py +++ b/cxmanage/ubootenv.py @@ -103,19 +103,15 @@ class UbootEnv: # Set bootcmd_default self.variables["bootcmd_default"] = "; ".join(commands) - # TODO: Don't set bootcmd0. But for now, we have to since we released - # an earlier version of cxmanage that may have modified it. - self.variables["bootcmd0"] = "run bootcmd_setup; run bootcmd_default" - def get_boot_order(self): """ Get the boot order specified in the uboot environment. """ - if "bootcmd_default" in self.variables: - commands = self.variables["bootcmd_default"].split("; ") - else: - commands = self.variables["bootcmd0"].split("; ") boot_args = [] + if not "bootcmd_default" in self.variables: + raise CxmanageError("Variable bootcmd_default not found") + commands = self.variables["bootcmd_default"].split("; ") + retry = False for command in commands: if command.startswith("while true"): @@ -133,7 +129,7 @@ class UbootEnv: elif command == "reset": boot_args.append("reset") break - elif command != "run bootcmd_setup": + else: raise CxmanageError("Unrecognized boot command: %s" % command) if retry: |