From 1764f37a67e696c3cbb6c4b0313fd9489abc91d0 Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 20 Apr 2026 09:45:46 +0100 Subject: [PATCH 1/2] imx500: Allow for fw progress bar access restrictions The firmware upload progress bar reads two files under debugfs, which requires sudo group membership. Non-sudo users may hit PermissionError during IMX500() construction even though the progress bar is purely cosmetic and the rest of the device works without it. Catch PermissionError/FileNotFoundError on the two opens, print a warning, and continue fw upload without a progress bar. Signed-off-by: Naushir Patuck --- picamera2/devices/imx500/imx500.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/picamera2/devices/imx500/imx500.py b/picamera2/devices/imx500/imx500.py index 780cb0df..8c2ba3c8 100644 --- a/picamera2/devices/imx500/imx500.py +++ b/picamera2/devices/imx500/imx500.py @@ -318,11 +318,20 @@ def __init__(self, network_file: str, camera_id: str = '', tensor_injection: boo if self.device_fd is None: raise RuntimeError('IMX500: Requested camera dev-node not found') - # Progress status specific debugfs entries. + # Progress status specific debugfs entries. These are cosmetic (they only feed the + # firmware upload progress bar), so a PermissionError here must not break IMX500. if imx500_device_id: - self.fw_progress = open(f'/sys/kernel/debug/imx500-fw:{imx500_device_id}/fw_progress', 'r') + path = f'/sys/kernel/debug/imx500-fw:{imx500_device_id}/fw_progress' + try: + self.fw_progress = open(path, 'r') + except (PermissionError, FileNotFoundError) as err: + print(f'IMX500: Unable to open {path} ({err}). Firmware upload progress bar will not be displayed') if spi_device_id: - self.fw_progress_chunk = open(f'/sys/kernel/debug/rp2040-spi:{spi_device_id}/transfer_progress', 'r') + path = f'/sys/kernel/debug/rp2040-spi:{spi_device_id}/transfer_progress' + try: + self.fw_progress_chunk = open(path, 'r') + except (PermissionError, FileNotFoundError) as err: + print(f'IMX500: Unable to open {path} ({err}). Firmware upload progress bar will not be displayed') if self.config['network_file'] != '': if tensor_injection: @@ -449,6 +458,9 @@ def get_fw_upload_progress(self, stage_req) -> tuple: return (0, 0) def show_network_fw_progress_bar(self): + if not self.fw_progress and not self.fw_progress_chunk: + # No readable progress source: skip the bar so the worker does not spin on (0, 0). + return p = multiprocessing.Process(target=self.__do_progress_bar, args=(FW_NETWORK_STAGE, 'Network Firmware Upload')) p.start() From 2e77c2e5d309a8c9bc6393649daa0b2057aeb53d Mon Sep 17 00:00:00 2001 From: Naushir Patuck Date: Mon, 20 Apr 2026 10:47:42 +0100 Subject: [PATCH 2/2] tests: imx500: Display the actual number of output tensors received Signed-off-by: Naushir Patuck --- tests/imx500.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/imx500.py b/tests/imx500.py index c49d9a00..e49da37c 100644 --- a/tests/imx500.py +++ b/tests/imx500.py @@ -47,7 +47,7 @@ print("Got output tensors on", tensor_count, "of", NUM_FRAMES, "frames") if tensor_count < NUM_FRAMES // 2: - print("ERROR: expected at least", NUM_FRAMES // 2, "frames with output tensors") + print("ERROR: expected at least", NUM_FRAMES // 2, "frames with output tensors, got", tensor_count) picam2.stop() picam2.close()