Commit graph

61016 commits

Author SHA1 Message Date
Eren Terzioglu
16829666cb boards/risc-v/esp32c6: Add missing config for esp32c6 romfs
Add missing config for romfs on esp32c6-devkitc

Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
2026-02-02 15:42:10 +01:00
hujun5
c844ecf393 sched_profil.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in the profil() function
into a single exit point by inverting the parameter validation condition and
restructuring error handling to reduce cyclomatic complexity and comply with MISRA HIS.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 22:18:16 +08:00
wangzhi16
a06ac14988 tools/nxstyle: add phy62xx/uart.c into style white list
To skip the style issue:
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:194:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:196:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:199:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:61:28: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:104:2: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:162:50: error: Mixed case identifier found

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-02-02 21:17:20 +08:00
wangzhi16
a2e8a5464e arch/xtensa: replace critical_section with spinlock.
The benefits of doing this are:

1. It makes the code logic clearer, with different resources protected by different locks.

2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-02-02 21:17:20 +08:00
wangzhi16
4de188cbed arm64/common: Critical Section Optimization.
Replace critical_section with spinlock.
The benefits of doing this are:

1. It makes the code logic clearer, with different resources protected by different locks.

2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-02-02 21:17:20 +08:00
wangzhi16
a53d58c5c3 arm/phy62xx: Critical Section Optimization.
The benefits of doing this are:

1. It makes the code logic clearer, with different resources protected by different locks.

2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-02-02 21:17:20 +08:00
wangzhi16
44f2f6f8f1 arm/rtl8720c: Critical Section Optimization.
Replace critical_section with spinlock or mutex.
The benefits of doing this are:

1. It makes the code logic clearer, with different resources protected by different locks.

2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2026-02-02 21:17:20 +08:00
fangxinyong
a724a5f4f4 sched/cancelpt: Fix MISRA C 2012 Rule 10.4 violations
Fix violations of MISRA C:2012 Rule 10.4 (operand of unsigned and signed)
in cancellation point handling code.

Changed all CANCEL_FLAG_* macro definitions and their usage to use unsigned
literals (1u instead of 1) to ensure consistent unsigned arithmetic when
performing bitwise operations. This eliminates mixed signed/unsigned operand
violations in:

- CANCEL_FLAG_NONCANCELABLE
- CANCEL_FLAG_CANCEL_ASYNC
- CANCEL_FLAG_CANCEL_PENDING

The changes affect cancellation point entry/exit logic, cancellation state
management, and cancellation type handling across both kernel and libc
implementations.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-02-02 21:09:40 +08:00
fangpeina
35e579d2d3 Documentation/nsh: Add stderr and stdin redirection documentation
This commit updates the NSH documentation about redirection syntax.

This documentation update corresponds to the stderr redirection feature
added in nuttx-apps PR #3378.

Signed-off-by: fangpeina <fangpeina@xiaomi.com>
2026-02-02 14:01:53 +01:00
hujun5
f794238bb8 boards/boardctl.c: BOARDIOC_SPINLOCK missing some Conditional branch
Add missing else branches to handle spinlock operations when no valid spinlock
pointer is available. This fixes a regression in IRQ save/restore operations
introduced by a previous refactoring of the spinlock control logic.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 20:40:33 +08:00
fangxinyong
2b9506bc5d sched/spawn: Fix MISRA C 2012 Rule 10.4 violations
Fix violations of MISRA C:2012 Rule 10.4 (essential type operand of
unsigned and signed) in posix_spawn attribute handling code.

Changed all POSIX_SPAWN_* flag macro definitions to use unsigned literals
(1u instead of 1) to ensure consistent unsigned arithmetic when performing
bitwise operations. This eliminates mixed signed/unsigned operand violations
in the following flags:

- POSIX_SPAWN_RESETIDS
- POSIX_SPAWN_SETPGROUP
- POSIX_SPAWN_SETSCHEDPARAM
- POSIX_SPAWN_SETSCHEDULER
- POSIX_SPAWN_SETSIGDEF
- POSIX_SPAWN_SETSIGMASK
- POSIX_SPAWN_SETSID

Updated all flag checking comparisons in spawn_execattrs() to compare
against 0u instead of 0 for consistency.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2026-02-02 20:39:36 +08:00
hujun5
9ae2fce3c1 sched_getparam.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in nxsched_get_param()
into a single exit point and restructures the error handling path to reduce
cyclomatic complexity and comply with MISRA HIS coding standards.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 14:54:58 +08:00
cqb
7b1e9eb8bc arch/x86_64: replaced loop construct with rep movsb
Replaces inefficient loop construct with rep movsb string instruction.

Signed-off-by: cqb <cqb@sideways.engineering>
2026-02-02 13:58:10 +08:00
shichunma
3fb776e45c net/netdev: a valid netdev for ipv4 should have ipv4 addr configured
It's not a valid netdev if without ipv4 address.

Signed-off-by: Jerry Ma <shichunma@bestechnic.com>
2026-02-02 13:57:56 +08:00
ouyangxiangzhen
5b978a7f9b sched/hrtimer: workaround for SCHED_RR in tickless mode.
This commit provided workaround for incorrect SCHED_RR behavior in
tickless mode.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
b685d97199 sched/hrtimer: Simplify the hrtimer.
This commit simplified the hrtimer.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
dac48484ce sched/hrtimer: Update the comments.
This commit updated the comments.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
3eedf5f22b sched/wdog: Simplify timer expiration for hrtimer.
This commit simplified the timer expiration for hrtimer.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
5bab9fcc7f sched/hrtimer: Add guard timer.
This commit added the guard timer for hrtimer.
The guard timer uses a small memory footprint, offering two main advantages:
- Reduced branches checking for an empty hrtimer queue, simplifying code implementation and improving the performance.
- Additional health monitoring allows the system to enter a safe state in case of time acquisition errors, and supports custom error handling callback functions.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
78dce81c5a sched/hrtimer: Fix uncancelled hardware timer.
If there are no timers in the hrtimer queue, we should cancel the timers to avoid unnecessary timer interruptions. Since we currently do not have a timer cancellation interface, we can achieve cancellation by setting the timer to its maximum value.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
018e6d50c5 sched/hrtimer: Fix finding the rbtree left-most node.
Determining whether a red-black tree node is the left-mode node using `RB_LEFT(hrtimer, node) == NULL` is functionally incorrect. This is because the left node of any leaf node can also be NULL. For example, in the following rbtree:
 5
/ \
3 7
\
4
the left node of the right-most node 7 would also be NULL.
To avoid extra performance overhead to find the left-most node when the
rb-tree changed, this commit used `g_cached_first` to cache the
left-most node.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
d1c45f7c4e sched/hrtimer: Fix delay in hrtimer_process.
This commit fixed the overflow check and renamed the period to delay, since the callback return value is the next delay not the period.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
33c6b4115c sched/hrtimer: Simplify the hrtimer_process.
This commit simplified the hrtimer_process.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
493e2075a1 sched/hrtimer: Fix functional corrctness issue in re-enqueuing the timer
When a hrtimer is removed and then re-enqueued, if the removed hrtimer is the head node and the re-enqueued node is not the head node, the hardware timer still needs to be reset. This patch fixes this issue and simplifies the enqueuing.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
ada6d14672 sched/hrtimer: Simplify the rbtree.
This commit simplified the rbtree in hrtimer and provided better
branchless compare function.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
54dfa46c09 sched/hrtimer: Rename the hrtimer_is_armed.
This commit renamed the hrtimer_is_armed to hrtimer_is_pending, which is
more accurate in the semamtic, and simplify it.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
ouyangxiangzhen
7b67055150 sched/hrtimer: inline hrtimer_start.
This commit inlined the `hrtimer_start` to allow the compiler to optimize at least 1 branch in
hrtimer_start.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
2026-02-02 13:26:22 +08:00
Bartosz Wawrzynek
fe184f79f3 boards/arm/stm32: Fix CMake build for protected mode on stm32f4discovery
- Added support for multiple linker scripts preprocessing in CMake
- Changed kernel/CMakeLists.txt to use target_sources for nuttx_user
- Added KEEP() directive in user-space.ld for .userspace section
- Removed hardcoded -funwind-tables to fix binary size bloat
- Updated memory regions: ksram/usram 4KB→16KB, xsram 104KB→80KB
- Enabled CONFIG_ARCH_FPU, CONFIG_STM32_CCMEXCLUDE, adjusted heap size

Fixes protected mode CMake build for stm32f4discovery:kostest configuration.

Signed-off-by: Bartosz <bartol2205@gmail.com>
2026-02-02 13:24:34 +08: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
hujun5
2ec1bff4e3 lib_stackchk.c: a duplicate implementation error reported during compilation
Mark __stack_chk_guard and __stack_chk_fail as weak symbols to prevent linker
conflicts when multiple definitions of these stack protection symbols exist
across different compilation units.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 13:22:07 +08:00
hujun5
7801c46a0d sem_rw.c: down_read_trylock coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in down_read_trylock() into
a single exit point and replaces goto with if-else structure to reduce cyclomatic
complexity and comply with MISRA HIS coding standards.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 13:21:24 +08:00
hujun5
437cdfac8d sem_rw.c: coverity: HIS_metric_violation(HIS_GOTO)
This change replaces goto-based control flow with structured if-else blocks
in the down_read() function to comply with MISRA HIS coding standards while
maintaining identical functional behavior.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 13:21:24 +08:00
hujun5
3200185665 sem_rw.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in init_rwsem() into a
single exit point by inverting error conditions and restructuring nested
if-else blocks for MISRA HIS compliance.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 13:21:24 +08:00
wangmingrong1
95ef6753ad arm64/irq.h: Fix the issue of including incorrect order
<nuttx/irq.h> will use the macros defined in <arch/chip/irq.h>, so the include order should be after it

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-02-02 11:13:21 +08:00
wangmingrong1
4429e3d3ea arch/arm64: Delete the default save for SCTLR
Currently, the SCTLR register is only used to switch the thread MTE state and has no other uses. Because saving this register is special, it will take a long time after testing, so the default saving behavior is deleted.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-02-02 11:13:21 +08:00
hujun5
5db4278173 protect: move us_heap to userspace_data_s
Refactor heap pointer storage by moving us_heap field from userspace_s
to the nested userspace_data_s structure, enabling future extensibility
of user-space data without modifying the core userspace_s interface across
all board-specific implementations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 11:06:53 +08:00
hujun5
03d9d78adf sched_critmonitor.c: coverity HIS_metric_violation: RETURN
Reduce multiple return statements and simplify control flow by inverting the
condition check and moving all critical monitoring operations into a single
conditional block. This improves code maintainability and addresses the
Coverity HIS_metric_violation (RETURN) defect.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-02 11:06:05 +08:00
Adwait Godbole
5c43ef4eaf arch: xtensa: fix INT32_C macro to match int32_t type
INT32_C(x) is currently defined as x ## ll on Xtensa, which
produces a long long int constant. However, int32_t is
defined as long int on this architecture.

This mismatch can break C++ template overload resolution
and causes build failures in downstream projects such as PX4.

Fix the macro by using x ## l so INT32_C expands to the same
underlying type as int32_t.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
2026-02-02 10:47:55 +08:00
Adwait Godbole
5024a67514 arch: stm32: fix undeclared page variable in flash write
Fix a compilation error in stm32f10xxf30xx_flash.c where the variable
`page` is used without being declared in up_progmem_write().

The issue appears when STM32_FLASH_DUAL_BANK is enabled.

The page is now derived locally from the flash base address and
page size macros, avoiding any dependency on PROGMEM helpers when
selecting the flash bank.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
2026-02-01 23:23:32 +08:00
Jukka Laitinen
fdaeb00910 arch/imx9/enet: Move imx9_phy_boardinitialize to "ifup" phase
Move the board-specific phy initialization from early boot into ifup phase. The
board specific phy initialization may need to implement delays, or bus
communication, for example via i2c bus.

These OS services are not necessarily available yet in arm64_netinitialize, and
PHY initialization is not necessary until the driver actually starts using it.
In addition, this allows the board to reset the ethernet phy at every ifup,
if needed for error recover.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-02-01 09:41:50 -03:00
Jukka Laitinen
15fa005e5b arch/imx9/enet: Correct configuration flag IMX9_ENET1_PHYINIT
The function is for any ethernet interface, given as paramter to the function,
it is not for ENET1 only. The correct name is already used
in the code, but the Kconfig had it wrong.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-02-01 09:41:50 -03:00
liaoao
425a760799 drivers/rpmsg: implement timestamp support for rpmsg_port
Add TX/RX timestamp tracking for rpmsg_port to enable latency
measurement and debugging:

- Add rpmsg_port_get_timestamp() to retrieve buffer timestamps
- Add rpmsg_port_update_timestamp() to record timestamps at TX/RX time
- Integrate timestamp recording in rpmsg_port_spi and rpmsg_port_spi_slave
- Reserve space for rpmsg_timestamp_s in buffer size calculations

Signed-off-by: liaoao <liaoao@xiaomi.com>
2026-02-01 01:14:49 +08:00
liaoao
198a8fe108 drivers/rpmsg: add rpmsg_get_timestamp to retrieve buffer timestamps
Add rpmsg_get_timestamp() API to get the TX/RX timestamps of an rpmsg
buffer. This is useful for latency measurement and debugging purposes.

The new rpmsg_timestamp_s structure contains:
  - tx_nsec: timestamp when the buffer was transmitted
  - rx_nsec: timestamp when the buffer was received

Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-02-01 01:14:49 +08:00
hujun5
0d25df7663 sched: fix code style violations in clock conversion macros (MISRA C-2012)
Add explicit type casts to uint32_t for time conversion macro divisors to
comply with MISRA C-2012 Rules 10.1, 10.3, 11.1, 11.3, and 11.4. This fixes
Coverity warnings and improves type safety in clock_time2ticks_floor and related
time conversion operations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-02-01 01:14:01 +08:00
Bowen Wang
fe5cf5b03e nuttx/clock.h: add USEC2MSEC macro for microsecond to millisecond conversion
Add USEC2MSEC macro to provide a convenient and consistent interface for
converting microseconds to milliseconds, complementing the existing SEC, USEC,
and NSEC conversion macros and improving code readability.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-02-01 01:14:01 +08:00
aviralgarg05
a4315fbb45 arch/arm/src: Fix Ethernet RUNNING status regression in IMXRT and STM32(F7/H7).
Add missing netdev_carrier_on() and netdev_carrier_off() calls to
imxrt_enet.c, stm32f7/stm32_ethernet.c, stm32h7/stm32_ethernet.c,
and stm32/stm32_eth.c. This ensures the interfaces correctly report
IFF_RUNNING status, as required by recent networking stack changes.

Verification:
- imxrt_enet.c pass ./tools/checkpatch.sh.
- stm32f7/stm32_ethernet.c pass ./tools/checkpatch.sh.
- stm32h7/stm32_ethernet.c pass ./tools/checkpatch.sh.
- stm32/stm32_eth.c pass ./tools/checkpatch.sh.
- Manual compilation verification for IMXRT1060 driver.
- Addresses CI failures in arm-13 job (STM32H7).

Signed-off-by: Aviral Garg <gargaviral99@gmail.com>
2026-02-01 01:12:18 +08:00
hujun5
7a5d333454 sched_waitid.c: HIS_metric_violation: CCM
Extract the core waitid logic into a separate waittcb() helper function to reduce the
cyclomatic complexity of the main waitid() function. This improves code maintainability,
reduces nested conditions, and enhances code clarity while preserving all functionality.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 13:11:34 -03:00
hujun5
5fca12c277 sched_waitid.c: HIS_metric_violation(HIS_GOTO)
Replace all goto statements with structured control flow using while loops and
conditional blocks. Consolidate early returns into a single error-handling path
for better code structure and MISRA HIS standards compliance.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 13:11:34 -03:00
Bowen Wang
f1d06cbdcf drivers/virtio: fix the minor code style in virtio.c
Add empty line after `}`

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-31 13:09:30 -03:00
Adwait Godbole
16e2aa0922 docs: Update Signal Interfaces documentation
Update the Signal Interfaces documentation to include all
signals with configurable default actions and group them
by behavior for improved readability.

This reflects the current implementation in
sched/signal/sig_default.c.

Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
2026-01-31 10:07:36 -03:00