Skip to content

Commit

Permalink
iwmbtfw: Check firmware exists before trying to upload it
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gavinatkinson authored and emaste committed Jan 17, 2025
1 parent d7df653 commit b8cdbe1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions usr.sbin/bluetooth/iwmbtfw/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b8cdbe1

Please sign in to comment.