461 Commits

Author SHA1 Message Date
daniellizewski fe67544d5f drivers/usbhost/usbhost_cdcecm.c: Converted CDC-ECM to lower half
Converted USB Host CDC-ECM to a lower half driver.
Removed existing full network driver callbacks and replaced with lower
half.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
daniellizewski 9b18160893 drivers/usbhost/usbhost_cdcecm.c: Added support for Host CDC-ECM
Added support for USB host to use an USB CDC-ECM device.
This class is used for usb-ethernet adapters as well as many modems.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
daniellizewski 761c17f1e0 drivers/usbhost/usbhost_enumerate.c: Allow selecting USB configuration
Added support for selecting a different USB configuration.
Certain USB devices offer different classes using different
configurations. This allows a board file to provide a callback
to select the proper configuration for a given USB device.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-05-06 06:20:03 +08:00
daniellizewski 1632beaede arch/arm/src/stm32h5/stm32_usbdrdhost.c: Fixed Hub support
Fixed a few bugs in the initial stm32_usbdrdhost.c implementation
when using a USB hub. Fixed fault when freeing control endpoints.
Fixed crash when disconnecting devices from hubs due ot use after free.

Signed-off-by: daniellizewski <daniellizewski@geotab.com>
2026-04-19 14:24:40 +08:00
Piyush Patle 0dccc8ba21 include/debug.h: Move to include/nuttx/debug.h
debug.h is a NuttX-specific, non-POSIX header. Placing it in the
top-level include/ directory creates naming conflicts with external
projects that define their own debug.h.
This commit moves the canonical header to include/nuttx/debug.h,
following the NuttX convention for non-POSIX/non-standard headers,
and updates all in-tree references.

A backward-compatibility shim is left at include/debug.h that
emits a deprecation #warning and re-includes <nuttx/debug.h>,
allowing out-of-tree code to continue building while migrating.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-07 07:50:06 -03:00
Peter Barada efdbdfe409 arch/arm/stm32*: Use PRIx32 format specifier where appropriate
Replace 'x' printf format specifier with PRIx32 where
corresponding value is uint32_t type.

Signed-off-by Peter Barada <peter.barada@gmail.com>
2026-04-01 13:48:58 +08:00
Huang Qi e3eeaefd6d style: Fix "the the" typo across the codebase.
Fix 269 occurrences of duplicate "the" word typo found in 209 files
across source code, header files, and configuration.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2026-03-23 11:07:49 +01:00
zhanghongyu a7567677a8 netdev_driver: add carrier_on to xxx_ifup where carrier_on is absent
since the judgment for network card selection was changed from IS_UP to
IS_RUNNING, drivers that lack carrier_on need to add the carrier_on
operation; otherwise, network access issues will occur.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-02-02 13:23:05 +08:00
Alan Carvalho de Assis 0e5323370f drivers/usbhost_hidkbd: Fix small typo in usbhost_hidkbd.c
Build Documentation / build-html (push) Has been cancelled
There were missing quotes for key "backspace" for scancodes.
This issue was found by github user @StagiaireAbritek

He opened an PR in github to fix it:
https://github.com/apache/nuttx/pull/15917

However he decided to abandon and close the PR, but because it is
an important fix I decided submit it upstream.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2026-01-18 11:57:58 -05:00
zhanghongyu fa6c8579dd driver/net: replace net_lock with netdev_lock
modify the code of the adapted protocol stack to avoid deadlocks and the
logic that cannot be protected by locks after modification.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-06 16:08:30 +08:00
yangsong8 a87ad98343 usbhost: cdcacm exit wq after copy all received data
Build Documentation / build-html (push) Has been cancelled
Fix issue: When the SIM CDCACM host receives data, the second packet
data reception is incorrect.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-14 10:37:53 -03:00
yangsong8 f2191a7e3b drivers/usbhost: fix build waring
usbhost/usbhost_hidkbd.c:1373:14: warning: unused variable ‘flags’ [-Wunused-variable]
 1373 |   irqstate_t flags;
      |              ^~~~~

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 13:03:52 +08:00
yangsong8 2660df6581 drivers/usbhost: use small lock to protect usbhost kbd
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 13:03:52 +08:00
yangsong8 25ec00c67c drivers/usbhost: improve usbhost hid kbd code
By passing parameters to the kthread_create process, reduce the global
variables and nxmutex lock.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 13:03:52 +08:00
yangsong8 a7af894cd3 driver/usbhost: use small lock to protect usbhost cdcmbim
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 12:39:48 +08:00
yangsong8 23cec99002 drivers/usbhost: use small lock to protect usbhost cdcacm
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 12:39:48 +08:00
yangsong8 62f7a8fa22 drivers/usbhost: use small lock to protect usbhost bthci
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 12:39:48 +08:00
yangsong8 5571ec8fa2 drivers/usbhost: use small lock to protect usbhost msc
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 12:39:48 +08:00
yangsong8 b9b62a9204 drivers/usbhost: Use small lock to protect usbhost common function
replace critical_section with spinlock

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-13 12:39:48 +08:00
yangsong8 7907a5b1c3 driver/usbhost: Support obtaining USB3.0 device descriptors
usbhost supports USB 3.0 device descriptors.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-12-09 08:57:28 -05:00
Alan Carvalho de Assis 8cb1fd713e drivers/usbhost_hub: Add support to Multiple TT HS HUB
This is the case for USB2517 USB HUB. Also improved the driver to
avoid mistakes: initially I changed g_id[3], but the in register
there is another field where we need to pass this size again. So
it is better to use ARRAY_SIZE() macro to avoid mistakes.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2025-10-27 18:24:42 +08:00
chao an 87f134cfaa sched/sleep: replace all Signal-based sleep implement to Scheduled sleep
Nuttx currently has 2 types of sleep interfaces:

1. Signal-scheduled sleep: nxsig_sleep() / nxsig_usleep() / nxsig_nanosleep()
Weaknesses:
a. Signal-dependent: The signal-scheduled sleep method is bound to the signal framework, while some driver sleep operations do not depend on signals.
b. Timespec conversion: Signal-scheduled sleep involves timespec conversion, which has a significant impact on performance.

2. Busy sleep: up_mdelay() / up_udelay()
Weaknesses:
a. Does not actively trigger scheduling, occupy the CPU loading.

3. New interfaces: Scheduled sleep: nxsched_sleep() / nxsched_usleep() / nxsched_msleep() / nxsched_ticksleep()
Strengths:
a. Does not depend on the signal framework.
b. Tick-based, without additional computational overhead.

Currently, the Nuttx driver framework extensively uses nxsig_* interfaces. However, the driver does not need to rely on signals or timespec conversion.
Therefore, a new set of APIs is added to reduce dependencies on other modules.

(This PR also aims to make signals optional, further reducing the code size of Nuttx.)

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-10-17 14:05:02 +08:00
simbit18 db26ef1bd2 drivers/usbhost: Aligned Cmake with Make
Add:

- Bluetooth HCI Driver #11552

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-10-09 18:20:36 -04:00
Lars Kruse 3ce85ca54e style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
p-szafonimateusz fab4f68b6f drivers/usbhost: add xHCI support
add xHCI PCI driver (usbhost).

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-05-15 21:58:57 +08:00
p-szafonimateusz 3dc1ac91d6 usbhost: add common usb host waiter and drivers initialization
add common usb host waiter and drivers initialization which is
required for xHCI support

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-05-15 21:58:57 +08:00
Lars Kruse 4568110d63 fix misspelled names in locally scoped code
These misspelled words are used in strictly local scopes.
Renaming these variables should not cause any problems.
2025-05-15 10:12:12 +08:00
yangsong8 7bad94a964 drivers/usbhost: recognize sim usb cdcacm composite device
In the USB interface descriptor of the cdcacm device, class:2 (CDC)
subclass:2 (ACM) protocol:0 (NONE) may appear. At this time, the
usb host does not match the correct protocol byte, which will cause
the device identification to fail.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-03-05 10:11:29 +01:00
Alin Jerpelea 35a4fc05d9 drivers/usbhost/hid_parser: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-18 17:51:57 +08:00
Alin Jerpelea 286d37026c drivers: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-11-06 18:02:25 +08:00
Petro Karashchenko d499ac9d58 nuttx: fix multiple 'FAR', 'CODE' and style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
Petro Karashchenko 7b18f9d19f nuttx: add missing 'FAR' and fix style issues
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
Petro Karashchenko ebddc8d8ee drivers/usbhost: remove unused function
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2024-08-25 19:22:15 +08:00
zhanghongyu 4e79741e7d usbdev: add ncm driver
The compilation and verification commands are shown below:
./tools/configure.sh sim:usbdev
make -j
sudo ./nuttx
nsh> conn 2
nsh> dhcpd_start eth1

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-08-21 02:01:01 +08:00
Yanfeng Liu c3aab93e5f usb: document revision and typo fixing
This slightly revised the USB host documentation and fixed typos
encountered in the document and some source files.

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-01-18 21:09:20 -08:00
Lwazi Dube 1c0299b687 drivers/usbhost: Update USB bluetooth driver
Miscellaneous changes addressing feedback from xiaoxiang781216.
2024-01-17 17:49:02 -08:00
Lwazi Dube 1349dcfc1f drivers/usbhost: Add a USB bluetooth driver.
This change adds support for the USB Transport Layer as described
in the bluetooth spec. Isochronous endpoints are not yet supported.
Because of limitations in the NuttX bluetooth stack, only one USB
device can be used. This driver will only allow one USB dongle to
use bluetooth.

A Laird USB BT4.2 dongle (from Mouser) was used for testing:
M/N BT851 1.0 1829, FCC ID:SQGBT850
lsusb: 04b4:f901 Cypress Semiconductor Corp. CYW20704A2

The following commands were used to test from the nsh prompt:
bt bnep0 scan start
bt bnep0 scan stop
bt bnep0 scan get
bt bnep0 info

The Linux gatttool was used to connect over wireless.

With the BDAddr found by "bt bnep0 info", start gatttool using:
gatttool -b BDAddr -I

Connect to the device using:
connect

Read the device name using the GAP device name UUID:
char-read-uuid 2a00

Part of the response is:
value: 41 70 61 63 68 65 20 4e 75 74 74 58
which is the string "Apache NuttX"
2024-01-16 16:02:15 +01:00
hujun5 1a65f5ed88 sched_lock refine: remove sched_[un]lock in xxx_waitsample
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-11-21 20:03:43 -08:00
Xiang Xiao eddd90de78 poll: pollsetup should notify only one fd passd by caller
since it's redundant to iterate the whole fds array in setup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
hujun5 66fa229fcc Fix some typos in comments
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-10-11 08:14:49 +02:00
Daniel Appiagyei 5bfda12634 c++ compatibility: rename reserved c++ keywords 'public' and 'this' 2023-09-16 19:45:02 +08:00
chao an 664927c86e mm/alloc: remove all unnecessary cast for alloc
Fix the minor style issue and remove unnecessary cast

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-30 14:34:20 +08:00
chao an b60f01a55b inode/i_private: remove all unnecessary cast for i_private
Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 08:58:07 +02:00
chao an 7aa45305b7 fs/inode: remove all unnecessary check for filep/inode
Since VFS layer already contains sanity checks, so remove unnecessary lower half checks

Signed-off-by: chao an <anchao@xiaomi.com>
2023-08-29 09:47:11 +08:00
Petro Karashchenko 075738cf14 net/ip: print ip addresses using ip4_addrN macro
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-08-19 13:28:21 -03:00
Zhihong Chen 8e85e52708 drivers: usbhost: fix usbhost_hidkbd some errors
- usbhost_send_request(): data should using DRVR_ALLOC buffer
- fix usbhost_cralloc() assert variable

Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
2023-07-27 00:51:59 -07:00
Zhihong Chen 3d8324962a drivers: usbhost_hub: usb communication memory should use DRVR_ALLOC
- usb communication memory should use DRVR_ALLOC

Signed-off-by: Zhihong Chen <zhihong.chen@hpmicro.com>
2023-07-19 13:38:36 +08:00
chao an 6ee9ec7656 build: add initial cmake build system
1. Update all CMakeLists.txt to adapt to new layout
2. Fix cmake build break
3. Update all new file license
4. Fully compatible with current compilation environment(use configure.sh or cmake as you choose)

------------------

How to test

From within nuttx/. Configure:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja
cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
cmake -B build -DBOARD_CONFIG=sabre-6quad/smp -GNinja
cmake -B build -DBOARD_CONFIG=lm3s6965-ek/qemu-flat -GNinja

(or full path in custom board) :
cmake -B build -DBOARD_CONFIG=$PWD/boards/sim/sim/sim/configs/nsh -GNinja

This uses ninja generator (install with sudo apt install ninja-build). To build:

$ cmake --build build

menuconfig:

$ cmake --build build -t menuconfig

--------------------------

2. cmake/build: reformat the cmake style by cmake-format

https://github.com/cheshirekow/cmake_format

$ pip install cmakelang

$ for i in `find -name CMakeLists.txt`;do cmake-format $i -o $i;done
$ for i in `find -name *\.cmake`;do cmake-format $i -o $i;done

Co-authored-by: Matias N <matias@protobits.dev>
Signed-off-by: chao an <anchao@xiaomi.com>
2023-07-08 13:50:48 +08:00
Xiang Xiao 694c0f0b7f usbhost/cdcacm: Fix the compiler warning when serial dma is enabled
CP:  nuttx/nuttx/include/nuttx/config.h
CC:  mqueue/mq_sndinternal.c usbhost/usbhost_cdcacm.c:435:3: warning: initialization of ‘void (*)(struct uart_dev_s *)’ from incompatible pointer type ‘void (*)(struct uart_dev_s *, _Bool)’ [-Wincompatible-pointer-types]
  435 |   usbhost_txint,         /* txinit */
      |   ^~~~~~~~~~~~~
usbhost/usbhost_cdcacm.c:435:3: note: (near initialization for ‘g_uart_ops.dmareceive’)
usbhost/usbhost_cdcacm.c:436:3: warning: initialization of ‘void (*)(struct uart_dev_s *)’ from incompatible pointer type ‘_Bool (*)(struct uart_dev_s *)’ [-Wincompatible-pointer-types]
  436 |   usbhost_txready,       /* txready */
      |   ^~~~~~~~~~~~~~~
usbhost/usbhost_cdcacm.c:436:3: note: (near initialization for ‘g_uart_ops.dmarxfree’)
usbhost/usbhost_cdcacm.c:437:3: warning: initialization of ‘void (*)(struct uart_dev_s *)’ from incompatible pointer type ‘_Bool (*)(struct uart_dev_s *)’ [-Wincompatible-pointer-types]
  437 |   usbhost_txempty        /* txempty */
      |   ^~~~~~~~~~~~~~~
usbhost/usbhost_cdcacm.c:437:3: note: (near initialization for ‘g_uart_ops.dmatxavail’)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-06-05 09:25:31 +02:00
simbit18 e4ffce3355 Fix Kconfig style
Remove spaces from Kconfig files
2023-05-23 00:03:25 +08:00