Skip to content

Conversation

@josuah
Copy link
Contributor

@josuah josuah commented Nov 7, 2025

Build:

git remote add josuah https://github.com/josuah/zephyr/
git fetch josuah
git checkout da1f3ee6f95fbecb502ed823c202d8aca9426d7e

west build -d build_nrf54lm20 -b nrf54lm20dk/nrf54lm20a/cpuapp samples/subsys/usb/shell/ \
-DEXTRA_CONF_FILE=host_prj.conf -DCONFIG_USB_DEVICE_STACK_NEXT=n

Before:

uart:~$ usbh init
uart:~$ usbh enable
uart:~$ usbh device address 1 2
host: New device address is 2
uart:~$ usbh device list 
1
uart:~$ usbh device descriptor device 1
host: Failed to request device descriptor
uart:~$ usbh device descriptor device 2
host: No USB device with address 2

After:

uart:~$ usbh init
uart:~$ usbh enable
uart:~$ usbh device address 1 2
host: New device address is 2
uart:~$ usbh device list 
2
uart:~$ usbh device descriptor device 2
bLength			18
bDescriptorType		1
bcdUSB			200
bDeviceClass		0
bDeviceSubClass		0
bDeviceProtocol		0
bMaxPacketSize0		64
idVendor		bda
idProduct		8176
bcdDevice		200
iManufacturer		1
iProduct		2
iSerial			3
bNumConfigurations	1

@josuah josuah added the area: USB Universal Serial Bus label Nov 7, 2025
@josuah josuah changed the title subsys: usb: host: update udev->addr after setting the address usb: host: update udev->addr after setting the address Nov 7, 2025
The usbh_req_set_address() function did successfully set the device to its
new address, but the udev->addr was not update, so there was a mismatch
between the reality and udev.

Signed-off-by: Josuah Demangeon <josuah.demangeon@nordicsemi.no>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 7, 2025

}

return usbh_req_setup(udev, bmRequestType, bRequest, addr, 0, 0, NULL);
udev->addr = addr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mismatch is only in

err = usbh_req_set_address(udev, new_addr);
if (err) {
shell_error(sh, "host: Failed to set address");
} else {
shell_print(sh, "host: New device address is %u", new_addr);
}

The actual USB host stack updates device address

err = usbh_req_set_address(udev, new_addr);
if (err) {
LOG_ERR("Failed to set device address");
udev->addr = 0;
goto error;
}
udev->addr = new_addr;
udev->state = USB_STATE_ADDRESSED;

The question is really about what should be updated by usbh_req_set_address() and what is left to the caller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: USB Universal Serial Bus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants