The USB device descriptors for DFU mode should only change after a
USB reset, not in appDETACH as the device is still in run-time mode
until reset; thus should still return the run-time descriptors when
requested.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
In accordance with USB DFU 1.1 Section 5.1, a device should only
stay in appDETACH for a given period of time, either from the
DFU_DETACH request (wValue ms) or from the wDetachTimeout property,
after which the device should return to appIDLE.
Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
ZLP - zero length packet is used to indicate that the device
has no more data to send. If the Host asks for more data that the
device can provide and the data size is mutliplication of Endpoint
wMaxPacketSize then the device must terminate the data transfer
with ZLP.
Until this patch Nordic device driver controller was not aware of
the requested data length and could not determine when the ZLP was
required.
This patch introduces a fix that prevents the driver from starting
setup stage before the ZLP is being send.
For consistance with the Zephyr USB stack sending ZLP must be
issued from the stack level. Making trans_zlp flag true results
in blocking the driver from starting setup stage without required
ZLP.
After the data transfer finishes the driver will be prepared for ZLP
and will call back the stack to start writing ZLP. After the ZLP
is being send the driver will automatically start status stage and
end the Control Transfer.
This patch also removes CONFIG_USB_DEVICE_DISABLE_ZLP_EPIN_HANDLING
and aligns Nordic driver with others.
Without this patch the issue could occur when handling get requests.
Typical case is string descriptor of length equal to wMaxPacketSize.
Hosts usually asks for wLength = 255 Bytes when string descriptors
are being requested. In that case to successfully finish the data
stage of the Control transfer the device must send wMacPacketSize
Bytes of actual string descriptor and then ZLP to indicate that no
more data are present. After ZLP the status stage may start and the
request is finished successfully.
Without this patch the driver will not send ZLP making it unable
to end the Control Request successful - this may lead to failing
'Device Descriptor Test' from USB3CV test tool.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Kconfig USB_DFU_WAIT_DELAY_MS was hidden.
Added prompt for it so it can be configured.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
It is possible that USB DFU class is used by MCUBoot
itself while it has enabled CONFIG_SINGLE_APPLICATIO_SLOT.
In this mode only application slot is the primary slot.
Adapted DFU class descriptor and services to optionally
serve only for one image.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
End of DFU operation was signaled after the last usb dfu request was
received. Therefeore wait_for_usb_dfu() terminated so fast that
dfu_work_handler() was not called by k_work_queue befor.
wait_for_usb_dfu() should terminate after DFU operation was completed.
For fix that k_poll_signal_raise() was moved after the flash write
operation.
fixes#29611
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Status callback was logging whenever some statuses where
present. Those are not used by HCI class so drop them
and do not LOG if not necessary.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
USB bus might be suspended to save power. After the device
is Resumed from Suspended state there is a need to restart
OUT transfers for Endpoints used by HCI class. The transfers
shall be restarted only if the device was Resumed after Suspend
from Configured state. This patch applies the fix.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Add prompt to USB_DEVICE_NETWORK_ECM_MAC Kconfig option to allow
users to change it. The current default value is assigned for
documentation purposes in RFC 7042.
Signed-off-by: Joakim Algrøy <joakimalgroy@gmail.com>
The existing calculation of the BULK_EP size can sometimes result in a
bulk EP size that is not spec-compliant. The accepted BULK_EP sizes are
8, 16, 32 or 64 bytes.
Additionally, the INT_EP size is always set to the max EP size since
BT_BUF_RX_SIZE is always greater than that (min. 73 in Kconfig).
This commit sets the BULK and INT endpoint sizes to their maximum
supported values.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Both operands of an operator in the arithmetic conversions
performed shall have the same essential type category.
Changes are related to converting the integer constants to the
unsigned integer constants
Signed-off-by: Aastha Grover <aastha.grover@intel.com>
Depending on the Bluetooth features enabled, the HCI
packets can be 264 Bytes long. For HCI over USB the HCI packet
is handled in data stage of USB transfer. Buffer for the data
stage was too short and USB driver was STALLing the data stage
making it unable to complete. Extend the data stage buffer
to 266 Bytes if HCI USB is selected and BT_RX_BUF_LEN > 127
indicating that longer HCI packets are needed.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The USB infrastructure currently uses the system work queue for
offloading transfers, CDC-ACM UART transmission/reception, and device
firmware activities. This causes problems when the system work queue
is also used to initiate some activities (such as UART) that normally
complete without requiring an external thread: in that case the USB
infrastructure is prevented from making progress because the system
work queue is blocked waiting for the USB infrastructure to provide
data.
Break the dependency by allowing the USB infrastructure to use a
dedicated work queue which doesn't depend on availability of the
system work queue.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The z length modifier must be applied to avoid build errors when the
format is verified by the compiler on systems where size_t is larger
than int.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Both tx_irq_ena and rx_irq_ena flags shall be updated only
by using UART API. Those flags are used to let the device
start sending or receiving data. Changing those flags without
awareness of the user may lead to errors.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Usage of `pool_wait_sem` was incorrect. The semaphore shall be
dependent on context it was called for. In case of many CDC_ACM
devices one could possibly block others. This fixes an issue by
making semaphore a part of the internal CDC_ACM device structure.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
is_ep_valid() function was incorrectly searching through
all used endpoints. All endpoints for class must be checked
if they match requested endpoint.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Flag name usb_dev.configured is misleading as it does not
mean the device is configured. This flag indicates whenever
endpoints for the device were enabled. For all classes
except for audio endpoints are enabled on set_configuration
request. This sets the configured flag true. For Audio this
will never happen as what enables audio endpoints is
set_interface request. Without this patch audio samples
will STALL all interface requests.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit extends USB hid API callbacks by adding
'const struct device *dev' parameter. If the application
configured more than one HID device then it must specify
separate hid_ops for each device as its unable to determine
for which device the callback was called.
This patch makes it possible to have only one hid_ops within
the application and the application is aware for which device
the callback was called because of explicit device pointer.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commits introduces check for standard interface and endpoint
requests. Not all requests shall be accepted. In particular those
which addresses not existing interfaces/endpoints should be STALLed.
This patch STALLes incorrect requests.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
The device returns 2 bytes for GetStatus(Device) request.
If the device is self-powered then it shall respond with
bit 0 set to 1 when responding to GetStatus(Device) req.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This patch removes the hard-coded number of transfer buffers and allows
you to increase the number of transfer buffers when multiple USB
devices are used.
Signed-off-by: Pavel Král <pavel.kral@omsquare.com>
Sort entries alphabetically and cleanup top level menu for each
subsystem. Move stats subsystem Kconfig from debug into its own Kconfig.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit fixes an issue when more than one USB transfer is
reserved for same OUT endpoint.
There are 2 scenarios when this could happen:
- The Host sends SET_CONFIGURATION(1) request twice.
- The Host triggers Suspend->Resume->Configured
event sequence for the device.
USB tranfers are not canceled on SUSPEND event
when the device was not configred previously.
Because of that USB transfer slot is reserved twice
for the same OUT endpoint and lead to shortage of USB
transfer slots quickly.
Without this patch CDC ACM class reserves duplicated USB
transfer slots for one transfer. The sequence of
Suspend->Resume events is genereted alongside with
Configured and the stack will shortly run out of transfer
slots.
If the Host, for some reason, decides to send
SET_CONFIGURATION request twice the same issue is seen.
This patch prevents from reserving additional USB transfer
slots twice.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit allows let build zperf sample with overlay-netusb.conf.
USB subsystem must be enabled by the application.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
USB device shall be able to send only in CONFIGURED state.
Zephyr USB HID device class allows to send the data no matter
of the USB state what is wrong. Attempting to write to endpoint
buffer in state != CONFIGURED may lead to driver error.
This patch introduces state tracing for USB HID class and
allows to send data using hid_int_ep_write() class API
only if the device remains in CONFIGURED state.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This adds a new config option for SAM0 targets that use the BOSSA
bootloader. If the CDC ACM driver is also enabled, then the
programmer can automatically reset the board into the bootloader for
programming.
Signed-off-by: Michael Hope <mlhx@google.com>
This is called when the USB host changes the virtual baud rate.
This is used by Arduino style boards to signal that the board should
reset into the bootloader.
Signed-off-by: Michael Hope <mlhx@google.com>
Transfers are cancelled on suspend event, OUT transfers
needs to be re-trigger on resume.
Rework event handling to filter out spurious resume
events and re-trigger transfer if previous event was
a suspend event.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Configuration file was left unchanged after development
of USB Audio class. Deleted configs should never be present.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
USB is sending data from LSB to MSB. Same happens for each field
of the USB setup packet.
This patch convert USB setup packet to proper form when its read
out from the line.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Sets thread names for all usb device class threads (bluetooth, bt_h4,
mass storage, and rndis) to aid debug.
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
Convert with a combo of scripts and by hand fixups:
git grep -l DT_FLASH_AREA_.*_ID | \
xargs sed -i -r 's/DT_FLASH_AREA_(.*)_ID/FLASH_AREA_ID(\L\1)/'
git grep -l DT_FLASH_AREA_.*_OFFSET | \
xargs sed -i -r 's/DT_FLASH_AREA_(.*)_OFFSET/FLASH_AREA_OFFSET(\L\1)/'
git grep -l DT_FLASH_AREA_.*_SIZE | \
xargs sed -i -r 's/DT_FLASH_AREA_(.*)_SIZE/FLASH_AREA_SIZE(\L\1)/'
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:
- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
for macros which are equivalent to
DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name
Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.
This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit updates USB audio class implementation with
DT changes introduced in 7e0eed9235. In particular rename
DT_NUM_INST to DT_NUM_INST_STATUS_OKAY.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
By this commit USB audio class implementation is introduced
to Zephyr.
The Zephyr USB audio device class follows bellow
documentations:
- Universal Serial Bus specification rev2.0 (usb20.pdf)
- Universal Serial Bus Device Class Definition for Audio Devices
(audio10.pdf)
- Universal Serial Bus Device Class Definition for Audio Data Formats
(frmts10.pdf)
- Universal Serial Bus Device Class Definition for Terminal Types
(termt10.pdf)
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>