Commit graph

6912 commits

Author SHA1 Message Date
yangao1
99303e9493 note/notestream: Call lib_fileoutstream_open in notefile_register
follow up fileoutstream change

Signed-off-by: yangao1 <yangao1@xiaomi.com>
2025-06-17 20:58:13 +08:00
liwenxiang1
81f27bd602 drivers/segger:Add config option to allow defining the macro as variable
we are using segger RTT protocol over shared memory for two core log/trace: one is NuttX another Linux/Windows. But the base address of shared memory can only be known at runtime, so we change SEGGER_RTT_UNCACHED_OFF from macro to global variable, and update to the correct g_segger_offset after the shared memory is initialized by:
g_segger_offset = (uintptr_t)ishmem - (uintptr_t)&_SEGGER_RTT;

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2025-06-16 14:56:06 +08:00
Jukka Laitinen
42b1ac90fb drivers/segger: Change SEGGER_RTT_LOCK into rspinlock
The SEGGER_RTT_LOCK needs to be recursive, otherwise system will
deadlock in SMP

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-06-15 00:07:26 +08:00
liwenxiang1
2fa5811f7c drivers/segger:Replace the included header file
The trunk branch fails to compile

Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2025-06-15 00:07:26 +08:00
liwenxiang1
525fcb4a45 drivers/segger: move g_segger_lock to segger.c
Signed-off-by: liwenxiang1 <liwenxiang1@xiaomi.com>
2025-06-15 00:07:26 +08:00
Matteo Golin
4ccc3d4c96 drivers/syslog: Add RFC 5424 protocol support
Initial implementation of RFC 5424 support (syslog protocol). Allows
users to force-format the syslog output in a RFC 5424 compatible way,
making NuttX systems 'originators' that are able to interface with
syslog 'collectors' and 'relays' (useful for logging to syslog servers).

In addition to regular formatting options for syslog output, users can
also add structured data (currently only timeQuality is implemented,
assuming no sync and no timezone is no known). Facilities and severities
now also follow RFC 5424. Support for additional features (like
more sdata elements, msgid, etc.) will need to be built into the syslog
implementation if desired.
2025-06-13 20:26:57 +08:00
dongjiuzhu1
cf1e92e5a2 driver/optee: fix compile break
update api name accroading to new implementation.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-06-13 20:14:48 +08:00
Ville Juven
b8e30b54ec fs/vfs: Separate file descriptors from file descriptions
This patch is a rework of the NuttX file descriptor implementation. The
goal is two-fold:

1. Improve POSIX compliance. The old implementation tied file description
to inode only, not the file struct. POSIX however dictates otherwise.
2. Fix a bug with descriptor duplication (dup2() and dup3()). There is
an existing race condition with this POSIX API that currently results
in a kernel side crash.

The crash occurs when a partially open / closed file descriptor is
duplicated. The reason for the crash is that even if the descriptor is
closed, the file might still be in use by the kernel (due to e.g. ongoing
write to file). The open file data is changed by file_dup3() and this
causes a crash in the device / drivers themselves as they lose access to
the inode and private data.

The fix is done by separating struct file into file and file descriptor
structs. The file struct can live on even if the descriptor is closed,
fixing the crash. This also fixes the POSIX issue, as two descriptors
can now point to the same file.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-06-12 18:12:42 +08:00
dongjiuzhu1
a12d21e830 fs/file: unify prefix about file_xxx api, like file_open, file_ioctl
old:
fs_getfilep, fs_putfilep, fs_reffilep
new:
file_get, file_put, file_ref

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-06-12 18:12:42 +08:00
Jukka Laitinen
56ad0d6837 arch: Flag all definitions of up_perf_* functions with CONFIG_ARCH_HAVE_PERF_EVENTS
Use the flag CONFIG_ARCH_HAVE_PERF_EVENTS to detect whether the architecture specific code
provides the up_perf_* functions. Now it is mixed with CONFIG_ARCH_PERF_EVENTS, which should
select just whether the perf events (perf_*) are enabled for the configuration.

- drivers/timers/arch_alarm.c: Don't compile the up_perf_* functions here if the
  CONFIG_ARCH_HAVE_PERF_EVENTS is defined
- arch/*/*_perf.c: Change CONFIG_ARCH_PERF_EVENTS -> CONFIG_ARCH_HAVE_PERF_EVENTS to
  select whether architecture specific up_perf_* functions are provided

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-06-06 17:31:10 +08:00
Jukka Laitinen
82e17623b1 drivers/segger: Add support for System View post-mortem mode
Add a configuration option CONFIG_SEGGER_SYSVIEW_POST_MORTEM to enable
logging continuously into a circular buffer

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-06-06 09:46:08 +08:00
Jukka Laitinen
e81b441f4b drivers/segger: Set correct scaling for perf time
Don't assume that perf_getfreq returns nanoseconds, define the
SEGGER_SYSVIEW_TIMESTAMP_FREQ instead.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-06-06 09:46:08 +08:00
Jukka Laitinen
1178b48047 drivers/note: Fix compilation with -Werr for note driver
- Fix void * arithmetic warning
- Fix unused variable warning without CONFIG_SCHED_INSTRUMENTATION_FILTER

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-06-06 09:46:08 +08:00
Matteo Golin
0bfcbed934 sensors/nau7802: Fix format warning
Silence format string warning by adding missing '%' sign.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2025-06-04 15:26:47 +08:00
chao an
2ff44978c2 drivers/mtd: fix compile warning
mtd/mtd_rwbuffer.c:42:
mtd/mtd_rwbuffer.c: In function 'mtd_erase':
mtd/mtd_rwbuffer.c:189:9: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long long int' [-Wformat=]
  189 |   finfo("block: %08zx nsectors: %zu\n",
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  190 |         (intmax_t)block, nsectors);
      |         ~~~~~~~~~~~~~~~
      |         |
      |         long long int
mtd/mtd_rwbuffer.c:189:21: note: format string is defined here
  189 |   finfo("block: %08zx nsectors: %zu\n",
      |                 ~~~~^
      |                     |
      |                     unsigned int
      |                 %08llx
mtd/mtd_rwbuffer.c: In function 'mtd_ioctl':
mtd/mtd_rwbuffer.c:298:21: warning: format '%d' expects argument of type 'int', but argument 3 has type 'uint32_t' {aka 'long unsigned int'} [-Wformat=]
  298 |               finfo("blocksize: %d erasesize: %d neraseblocks: %d\n",
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  299 |                     geo->blocksize, geo->erasesize, geo->neraseblocks);
      |                     ~~~~~~~~~~~~~~
      |                        |
      |                        uint32_t {aka long unsigned int}
...

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-06-03 17:33:14 +08:00
chao an
d1136084b0 syslog/rpmsg: disable force put char to lower putc
if rpmsg triggers force flushing when the master core provides lower putc,
characters will be duplicated caused by SYSLOG_DEFAULT also send the char to lower half.
in this PR, we disable force put char to lower putc if CONFIG_SYSLOG_DEFAULT is enabled

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-06-03 17:33:03 +08:00
Matteo Golin
b49b62a733 analog/ads1115: Speed up channel measurement delays
The ADS1115 driver uses the `nxsig_usleep()` function to sleep for a
65us delay, but with a 1ms tick resolution and the context-switching
overhead, this is much more than 1ms. Introducing `up_udelay` (even with
a larger duration because of the unreliability of busy-waiting) speeds
up sampling noticeably.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2025-05-29 15:23:06 +08:00
raiden00pl
98e2267297 drivers: unify Private Types banners
unify Private Types banners according to NuttX coding standard

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-28 10:17:15 +08:00
wangzhi16
35a62b7d5e Revert "Reduce the size of tcb by four bytes."
This reverts commit 893c5e92c2.
2025-05-27 16:30:35 +08:00
raiden00pl
1775528beb drivers/sensors: add missing SENSORS prefix after d68476796a
add missing SENSORS prefix after d68476796a for some sensors

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-25 09:50:53 +08:00
Tim Hardisty
a28367f507 drivers/usbdev/cdcncm.c: Fix issue with unplug/replug of USB causing link not to re-establish
Signed-off-by: Tim Hardisty <timh@jti.uk.com>
2025-05-24 12:29:07 +08:00
raiden00pl
d68476796a drivers/sensors: fix various coding style issues
fix various coding style issues for drivers/sensors:

- remove redundant `#define CONFIG_XXX` that should be provided from Kconfig
- correct section banners
- remove empty section banners
- fix some function banners

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-23 11:29:58 -03:00
Lars Kruse
3dc53adb28 arch | boards | drivers: fix whitespace issues for switch case statements 2025-05-23 10:48:41 +08:00
Lars Kruse
3ce85ca54e style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
p-szafonimateusz
49ad027c60 drivers/ctucanfd_pci.c: fix frame reception
Fix frame reception when CANFD is not enabled and there are many message in
the RX buffer.

The previous implementation assumed that the size of the data in the RX buffer
is constant, which is not true. Fortunately, the amount of
data in the buffer can be easily read from frame->fmt.rwcnt.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-05-21 21:10:17 -03:00
raiden00pl
3a31da9585 sensors: add support for BME688 sensor
Add support for BME688 sensor based on BME680 implementation.
The BME688 is nearly identical to the BME680, and this implementation
reuses much of the existing BME680 code. However, there are some differences
related to gas measurements that make it impractical to use the same driver
without significantly complicating it. BME688 also supports parallel mode
which isn't yet supported.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-17 12:16:54 +08:00
Yanfeng Liu
55f85dd727 drivers/ctucan: fix IRQ ctrl
This revises the post-IRQ interruption control logic so that to balance
the disable/enable operations for both chardev and socketcan cases.

Checked with chardev/socketcan on qemu-intel64.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-05-16 18:21:07 +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
p-szafonimateusz
ce99762b36 drivers/ctucanfd_pci.c: fix pointer unaligned GCC error
fix an unaligned pointer error for arm32 build:

  ctucanfd_pci.c:1361:7: warning: converting a packed 'struct ctucanfd_frame_s'
  pointer (alignment 1) to a 'uint32_t' {aka 'long unsigned int'} pointer (alignment 4)
  may result in an unaligned pointer value [-Waddress-of-packed-member]
   1361 |       ptr = (FAR uint32_t *)&rxframe;

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-05-15 10:00:22 +08:00
raiden00pl
dc73324ed0 drivers/can: fix codespell errors
drivers/can: fix codespell errors

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-14 10:30:25 -03:00
raiden00pl
5d95d0871f drivers/can: move CAN utils to CAN common files
Move can_bytes2dlc() and can_dlc2bytes() to a common CAN file
that can be shared between socketCAN implementation and CAN
character driver.

This is the first step to simplifying the logic repeated in
many CAN drivers.

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-14 10:30:25 -03:00
simbit18
ea47f0cf42 [Kconfig]: Fix Kconfig style
Remove spaces from Kconfig files
Add comments
Add TABs

Signed-off-by: simbit18 <simbit18@gmail.com>
2025-05-14 21:15:14 +08:00
George Poulios
47064e42df drivers/misc/optee: Fix non-registered memory ref passing
So far the NuttX implementation of OP-TEE has been using
registered memory references to pass non-registered memory
to OP-TEE OS, passing the physical address of the memory
in what is normally used as a 'cookie'. This was compatible
with the Openvela framework, but no other OP-TEE OS.

Fix this by passing temporary memory instead with the standard
non-contiguous (OPTEE_MSG_ATTR_NONCONTIG) flag.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-13 10:14:01 +08:00
George Poulios
6f77cb6dce drivers/misc/optee: Proper cleanup of registered shm
This is mostly to handle the case that the user calls
close() before calling close() on the shm. In that case
optee_close() frees the shm and then optee_shm_close()
operates on an invalid reference. Fix that.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-13 10:14:01 +08:00
George Poulios
7f20487f56 drivers/misc/optee: Rename optee_shm_entry to optee_shm
This is no longer (exactly) the linked list entry that it
used to be, but rather an associated pointer in an idr tree
entry. Plain 'optee_shm' is more concise, and more appropriate.

Changes also reg_pair_to_uintptr() to reg_pair_to_ptr() for
better readability in invocations.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-13 10:14:01 +08:00
George Poulios
a2a689fee0 drivers/misc/optee: Fix GP API compatibility
Previous implementation was not compatible with GlobalPlatform
API in the following ways:
 - Registered mem IDs would begin from negatives when it should
   have been greater than or equal to 0
 - Register IOCTL would return 0 on success, when it should have
   been returning a file descriptor.
 - Register IOCTL would expect the user-space client to specify
   TEE_SHM_* flags dictating its behaviour when in fact, libteec
   never specifies flags.

This commit fixes all those issues. It uses nuttx/idr.h instead
of a linked list, and it uses `file_allocate` to provide file
descriptors for registered shared memory. Upon close(fd), the
memory is de-registered and freed accordingly. It also updates
the documentation accordingly.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-13 10:14:01 +08:00
George Poulios
c497ee249b drivers/misc/optee: Harmonize invalid user addr errors
Some calls to `optee_is_valid_range()` would return
-EINVAL and some would return -EACCESS. Change all to
-EFAULT (Bad Address) which is more appropriate.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-13 10:14:01 +08:00
Michal Lenc
c0a6afff11 drivers/usbdev/Kconfig: fix COMPOSITE_VENDORSTR description
Option COMPOSITE_VENDORSTR should be described as composite vendor
string, not vendor id. This is consistent with other USB devices.

Also fixes a typo in USBDEV_EPBUFFER_ALIGNMENT.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-05-13 09:57:30 +08:00
Windrow14
b05ec7729d drivers/mmcsd/mmcsd_sdio.c: use dma to receive setup if dma is enabled
Call SDIO_DMARECVSETUP instead of SDIO_RECVSETUP if CONFIG_SDIO_DMA
is defined, aligning with other callings of in mmcsd_sdio.c.

Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
Reviewed-by: Jacky Cao <Jacky.Cao@sony.com>
Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
2025-05-11 20:28:55 +08:00
George Poulios
b103a64a87 drivers/misc/optee: Add SMC backend for arm archs
So far NuttX has supported OP-TEE interfacing over
local and RPMsg sockets. This commit introduces support
for direct invocation of OP-TEE through arm SMCs. The
SMC transport is enabled through CONFIG_DEV_OPTEE_SMC.

This SMC implementation has been tested only with arm64,
OP-TEE rev 4.4.

Note that it does not support reverse direction RPCs,
i.e. from the Secure World to the Normal World to
something like optee supplicant. A basic RPC handling
skeleton is provided with implementation for some
basic functions (alloc/free mem, and foreign interrupts)
but no supplicant command handling.

(+one minor change s/parm/param in arch/arm64/include/syscall
to satisfy the spellchecker during PR)

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-09 10:29:26 +08:00
George Poulios
a2b8c9d1d8 drivers/misc/optee.c: Add shm registration support
Adds support for SHM_REGISTER IOCTL. Registration can
be requested both against the driver (for automatic cleanup)
and against the secure OS (for sharing).

Introduces also `optee_{msg,free}_alloc()` to allocate
aligned memory for message arguments depending on the
`alignment` specified in the driver's private data. For
alignment greater than word size, memory is allocated on the
heap, otherwise it's allocated on the stack (similar to the
previous implementation but using `alloca()` instead).

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-09 10:29:26 +08:00
George Poulios
8546fb080d drivers/misc/optee.c: Add memory sanity checks
Besides a few checks for NULL IOCTL argument values, this
commits introduces also a check to ensure that user specified
memory (mainly IOCTL arguments) indeed belongs to the user.
This is applicable only with `CONFIG_ARCH_ADDRENV`.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-09 10:29:26 +08:00
George Poulios
5c8e5d2ef2 drivers/misc/optee.c: Close session on open error
Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-09 10:29:26 +08:00
George Poulios
da0586c7e3 drivers/misc/optee.c: Decouple transport from driver
Prepares the ground for introducing new transports to
the OP-TEE driver. "transports" as in alternatives to
RPMsg and local network.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
2025-05-09 10:29:26 +08:00
Tim Hardisty
ed0c18c66c drivers/video/fb.c: Add startup splashscreen option
Adds Kconfig-selected splashscreen options used when the driver is first registered

* Includes a new Python script in ./tools to create RLE bitmap files
* Includes default NS logo btimaps in 320x320, 160x160 and 80x80 resolutions along with their PNG files

Signed-off-by: Tim Hardisty  timh@jti.uk.com>
2025-04-30 06:38:05 -03:00
Lars Kruse
9b3914b740 drivers/analog/mcp47x6: Add support for MCP47X6 DAC series
The MCP47X6 series consists of the following single channel DAC chips:
- MCP4706 (8 bit)
- MCP4716 (10 bit)
- MCP4726 (12 bit)

The driver supports the following configurations:
- gain
- power down
- voltage reference

Persistent configuration storage in the internal EEPROM is not
implemented.
2025-04-29 16:17:44 -03:00
p-szafonimateusz
33a6e70077 serial/uart_pci_16550.c: fix multiport ax99100
ax99100 export each serial port as a separate PCI device function
so we have to handle this properly.

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2025-04-29 15:33:23 -03:00
Serg Podtynnyi
9566b2b908 drivers/lcd/ili9341: Add custom width/height display options
Add ability to set custom height/width for each two lcd ifaces

Signed-off-by: Serg Podtynnyi <serg@podtynnyi.com>
2025-04-27 08:37:54 -03:00