diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/rpmsg_load_firmware.py b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/rpmsg_load_firmware.py index 203fa39300..37e8f2d1e5 100755 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/rpmsg_load_firmware.py +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/rpmsg_load_firmware.py @@ -59,13 +59,18 @@ def _setup(self): def _teardown(self): self.rpmsg_state = "stop" - for key in self.properties: - if getattr(self, key) != self._previous_config[key]: - setattr(self, key, self._previous_config[key]) + self.firmware_path = self._previous_config["firmware_path"] + self.firmware_file = self._previous_config["firmware_file"] + if ( + self.firmware_file.strip() != "(null)" + and self._previous_config["rpmsg_state"].strip() == "running" + ): + # start RPMSG again when firmware file been configured + self.rpmsg_state = "start" @property def firmware_path(self) -> str: - return self._firmware_path.read_text() + return self._firmware_path.read_text().strip() @firmware_path.setter def firmware_path(self, value: str) -> None: @@ -81,10 +86,51 @@ def firmware_file(self, value: str) -> None: @property def rpmsg_state(self) -> str: + """ + Reports the state of the remote processor, which will be one of: + + - "offline" + - "suspended" + - "running" + - "crashed" + - "invalid" + + "offline" means the remote processor is powered off. + "suspended" means that the remote processor is suspended and + must be woken to receive messages. + "running" is the normal state of an available remote processor + "crashed" indicates that a problem/crash has been detected on + the remote processor. + "invalid" is returned if the remote processor is in an + unknown state. + + Returns: + str: remote processor state + """ return self._rpmsg_state.read_text() @rpmsg_state.setter def rpmsg_state(self, value: str) -> None: + """ + Writing this file controls the state of the remote processor. + + The following states can be written: + - "start" + - "stop" + + Writing "start" will attempt to start the processor running the + firmware indicated by, or written to, + /sys/class/remoteproc/.../firmware. The remote processor should + transition to "running" state. + + Writing "stop" will attempt to halt the remote processor and + return it to the "offline" state. + + Returns: + None + """ + if value not in ["start", "stop"]: + raise ValueError("Unsupported value for remote processor state") self._rpmsg_state.write_text(value) @property @@ -169,7 +215,11 @@ def load_firmware_test(args) -> None: with RpmsgLoadFirmwareTest(remote_proc_dev) as rpmsg_handler: rpmsg_handler.search_pattern = search_patterns rpmsg_handler._init_logger() - if rpmsg_handler.rpmsg_state == "online": + if rpmsg_handler.rpmsg_state.strip() in [ + "running", + "suspended", + "invalid", + ]: logging.info("Stop the Remote processor") rpmsg_handler.rpmsg_state = "stop" logging.info( diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/jobs.pxu b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/jobs.pxu index e0f71d32a5..7395cd318e 100644 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/jobs.pxu +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/jobs.pxu @@ -57,7 +57,9 @@ _summary: Reload Remote Processor firmware to {firmware} via RPMSG {device} id: ce-oem-rpmsg/reload-rp-firmware-test-{firmware}-{device} category_id: rpmsg estimated_duration: 60 -requires: manifest.has_rpmsg == 'True' +requires: + manifest.has_rpmsg == 'True' + manifest.has_rpmsg_firmware_load == 'True' imports: from com.canonical.plainbox import manifest flags: also-after-suspend user: root diff --git a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/manifest.pxu b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/manifest.pxu index 2311d60c98..7f6060fdbd 100644 --- a/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/manifest.pxu +++ b/contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/rpmsg/manifest.pxu @@ -2,3 +2,8 @@ unit: manifest entry id: has_rpmsg _name: Remote Processor Messaging (rpmsg) framework supported? value-type: bool + +unit: manifest entry +id: has_rpmsg_firmware_load +_name: Change the RPMSG running firmware is supported? +value-type: bool