Commit graph

7687 commits

Author SHA1 Message Date
Jukka Laitinen
edaa074e51 include/nuttx/atomic.h: For each ATOMIC func, cast the parameters to (FAR intXX_t *) of correct size
This fixes useless -Wpointer-sign errors with clang when doing atomic operations on unsigned datatypes.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-04-17 20:14:15 +08:00
Carlos Sanchez
d976c66edf net: use bps units for bitrate in SocketCAN interfaces.
This makes units compatible with what Linux uses for SocketCAN bitrate
and allows representing usual Single Wire Can (SAE J2411) usual bitrates
of 33333 and 83333 bps.

Signed-off-by: Carlos Sanchez <carlossanchez@geotab.com>
2025-04-16 11:07:27 -03:00
chao an
52482219c8 libc/elf: rename modlib to libelf
Renaming "modlib" to "libelf" is more in line with the implementation content,
which makes it easier for individual developers to understand the capabilities of this module.

CONFIG_LIBC_MODLIB -> CONFIG_LIBC_ELF

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-11 09:43:22 +08:00
chao an
59da455fea libs/libc/crc16: Separate implementation of crc16xmodem from crc16
keep default crc16 catalogue for CRC-16/XMODEM

Mapping crc16 implement to crc16xmodem

crc16     -> crc16xmodem
crc16part -> crc16xmodempart

- CRC-16/ACORN, CRC-16/LTE, CRC-16/V-41-MSB, XMODEM, ZMODEM
poly: 0x1021 initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x1021
: init=0x0000
: refin=false
: refout=false
: xorout=0x0000
: check=0x31c3
: residue=0x0000
: name="CRC-16/XMODEM"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-xmodem

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-10 16:47:28 +08:00
chao an
db91b3b53c nuttx/compiler: add support of deprecated attribute
Warning about usage of deprecated features.

since __deprecated__ is a compiler built-in macro, so we define the deprecated with "deprecated_function"

Break log:

| /usr/include/x86_64-linux-gnu/sys/cdefs.h:355:65: error: missing ')' after "__has_attribute"
|   355 | #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
|       |                                                                 ^
| /usr/include/x86_64-linux-gnu/sys/cdefs.h:355:51: error: missing binary operator before token "("
|   355 | #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
|       |                                                   ^~~~~~~~~~~~~~

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-10 14:34:57 +08:00
anjiahao
422c43949a binfmt:use crt0 inside of starthook
test:
1.use mps3-an547 build helloxx as module and run it
2.use qemu-armv7a:knsh test kernel build helloxx and run it

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2025-04-09 23:07:29 +08:00
Ville Juven
850cfb545a Revert "includes/nuttx: fix _SCHED_GET(T/P/PP)ID definition issue"
This reverts commit 9369b75ee5.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
2025-04-08 22:53:10 +08:00
Ville Juven
04e760b1c2 sched/gettid: Move thread ID to TLS
There is no need for a gettid() syscall, as the thread ID is stable through
the life of the process. It is safe to put a copy of TID to TLS. This way
a user processes can access TID quickly via its own stack, instead of
having to use an expensive syscall.

Signed-off-by: Ville Juven <ville.juven@unikie.com>
2025-04-08 22:53:10 +08:00
chao an
53836fc18a libs/libc/crc16: add support of CRC-16/ANSI(aka CRC-16/IBM)
Compatible CRC16 with Linux Kernel:
https://github.com/torvalds/linux/blob/master/lib/crc16.c

- CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-16/KERMIT
poly: 0x8005 (0xA001) initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x8005
: init=0x0000
: refin=true
: refout=true
: xorout=0x0000
: check=0xbb3d
: residue=0x0000
: name="CRC-16/ARC"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-arc

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-07 12:10:05 +08:00
chao an
4e2f6eabb3 libs/libc/crc16: add some comments for crc16ccitt
The search table of ccitt should describe more algorithm details:

- CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-16/KERMIT
initial seed: 0x0000, xor output: 0x0000

: width=16
: poly=0x1021
: init=0x0000
: refin=true
: refout=true
: xorout=0x0000
: check=0x2189
: residue=0x0000
: name="CRC-16/KERMIT"

https://reveng.sourceforge.io/crc-catalogue/16.htm#crc.cat.crc-16-kermit

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-07 09:02:01 +08:00
chao an
58ed9934c2 syscall/csv: add nxsem_tickwait() to userspace
mutex_tickwait() depends on this API

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-03 20:13:55 +08:00
chao an
0d6de4c0a7 sched/mutex: add ticked lock version for mutex/rmutex
Added ticked lock version for mutex to reduce time calculation overhead

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-04-03 20:13:55 +08:00
Kerogit
ac42add946 nuttx/clock: make NSEC_PER_USEC and others long
On AVR architecture, the compiler apparently sometimes truncates NSEC_PER_TICK
to 16bit value, leading to clock_time2ticks returning incorrect results. This
was encountered while attempting to add tickless OS support for AVR
architecture but seemed to affect non-tickless mode of operation as well.

This patch marks NSEC_PER_USEC (and to be safe, USEC_PER_MSEC and MSEC_PER_SEC
too) as long.
2025-04-02 08:29:00 -03:00
ouyangxiangzhen
9f01e5c972 libc/stream: Support lowsyslog.
This commit added support for lowsyslog.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-04-02 12:01:46 +08:00
Jukka Laitinen
19a8e2403f libc/semaphore: Move fast mutex wait/post paths to libc
This avoids unnecessary syscalls in memory protected builds, when mutex
lock/unlock can be done with only atomic counter access

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-04-01 20:37:23 +08:00
Daniel Byshkin
504f838577 sensors/nau7802: Add support for the NAU7802
This patch adds support for the NAU7802 24 bit ADC from Nuvoton.
Please read the documentation for more details.

Signed-off-by: Daniel Byshkin <online@bskdany.com>
2025-04-01 09:38:37 +08:00
Alexander Lerach
d1be769038 arch/arm: Fix crash when using memcpy/memset as RAMFUNCS
Add no_builtin for memcpy/memset to the startup code of boards
with CONFIG_ARCH_RAMFUNCS, because certain compilers call memcpy/memset
instead of the explicit for loop. This will cause a crash if memcpy/memset
are mapped to RAM because the function that copies them to RAM is called later,
resulting in undefined code being executed.

Signed-off-by: Alexander Lerach <alexander@auterion.com>

arch/arm: Use decorator for entry point

Use a decorator that contains the required no_builtin instead of adding
them explicitly to the startup code. This way it will be easier to
maintain them in the future when changes to the no_builtin used are required.

Signed-off-by: Alexander Lerach <alexander@auterion.com>

arch/arm: Rename decorator

Rename the entry point decorator used for the startup code to a less explicit name.
This way the style is more consistent with other decorators.

Signed-off-by: Alexander Lerach <alexander@auterion.com>
2025-03-27 02:17:14 +08:00
Jukka Laitinen
06d00b4c88 Correct the pthread mutex priority inheritance default setting
After pthread mutexes changed to nxmutex, the priority inheritance
was set on by default; even if one tried to control it with
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT.

Also the CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_PROTECT is not effective.

Fix this by setting the default mutex priority adjustment flags according
to CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT and CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_PROTECT.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2025-03-26 22:36:48 +08:00
stbenn
c4a84e30b7 driver/mtd: ramtron multi-device spi bus support
Adds a device ID to ramtron_initialize, which is stored in the ramtron_dev_s structure.
This ID is used when calling SPI_SELECT to board specific logic to allow chip select on the SPI bus.

This change is NOT backwards compatible, as it changes the function signature of ramtron_initialize.

This implementation is based on the handling of chip select in nuttx/drivers/mtd/sst26.c:sst26_initialize_spi().

Additional Changes:
  - Add MB85RS64V to ramtron supported parts list.
2025-03-26 19:26:01 +08:00
wangjianyu3
b73d7f2922 drivers/ioexpander: Add support for PCA9557
Datasheet: https://www.ti.com/lit/ds/symlink/pca9557.pdf

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-03-25 15:46:09 -03:00
Tony Lin
1f2f910ccd drivers/analog/ads1115: Add support for the Texas Instruments ADS1115
This patch adds initial support for the Texas Instruments ADS1115 ADC.
Please read the documentation for more details.

Signed-off-by: Tony Lin <99093620+justapotato213@users.noreply.github.com>
2025-03-25 09:49:51 +01:00
SPRESENSE
64b97bda5d drivers/sensors: Add CXD5602PWBIMU driver for IMU Add-on board
Add CXD5602PWBIMU driver for IMU Add-on board.

Signed-off-by: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com>
2025-03-24 16:07:45 -03:00
Kevin Witteveen (MartiniMarter)
1cd3b3d01c nuttx/wireless/ioctl: Common IOCTL API for RF Modulation Technologies.
This PR is a follow-up of issue #15856 and the mailing list proposal "Proposal: Common IOCTL API for RF Modulation Technologies"

Before this PR, the IOCTL API for character-driven RF devices lacked a common
interface across different modulation technologies, such as LoRa, FSK, and
OOK. The result was, driver-specific IOCTL commands were created even when they
could be shared across multiple radios. This fragmentation made
application portability more difficult to maintain.

This PR will add a common API that can be shared across all new drivers.
Such as
* LoRa
* FSK
* OOK / ASK
* read() return struct

Signed-off-by: Kevin Witteveen (MartiniMarter) <kevinwit1999@gmail.com>
2025-03-23 17:51:15 +08:00
raiden00pl
19a99205c2 include/nuttx/math.h: add missing HUGE_VALF and HUGE_VALL
add missing HUGE_VALF and HUGE_VALL definitions to NuttX math.h

Signed-off-by: raiden00pl <raiden00@railab.me>
2025-03-21 08:57:13 +01:00
Eritque arcus
50c0e13a29 typo: fix incorrect doc 2025-03-12 10:36:30 -03:00
yangsong8
9c55a19238 driver/syslog: add cdcacm channel
Use the CDCACM as a SYSLOG output device, send message to remote proc.
If there are more than one CDCACM devices, then a device minor number
may also need to be provided. Default: 0

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-03-10 13:43:54 +08:00
ouyangxiangzhen
bcad1d038a sched/wqueue: Rename periodic workqueue API.
This commit renamed the periodic workqueue API.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-03-08 13:52:37 -03:00
ouyangxiangzhen
ed04000626 sched/wqueue: support for periodic workqueue.
This commit added support for periodic workqueue.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-03-08 13:52:37 -03:00
ouyangxiangzhen
f495cd4ffd sched/wdog: allow wd_cancel_period in the periodical wdog callback.
This commit addresses an issue where calling `wd_cancel_period` within the periodic watchdog callback would fail to cancel the watchdog timer.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-03-08 13:52:37 -03:00
ouyangxiangzhen
51399a76d9 sched/wdog: support for periodic wdog.
This commit added support for periodic wdog.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2025-03-08 13:52:37 -03:00
Matteo Golin
b9b505a2b2 wireless/lpwan: Add support for the RN903 and RN2483 family of LoRa
radio transceivers. This initial support includes transmit and receive
functionality and configuration and reading of radio parameters like
frequency and bandwidth.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2025-03-06 06:10:19 -03:00
yangsong8
c497c5feb0 drivers/serial/cdcacm: Reduce one copy of data between serial and cdcacm framework
Data form serial framework will be written to usb reqbuf directly,
and data form cdcacm will be read form reqbuf directly.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2025-03-05 12:52:00 -03:00
chao an
fc870d0984 libc/strings: fix compile warning if enable -Wshadow
Replace inline functions with macros to avoid confilcts with builtin definition

nuttx/include/strings.h:80:28: warning: declaration of 'ffs' shadows a built-in function [-Wshadow]
   80 | static inline_function int ffs(int j)
      |                            ^~~
nuttx/include/strings.h:94:28: warning: declaration of 'ffsl' shadows a built-in function [-Wshadow]
   94 | static inline_function int ffsl(long j)
      |                            ^~~~
nuttx/include/strings.h:109:28: warning: declaration of 'ffsll' shadows a built-in function [-Wshadow]
  109 | static inline_function int ffsll(long long j)
      |                            ^~~~~

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-03-05 11:20:01 -03:00
Kevin Witteveen (MartiniMarter)
20ed2e689c drivers/wireless/lpwan/sx126x:
[Experimental]
This adds a driver for the SX126x (SX1261 and SX1262) LoRa chips.
All functions and definitions are coming directly from the DS SX1261-2 V2.1 datasheet.

Signed-off-by: Kevin Witteveen (MartiniMarter) <kevinwit1999@gmail.com>
2025-02-27 16:03:18 -03:00
Michal Lenc
86917b4777 drivers/pwm: add PWMIOC_FAULTS_FETCH_AND_CLEAR ioctl for fault clears
This ioctl clears the active fault inputs. Some faults can be latched
(still active even if the source is not active anymore), so they have
to be cleared from the software. The argument is a pointer to unsigned
long bitmask variable. This bitmask specifies which faults are to be
cleared.

The ioctl also can fetch the faults active prior to the clear. These
faults are saved to the argument specifying which faults are to be
cleared. Therefore passing zero bitmask means the driver will only return
active faults and clear none. Passing NULL pointer means the driver
will clear all active and return none.

The implementation of this ioctl is per driver.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2025-02-27 11:47:51 -03:00
chao an
52a13a8351 sched/spin_lock: continue work to rename raw_spin* to spin_*_notrace
Some improvements are made to the following commits:

| commit f22b93b337
| Author: hujun5 <hujun5@xiaomi.com>
| Date:   Fri Jan 31 07:01:07 2025 +0800
|
|     sched/spin_lock: rename raw_spin_lock to spin_lock_notrace
|
|     Signed-off-by: hujun5 <hujun5@xiaomi.com>

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-02-27 06:11:58 +02:00
chao an
5a64967ce7 nuttx/compiler: fix build warning on GCC14
nuttx/include/arch/armv8-m/irq.h:496:36: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  496 | static always_inline_function bool up_interrupt_context(void)
      |                                    ^~~~~~~~~~~~~~~~~~~~
nuttx/include/arch/armv8-m/irq.h:490:41: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  490 | static always_inline_function uintptr_t up_getusrsp(void *regs)
      |                                         ^~~~~~~~~~~
nuttx/include/arch/armv8-m/irq.h:477:40: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  477 | static always_inline_function uint32_t up_getsp(void)
      |                                        ^~~~~~~~
nuttx/include/arch/armv8-m/irq.h:451:40: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  451 | static always_inline_function uint32_t getpsp(void)
      |                                        ^~~~~~
nuttx/include/arch/armv8-m/irq.h:441:36: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  441 | static always_inline_function void setcontrol(uint32_t control)
      |                                    ^~~~~~~~~~
nuttx/include/arch/armv8-m/irq.h:428:40: warning: 'always_inline' function might not be inlinable unless also declared 'inline' [-Wattributes]
  428 | static always_inline_function uint32_t getcontrol(void)
      |                                        ^~~~~~~~~~

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-02-18 09:04:54 -05:00
wangjianyu3
0b633946c0 drivers/thermal: Add support for passive trip point
Spliting `THERMAL_NORMAL` to `THERMAL_ACTIVE` and `THERMAL_PASSIVE`,
to support different update intervals for thermal zone.

Active/Passive from [kernel.org](https://www.kernel.org/doc/Documentation/devicetree/bindings/thermal/thermal.txt):

  * Cooling device nodes

  Cooling devices are nodes providing control on power dissipation. There
  are essentially two ways to provide control on power dissipation. First
  is by means of regulating device performance, which is known as passive
  cooling. A typical passive cooling is a CPU that has dynamic voltage and
  frequency scaling (DVFS), and uses lower frequencies as cooling states.
  Second is by means of activating devices in order to remove
  the dissipated heat, which is known as active cooling, e.g. regulating
  fan speeds. In both cases, cooling devices shall have a way to determine
  the state of cooling in which the device is.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2025-02-16 11:22:41 -03:00
Alan Carvalho de Assis
5a6e5a8fb4 serial: Add struct serial_icounter_s and CONFIG_SERIAL_TIOCGICOUNT
This commit add support to the serial_icounter_s struct used with
TIOCGICOUNT to report U[S]ART errors such as frame, parity, overrun,
etc.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
2025-02-14 18:24:47 +01:00
hujun5
f22b93b337 sched/spin_lock: rename raw_spin_lock to spin_lock_notrace
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-02-13 20:48:15 +08:00
hujun5
42e6825cbc Revert "spinlock: add sched_lock to spin_lock_irqsave"
This reverts commit edc049117bcf3180d74d93a0c6ae63695d1bcd91.
2025-02-13 20:48:15 +08:00
Jacob Dahl
3dcedd507b h7: eth: add checks for PHYID in stm32_phyinit
Fixes bug where stm32_phyinit will succeed even when no PHY is connected. This is because there is no check that a PHY is actually communicating and returning data.

Update include/nuttx/net/mii.h

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2025-02-12 15:00:19 -03:00
Matteo Golin
729f8a75f7 drivers/sensors: Added uORB driver for LSM6DSO32 IMU.
Adds support for the LSM6DSO32 IMU by STM using the uORB framework. This
only contains limited support for the I2C interface, interrupt and
polling driven measurement and standard modes of operation (high
performance ODRs). Features like interrupts besides DRDY, filtering,
gesture recognition and acting as a bus master are not implemented.
2025-02-12 10:44:15 -03:00
zhaohaiyang1
e657b35720 nuttx/can: Modify poll logic to bind can_reader_s and pollfd.
For clearing some variables corresponding with the pollfds of the felip in can_close API, we modify poll logic by binding can_reader_s and pollfd.

Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2025-02-12 10:28:21 -03:00
dongjiuzhu1
34bde7b80a qemu/armv7a: register cfi flash
search the device tree and register cfi flash

test flowchart:
mount -t littlefs -o autoformat /dev/cfi-flash1 /data
fstest -m /data

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-02-11 17:23:44 +08:00
zhengyu9
2c4285d9ac mtd/mtd_cfi: cfi flash bind to mtd interface
Bind cfi flash driver with the existing mtd interface

Signed-off-by: zhengyu9 <zhengyu9@xiaomi.com>
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-02-11 17:23:44 +08:00
Tiago Medicci Serrano
2ebdd72487 include/stdlib.h: define system()'s prototype for the flat build
The `$(APPDIR)` folder is added to the `$(KERNDEPDIRS)` when
`CONFIG_BUILD_KERNEL=y`. The `depend` phase iterates over the
`$(KERNDEPDIRS)` folders and executes the `depend` recipe of these
folders (including the apps' recipes) with the `__KERNEL__` macro
defined, which prevents `system()`'s prototype from being declared.
2025-02-07 09:03:14 +08:00
Javier Casas
d52ff33e78 net/can/: add statistics for recv, sent and drop
Add support for network statistics for CAN.
It includes counters for receive, sent
and drop frames.

Signed-off-by: Javier Casas <javiercasas@geotab.com>
2025-01-30 11:37:29 -03:00
Matteo Golin
044879e7a3 sensors/lis2mdl: Create a UORB driver for the LIS2MDL magnetometer. 2025-01-28 16:34:17 +08:00
wanggang26
f6b9a8f577 coredump: fix issue that nvic region overlapped by board memory region
Firstly call arm_coredump_add_region in up_initialize to add nvic region, then call
coredump_set_memory_region to add board mem region, at this moment, an overlap occurs.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2025-01-24 09:15:56 +08:00