Commit graph

61003 commits

Author SHA1 Message Date
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
wangmingrong1
28026af824 arch/sim: Add sigdelset to nuttx-names.in
sigdelset is used in up_enable_irq: sigdelset(&act.sa_mask, SIGSTOP);

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-01-31 14:14:32 +08:00
Bowen Wang
3237e25d70 drivers/virtio: use virtqueue_nused() to check pending buffers
Replace direct virtqueue internal field access with virtqueue_nused()
API to check for pending buffers in interrupt handlers. This improves
code maintainability and handles cached memory scenarios correctly.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-31 14:14:25 +08:00
hujun5
1900d4c8fb sched_sysinfo.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in the sysinfo() function
into a single exit point and inverts the error condition to improve code structure
and comply with MISRA HIS coding standards for safety-critical systems.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 02:53:58 +08:00
nope
f375093a25 arch/esp32s3/spi: make sure spi don't send wrong bytes when dma is enabled
SPI transmits incorrect bytes when DMA is enabled and `txbuffer` of
`esp32s3_spi_dma_exchange()` is NULL, causing mounted FAT32 SD cards
to fail with -ENODEV during read operations.

Signed-off-by: liu <liu334275@gmail.com>
2026-01-31 02:50:52 +08:00
hujun5
a3da45e1dc libc/tls: update preprocessor condition comment to match implementation
Update the closing preprocessor comment in tls_getinfo.c to accurately reflect
the simplified conditional compilation check. The comment now correctly represents
the actual guard condition used for the tls_get_info function implementation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 02:49:10 +08:00
hujun5
ceb23153c3 sem_rw.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in down_write_trylock()
into a single exit point to reduce cyclomatic complexity and comply with MISRA
HIS coding standards for safety-critical embedded systems.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 02:45:02 +08:00
paolo
c63b0510fb rp23xx/rp23xx-rv: Fix GPIO interrupt handler for RP2350B variant.
The GPIO interrupt handler had hardcoded values that only worked
correctly for RP2350A (30 GPIOs). For RP2350B (48 GPIOs):

- Loop count was hardcoded to 6 registers but should be computed
  based on RP23XX_GPIO_NUM (4 for RP2350A, 6 for RP2350B)
- Reserved bits mask was always applied at register index 3, but
  for RP2350B register 3 contains valid GPIOs 24-31. This caused
  interrupts for GPIOs 30-31 to be incorrectly discarded
- PWM port validation rejected valid ports 8-11 on RP2350B which
  has 12 PWM slices instead of 8

Changes:
- Add RP23XX_GPIO_NREGS macro to compute number of interrupt registers
- Use conditional compilation to only mask reserved bits on RP2350A
  where the last register has 6 valid GPIOs (bits 0-23)
- Fix PWM port validation to allow 12 ports on RP2350B

Signed-off-by: paolo <paolo.volpi@gmail.com>
2026-01-31 02:43:51 +08:00
hujun5
3ec45774fb sched_get_stateinfo.c: misra_c_2012_rule_8_9_violation
Move the static g_statenames array from file scope to block scope within the
nxsched_get_stateinfo() function. This resolves MISRA C 2012 Rule 8.9 violation
which requires static variables to be used at block scope when only one function accesses them.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 02:39:19 +08:00
hujun5
2860333552 sched_setpriority.c: coverity HIS_metric_violation: RETURN
This change consolidates multiple return statements in nxsched_set_priority()
into a single exit point to reduce cyclomatic complexity and comply with MISRA
HIS coding standards for safety-critical embedded systems.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-31 02:38:55 +08:00
wangmingrong1
fee69a2046 driver/virtio: Delete reset on initialization
Resetting during initialization can cause qemu to lock up, for example, virtio-gpu. qemu does not need to reset virtio during initialization.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2026-01-31 02:38:46 +08:00
zhaohaiyang1
f653ffd723 forward: Add IFF_NOSRC_FORWARD and IFF_NODST_FORWARD flags.
* IFF_NOSRC_FORWARD: Controls whether device prohibits forwarding packets inputs
* IFF_NODST_FORWARD: Controls whether device prohibits forwarding packets outputs

This allows users to selectively enable/disable forwarding on specific
devices, improving network flexibility and security.
Signed-off-by: zhaohaiyang1 <zhaohaiyang1@xiaomi.com>
2026-01-31 02:37:58 +08:00
paolovolpi
db50f0445a drivers/ioexapnder/mcp23x17 : Fix write gpio output values on OLAT registers
Gpio output value must be set on OLATA and OLATB registers.

Summary

Why is this change necessary?
This is a bug fix. The MCP23x17 driver was writing GPIO output values to incorrect registers, causing output
pins to not behave as expected.

What functional part of the code is being changed?
The MCP23x17 I/O expander driver (drivers/ioexpander/mcp23x17.c).

How does the change work?
The fix ensures GPIO output values are written to the OLATA and OLATB (Output Latch) registers instead of the
incorrect registers. The OLAT registers are the proper registers for controlling the actual output pin
states on the MCP23x17.

Impact

- User experience: No adaptation required. This fix corrects existing broken behavior.
- Build: No impact.
- Hardware: Affects boards using the MCP23x17 I/O expander.
- Documentation: None required.
- Security: No impact.
- Compatibility: Backward compatible - fixes incorrect behavior.

Testing

Build Host:
- OS: Ubuntu 22.04
- Compiler: arm-none-eabi-gcc

Target:
- Architecture: ARM (RP2350)
- Board: RP2350-based board
- Configuration: Custom config with MCP23x17 enabled over I2C0

Testing performed:
- Connected MCP23x17 to RP2350 via I2C0
- Attached an LED array to all 16 GPIO pins of the MCP23x17
- Configured all 16 GPIO as outputs
- Wrote a simple test application to toggle the LEDs on and off
- Before fix: LEDs did not respond correctly to output commands
- After fix: All 16 LEDs toggle on/off as expected

Signed-off-by: paolo <paolo.volpi@gmail.com>
2026-01-30 17:42:48 +01:00
hujun5
926f5de541 sched_cpuload.c: misra_c_2012_rule_8_9_violation
Move the static g_cpuload_wdog watchdog timer from file scope to block scope
within the cpuload_init() function. This resolves MISRA C 2012 Rule 8.9 violation
which requires static variables used by a single function to be scoped at block level.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-30 12:52:22 -03:00