diff --git a/unit-tests/func/dfu/test-device-fw-compatibility.py b/unit-tests/func/dfu/test-device-fw-compatibility.py new file mode 100644 index 00000000000..6e02e976be2 --- /dev/null +++ b/unit-tests/func/dfu/test-device-fw-compatibility.py @@ -0,0 +1,51 @@ +# License: Apache 2.0. See LICENSE file in root directory. +# Copyright(c) 2021 Intel Corporation. All Rights Reserved. + +# test:device L500* +# test:device D400* + +import pyrealsense2 as rs +from rspy import test + + +def check_firmware_not_compatible(updatable_device, old_fw_image): + test.check(not updatable_device.check_firmware_compatibility(old_fw_image)) + +def check_firmware_compatible(updatable_device, old_fw_image): + test.check(updatable_device.check_firmware_compatibility(old_fw_image)) + + +ctx = rs.context() +dev = ctx.query_devices()[0] +updatable_device = dev.as_updatable() + +############################################################################################# +test.start("checking firmware compatibility with device") +pid = dev.get_info(rs.camera_info.product_id) +if pid == '0B3A': # D435I + print("device D435i found") + with open("Signed_Image_UVC_5_12_6_0.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_not_compatible(updatable_device, old_fw_image) + with open("Signed_Image_UVC_5_12_7_100.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_compatible(updatable_device, old_fw_image) +elif pid == '0B07': # D435 + print("device D435 found") + with open("Signed_Image_UVC_5_8_14_0.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_not_compatible(updatable_device, old_fw_image) + with open("Signed_Image_UVC_5_8_15_0.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_compatible(updatable_device, old_fw_image) +elif pid == '0B64': # L515 + print("device L515 found") + with open("Signed_Image_UVC_1_4_0_10.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_not_compatible(updatable_device, old_fw_image) + with open("Signed_Image_UVC_1_4_1_0.bin", 'rb') as binary_file: + old_fw_image = bytearray(binary_file.read()) + check_firmware_compatible(updatable_device, old_fw_image) + +test.finish() +test.print_results_and_exit() diff --git a/wrappers/python/pyrs_device.cpp b/wrappers/python/pyrs_device.cpp index 60b9c587a23..818cb7ce89f 100644 --- a/wrappers/python/pyrs_device.cpp +++ b/wrappers/python/pyrs_device.cpp @@ -69,9 +69,8 @@ void init_device(py::module &m) { .def("update_unsigned", [](rs2::updatable& self, const std::vector& fw_image, std::function f, int update_mode) { return self.update_unsigned(fw_image, f, update_mode); }, "Update an updatable device to the provided unsigned firmware. This call is executed on the caller's thread and it supports progress notifications via the callback.", "fw_image"_a, "callback"_a, "update_mode"_a = RS2_UNSIGNED_UPDATE_MODE_UPDATE, py::call_guard()) - .def("check_firmware_compatibility", [](rs2::updatable& self, const std::vector& fw_image) { return self.check_firmware_compatibility(fw_image); }, - "Check firmware compatibility with device. This method should be called before burning a signed firmware.", - "fw_image"_a); + .def("check_firmware_compatibility", &rs2::updatable::check_firmware_compatibility, "Check firmware compatibility with device. " + "This method should be called before burning a signed firmware.", "image"_a); py::class_ update_device(m, "update_device"); update_device.def(py::init())