The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=b8cdbe1852ef5df4ba3c7a021d9632bde2e61327
commit b8cdbe1852ef5df4ba3c7a021d9632bde2e61327 Author: Gavin Atkinson <ga...@freebsd.org> AuthorDate: 2025-01-07 00:02:20 +0000 Commit: Ed Maste <ema...@freebsd.org> CommitDate: 2025-01-17 16:11:34 +0000 iwmbtfw: Check firmware exists before trying to upload it In the case of an Intel 7260 device, the device needs to be put into something called "manufacturer mode" before the firmware is uploaded. The firmware is then upladed, and the card is taken out of this mode, at which point it disconnects and reconnects to the USB bus, and is at that point usable. However, iwmbtfw(8) puts the device into manufacturer mode before verifying that there exists a copy of the firmware to upload. As a result, in the case where there is no firmware available on disk, the device is put into manufacturer mode, the firmware can't be found so isn't uploaded, and the card is brought out of manufacturer mode, so it disconnects and reconnects to the USB bus. Enter devd(8). There are rules in /etc/devd/iwmbtfw.conf to call iwmbtfw(8) when the device appears. When there's no firmware on disk, devd will call iwmbtfw, iwmbtfw will try to do its thing and fail, the device will dis/reconnect, and devd will notice the device reappear and start the whole loop again. Fix is to verify that the firmware exists before putting the device into its special mode. The fix only changes things for the 7260 and not the other chips supported, I don't believe the issue exists with other chips as those do not need to be switched into manufacturer mode before uploading. PR: 283896 Reviewed by: emaste --- usr.sbin/bluetooth/iwmbtfw/main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usr.sbin/bluetooth/iwmbtfw/main.c b/usr.sbin/bluetooth/iwmbtfw/main.c index c2b67ce01906..9c899d374e92 100644 --- a/usr.sbin/bluetooth/iwmbtfw/main.c +++ b/usr.sbin/bluetooth/iwmbtfw/main.c @@ -518,6 +518,13 @@ main(int argc, char *argv[]) iwmbt_debug("firmware_path = %s", firmware_path); + /* Check firmware file exists before changing HW mode */ + r = access(firmware_path, R_OK); + if (r) { + perror("Failed to open firmware"); + goto shutdown; + } + /* Enter manufacturer mode */ r = iwmbt_enter_manufacturer(hdl); if (r < 0) {