diff --git a/common/params.cc b/common/params.cc index 620cd42641..7b14ac6955 100644 --- a/common/params.cc +++ b/common/params.cc @@ -199,7 +199,7 @@ std::unordered_map keys = { {"UbloxAvailable", PERSISTENT}, {"UpdateAvailable", CLEAR_ON_MANAGER_START | CLEAR_ON_ONROAD_TRANSITION}, {"UpdateFailedCount", CLEAR_ON_MANAGER_START}, - {"UpdaterAvailableBranches", CLEAR_ON_MANAGER_START}, + {"UpdaterAvailableBranches", PERSISTENT}, {"UpdaterCurrentDescription", CLEAR_ON_MANAGER_START}, {"UpdaterCurrentReleaseNotes", CLEAR_ON_MANAGER_START}, {"UpdaterFetchAvailable", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/updated.py b/selfdrive/updated.py index db6a06dc9e..a623aaefc8 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -230,7 +230,6 @@ class Updater: b: Union[str, None] = self.params.get("UpdaterTargetBranch", encoding='utf-8') if b is None: b = self.get_branch(BASEDIR) - self.params.put("UpdaterTargetBranch", b) return b @property @@ -245,7 +244,7 @@ class Updater: @property def update_available(self) -> bool: - if os.path.isdir(OVERLAY_MERGED): + if os.path.isdir(OVERLAY_MERGED) and len(self.branches) > 0: hash_mismatch = self.get_commit_hash(OVERLAY_MERGED) != self.branches[self.target_branch] branch_mismatch = self.get_branch(OVERLAY_MERGED) != self.target_branch return hash_mismatch or branch_mismatch @@ -259,9 +258,11 @@ class Updater: def set_params(self, update_success: bool, failed_count: int, exception: Optional[str]) -> None: self.params.put("UpdateFailedCount", str(failed_count)) + self.params.put("UpdaterTargetBranch", self.target_branch) self.params.put_bool("UpdaterFetchAvailable", self.update_available) - self.params.put("UpdaterAvailableBranches", ','.join(self.branches.keys())) + if len(self.branches): + self.params.put("UpdaterAvailableBranches", ','.join(self.branches.keys())) last_update = datetime.datetime.utcnow() if update_success: @@ -428,10 +429,11 @@ def main() -> None: # invalidate old finalized update set_consistent_flag(False) - # wait a bit before first cycle - wait_helper.sleep(60) + # set initial state + params.put("UpdaterState", "idle") # Run the update loop + first_run = True while True: wait_helper.ready_event.clear() @@ -444,7 +446,8 @@ def main() -> None: # ensure we have some params written soon after startup updater.set_params(False, update_failed_count, exception) - if not system_time_valid(): + if not system_time_valid() or first_run: + first_run = False wait_helper.sleep(60) continue