Skip to content

Fix USB timeout crashes during sensor initialization - #245

Open
mpatton125 wants to merge 1 commit into
uunicorn:masterfrom
mpatton125:fix/usb-timeout-init-handling
Open

Fix USB timeout crashes during sensor initialization#245
mpatton125 wants to merge 1 commit into
uunicorn:masterfrom
mpatton125:fix/usb-timeout-init-handling

Conversation

@mpatton125

Copy link
Copy Markdown

Two issues cause python3-validity to crash on startup, particularly after reboot or when the sensor flash is uninitialized:

  1. get_flash_info() in flash.py calls assert_status() on the response from command 0x3e, which throws on any 0x04xx status. These statuses indicate uninitialized flash, which is a normal condition that init_flash() is designed to handle. The crash prevents init_flash() from ever reaching its formatting logic.

    Fix: return an empty FlashInfo when status byte is 0x04, allowing init_flash() to proceed with flash formatting as intended.

  2. send_init() in usb.py calls assert_status() on the init_hardcoded command, which fails with 0x0411 when no firmware is loaded. The very next lines check the 4302 (get_fw_info) response and fall through to init_hardcoded_clean_slate for exactly this case, but the assert prevents that path from ever being reached.

    Fix: remove assert_status() on init_hardcoded, allowing the existing clean slate fallback logic to work as designed.

Tested on Lenovo ThinkPad X1 Carbon Gen 5 with Validity VFS495 (138a:0097) sensor running Ubuntu 25.10 / kernel 6.17.

Two issues cause python3-validity to crash on startup, particularly
after reboot or when the sensor flash is uninitialized:
1. get_flash_info() in flash.py calls assert_status() on the response
from command 0x3e, which throws on any 0x04xx status. These statuses
indicate uninitialized flash, which is a normal condition that
init_flash() is designed to handle. The crash prevents init_flash()
from ever reaching its formatting logic.
Fix: return an empty FlashInfo when status byte is 0x04, allowing
init_flash() to proceed with flash formatting as intended.
2. send_init() in usb.py calls assert_status() on the init_hardcoded
command, which fails with 0x0411 when no firmware is loaded. The
very next lines check the 4302 (get_fw_info) response and fall
through to init_hardcoded_clean_slate for exactly this case, but
the assert prevents that path from ever being reached.
Fix: remove assert_status() on init_hardcoded, allowing the
existing clean slate fallback logic to work as designed.
Tested on Lenovo ThinkPad X1 Carbon Gen 5 with Validity VFS495
(138a:0097) sensor running Ubuntu 25.10 / kernel 6.17.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mpatton125