Commit graph

60439 commits

Author SHA1 Message Date
hujun5
657ac8317e arch: fix addrenv_switch changing this_task causing exceptions
After addrenv_switch(), the current running task (this_task) may change due to
deferred work execution. Update all architecture interrupt, syscall, and exit
handlers to re-fetch tcb = this_task() after addrenv_switch(). Ensures scheduler
and context operations use the correct TCB, preventing context corruption and
exceptions across SMP and memory-protected builds.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-17 18:23:06 -03:00
ligd
113bb02568 checkstack: fix access overflow when checkstack
We should check length first, and then check the value

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-17 18:04:28 -03:00
ligd
3c6cb0b76e sched: add dump_stack() for dumponexit
Add stack dump functionality when tasks exit, which helps with
debugging and understanding task termination conditions.


Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-17 18:04:28 -03:00
Filipe Cavalcanti
0bd1dc58a8 sched/sched_roundrobin.c: fix round-robin scheduling in SMP mode
In SMP mode, running tasks are in g_assignedtasks[cpu], not the
ready-to-run list, so tcb->flink is NULL. When a round-robin timeslice
expires, checking tcb->flink fails to find the next task.

Fix by calling nxsched_switch_running() directly in SMP mode when the
timeslice expires, which properly finds the next eligible task from the
ready-to-run list.

Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
2026-01-17 18:03:45 -03:00
hujun5
ae47d6a101 sched/task: fix null pointer dereference in fork address environment setup
Move addrenv_join() call after group_initialize() in nxtask_setup_fork() to fix
null pointer dereference. addrenv_join() accesses child->group which is
initialized by group_initialize(), so the operations must be sequenced
correctly. Reorder initialization to ensure child task group is set up before
address environment join operations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-17 17:35:36 -03:00
xucheng5
724ad008ab ctucanfd: increase rwcnt bitfield width and fix structure alignment
The rwcnt (read word count) field in ctucanfd_frame_fmt_s was previously
limited to 4 bits, allowing a maximum value of 15. This is insufficient
to correctly represent the frame size (excluding the FRAME_FORMAT word)
for larger CAN FD frames as required by the CTU CAN FD hardware.

Increase the rwcnt bitfield width to support a larger range and adjust
the structure layout so that ctucanfd_frame_fmt_s has a size that is a
multiple of 4 bytes, as required by the hardware interface.

This change improves correctness and robustness when handling larger
CAN FD frames without affecting existing users.

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2026-01-17 12:43:48 +01:00
xucheng5
2f3eb6d677 caros_x86_64: add support for generating linker map
This patch introduces support for generating a linker map file during
the build process for the x86_64 configuration.

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2026-01-17 14:14:13 +08:00
hujun5
13d1092939 arm64: add missing REG_SCTLR_EL1 initialization in signal processing
Add REG_SCTLR_EL1 system register initialization in arm64_init_signal_process
when setting up register context for signal handlers. Initialize with current
sctlr_el1 value and apply CONFIG_ARM64_MTE settings if enabled. Fixes regression
where signal handler context was missing critical system control register setup.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-17 14:13:55 +08:00
hujun5
acc833b07d libs/libc: replace critical section with spinlock in hostname operations
Replace global enter_critical_section() with lightweight spinlock in
gethostname() and sethostname() to reduce interrupt latency while protecting
access to the shared hostname string.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-17 14:13:07 +08:00
hujun5
4a160e7778 sched/environ: rm cestion_in evn
Replace global critical section with mutex in environment
variable operations. Use nxrmutex_lock/unlock(&group->tg_mutex)
instead of enter/leave_critical_section() to protect
environment access, reducing interrupt latency and
improving SMP responsiveness. Clean up unused
irqstate_t flags variables in env_dup,
env_getenv, env_setenv, and env_unsetenv.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-17 14:12:42 +08:00
Ari Kimari
fb7e5c5618 arch/imx9: Modify default ddr config handling
Remove default ddr config
Add imx9_ddr_config() function  to return default config

Signed-off-by: Ari Kimari <ari.kimari@tii.ae>
2026-01-17 11:41:57 +08:00
makejian
213c1b4957 docs: enhance crypto documentation with key management and asymmetric crypto
Add detailed descriptions of key management operations including:
- Key allocation and validation (CRK_ALLOCATE_KEY, CRK_VALIDATE_KEYID)
- Key import and export (CRK_IMPORT_KEY, CRK_EXPORT_KEY, CRK_EXPORT_PUBLIC_KEY)
- Key generation (CRK_GENERATE_AES_KEY, CRK_GENERATE_RSA_KEY, CRK_GENERATE_SECP256R1_KEY)
- Key lifecycle management (CRK_DELETE_KEY, CRK_SAVE_KEY, CRK_LOAD_KEY)
- Usage of keys in cryptographic operations

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-17 11:41:23 +08:00
makejian
b11901ffaf crypto: add key management and RSA/ECDSA keypair generation
Add key management interfaces and support for generating key pairs in RSA and ECDSA cryptographic processes to the cryptodev module.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-17 11:41:23 +08:00
hujun5
f4cbc1455f arm: use global variables for CPU startup addresses
Replace direct labels for CPU startup routines with indirection through global
variables. Export cpu1_start, cpu2_start, cpu3_start as global objects containing
addresses to __cpu1_start, __cpu2_start, __cpu3_start respectively. Use load-then-
branch-exchange (ldr r1, =cpu*_start; ldr r1, [r1]; bxeq r1) instead of direct beq
jumps. Enables flexible control of CPU startup positions and supports future AMP/
dynamic loading scenarios.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 14:05:24 -03:00
hujun5
c1884b8a4f arm: add CONFIG_NCPUS for AMP mode support
Add new CONFIG_NCPUS configuration option to support both SMP and AMP modes.
Replace SMP-specific CONFIG_SMP_NCPUS checks with generic CONFIG_NCPUS in ARM
boot code (ARMv7-A, ARMv7-R, ARMv8-R). CONFIG_NCPUS defaults to SMP_NCPUS when
SMP is enabled, or 1 otherwise, enabling multi-CPU support regardless of SMP mode.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 14:05:24 -03:00
hujun5
6f87c092a1 arm: support AMP mode with GIC SGI inter-core interrupts
Enable SGI (Software Generated Interrupts) usage in AMP mode for inter-core
communication. Modify arm_cpu_sgi() to use SGI_TGTFILTER_LIST for both SMP and
AMP modes instead of requiring CONFIG_SMP. Add CPU0-only guard checks using
sched_getcpu() to ensure arm_gic0_initialize() executes only once on CPU0 during
initialization in both SMP and AMP configurations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 14:05:24 -03:00
Jiri Vlasak
f49e61bf76 kinetis/enet: Set carrier on/off on ifup/ifdown
We need IFF_IS_RUNNING(dev->d_flags) to be true for ethernet device to
work properly. However, dev->d_flags are not set anywhere in the
Kinetis' ethernet code.

This change updates kinetis_ifup and kinetis_ifdown procedures to call
netdev_carrier_on and netdev_carrier_off to set dev->d_flags.

Signed-off-by: Jiri Vlasak <jvlasak@elektroline.cz>
2026-01-16 13:55:13 -03:00
Peter van der Perk
8c77fccaef imx95-m7: Fix Kconfig for flexcan typo
Fixes typo in flexcan2, which renders it unusable

Signed-off-by: Peter van der Perk <peter.vanderperk@nxp.com>
2026-01-16 13:49:25 -03:00
ligd
c000974700 arm64: fix compile failed
CC:  mm_heap/mm_mallinfo.c chip/bcm2711_serial.c: In function 'bcm2711_miniuart_attach':
chip/bcm2711_serial.c:571:3: error: implicit declaration of function 'up_prioritize_irq' [-Werror=implicit-function-declaration]
  571 |   up_prioritize_irq(BCM_IRQ_VC_AUX, 0);
      |   ^~~~~~~~~~~~~~~~~
CC:  mm_heap/mm_memalign.c chip/bcm2711_gpio.c: In function 'bcm2711_gpio_irqs_init':
chip/bcm2711_gpio.c:275:7: error: implicit declaration of function 'up_prioritize_irq' [-Werror=implicit-function-declaration]
  275 |       up_prioritize_irq(g_gpio_irqs[i], 0);
      |       ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: ligd <liguiding1@xiaomi.com>
2026-01-16 10:26:58 -05:00
guoshichao
5a9f6efddb ghs: update the compile option to recommended options
add new build option config that recommended from other mass-produced
products

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:57:00 +08:00
hujun5
79b6d27018 arm64: fix SP_EL0 register handling in syscall return path
Use regs[REG_SP_EL0] from register context instead of direct sp_el0 system
register read/write operations in arm64_syscall(). Replace read_sysreg(sp_el0)
with regs[REG_SP_EL0] and write_sysreg(usp, sp_el0) with direct assignment to
regs[REG_SP_EL0]. Ensures userspace stack pointer is correctly maintained from
register context during signal delivery, preventing userspace SP corruption on
syscall return.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 21:34:41 +08:00
guoshichao
3d45550da9 can_sendmsg_buffered: fix can_sendmsg param type mismatch error
Update the can_sendmsg() signature from "struct msghdr *msg" to
"const struct msghdr *msg" to match the updated sendmsg() prototype
and resolve compilation errors due to parameter type inconsistency.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:11:39 +08:00
guoshichao
57637e5927 net: make the sendmsg param type consistent with posix specification
To ensure consistency, in all places where the "sendmsg" function is used
either directly or indirectly, the type of the "struct msghdr *msg" parameter
needs to be modified to "const struct msghdr *msg".

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:11:39 +08:00
guoshichao
9de3b79e2c nucleo-h743zi/elf: modify the romfs img file path
Since the directory structure of the examples/elf project
has been reorganized, the corresponding ROMFS_IMAGEFILE path
also needs to be adjusted.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 21:07:33 +08:00
jingfei
9483df3571 driver/cfi-flash: Add a config option for the page size of CFI flash.
We have added a defconfig configuration to set the page size of the flash.
According to the CFI protocol, the flash supports a single write operation
with a data volume ranging from byte size up to the maximum number of bytes.
However, the MTD device structure requires defining a page size, which serves
as the minimum write unit of the flash. Hence, this configuration is introduced.
Any page size within the range of 1 to the maximum number of bytes is considered
valid.

Signed-off-by: jingfei <jingfei@xiaomi.com>
2026-01-16 20:38:26 +08:00
hujun5
ad3abcd277 arm64: g_mpu_region need support SMP
Convert g_mpu_region from single-CPU global variable to per-CPU array indexed
by this_cpu(). Change declaration from "unsigned int g_mpu_region" to
"unsigned int g_mpu_region[CONFIG_SMP_NCPUS]". Update all accesses in
mpu_allocregion(), mpu_freeregion(), and mpu_modify_region() to use
g_mpu_region[this_cpu()] for proper per-CPU MPU region tracking in multi-core
configurations.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 20:37:25 +08:00
hujun5
ffb4c101d8 arm64: fix FIQ mask initialization in task state
Add FIQ bit (DAIF_FIQ_BIT) initialization to SPSR register when creating new
ARM64 tasks. By default, FIQ interrupts are masked unless CONFIG_ARM64_DECODEFIQ
is enabled. Ensures consistent FIQ masking behavior across all task contexts.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 20:37:17 +08:00
lipengfei28
d369c92b17 drivers/pci: fix BAR size probing mask
Write 0xffffffff to the BAR when probing resource size, so the
returned mask is computed correctly.

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:36:45 +08:00
zhaoxingyu1
c4cf7ead30 bugfix: reading expired content need in expired range
By obtaining the erase value to set the nvs special ID
instead of using a fixed value

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-16 20:35:34 +08:00
zhaoxingyu1
61f4bd522c mtd/nvs: rename MTD_BLOCKSIZE_MULTIPLE
rename MTD_BLOCKSIZE_MULTIPLE to
CONFIG_MTD_CONFIG_BLOCKSIZE_MULTIPLE

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-16 20:35:34 +08:00
Xiang Xiao
23e1066322 mtd/mtd_config_fs: Add NVS_ prefix to ADDR_XXX
and rename ret to rc for keeping the consistency with other macros

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-01-16 20:35:34 +08:00
zhaoxingyu1
3fa0844da9 mtd/nvs: remove macro NVS_SPECIAL_ATE_ID
By obtaining the erase value to set the nvs
special ID instead of using a fixed value

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-16 20:35:34 +08:00
zhaoxingyu1
525a27b859 mtd/nvs: compatible with bread/bwrite
add MTD_BREAD/MTD_BWRITE in nvs when
CONFIG_MTD_BYTE_WRITE is n

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-16 20:35:34 +08:00
zhaoxingyu1
2274f1aeb3 mtd/nvs: remove CONFIG_MTD_WRITE_ALIGN_SIZE kconfig
remove CONFIG_MTD_WRITE_ALIGN_SIZE kconfig instead of
using geo.blocksize directly

Signed-off-by: zhaoxingyu1 <zhaoxingyu1@xiaomi.com>
2026-01-16 20:35:34 +08:00
hujun5
f909c9205e notifier: remove critical section
The notifier doesn't need to hold the critical section for the entire
operation, allowing for better performance and reduced lock contention
on multi-core systems.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 20:34:13 +08:00
guoshichao
eda1969888 ghs.cmake: add preprocess command to the .ld script generate procedure
Modify nuttx_generate_preprocess_target() to inject
$<TARGET_PROPERTY:nuttx_global,NUTTX_CPP_COMPILE_OPTIONS> into the
preprocessing command, ensuring that linker script preprocessing uses
the same C preprocessor flags as the rest of the build (e.g., -D defines,
include paths).

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 20:32:05 +08:00
makejian
a55119ccfe crypto/cryptodev: fix memory leak when failed to open /dev/crypto
Free the allocated fcrypt structure when opening /dev/crypto device fails, preventing memory leak.

Signed-off-by: makejian <makejian@xiaomi.com>
2026-01-16 20:31:43 +08:00
wangzhi16
ce982fac4c arch/arm64: fix compile error.
14:35:29  chip/a64_twi.c:1846:3: error: implicit declaration of function 'up_prioritize_irq' [-Werror=implicit-function-declaration]
14:35:29   1846 |   up_prioritize_irq(priv->config->irq, 0);
14:35:29        |   ^~~~~~~~~~~~~~~~~

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:26:14 +08:00
lipengfei28
efedf48cde arch/arm64: use up_prioritize_irq and up_set_type_irq instead
arm64_gic_irq_set_priority

use use up_prioritize_irq and up_set_type_irq as std api

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:26:14 +08:00
lipengfei28
e70c31162a arch/arm: add api to config irq type
arm add api to config irq type

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:26:14 +08:00
lipengfei28
ddb797b0ab arch/arm64: add api to config irq type
arm64 add api to config irq type

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:26:14 +08:00
lipengfei28
54e6c0c1d9 irq: add api to config irq type
add api to config irq type

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2026-01-16 20:26:14 +08:00
hujun5
5e03a56c8f drivers/misc/optee: add missing addrenv header include
Fix compilation error in optee_va_to_pa() caused by undefined 'struct addrenv_s'
type when CONFIG_ARCH_ADDRENV is enabled. Add the missing nuttx/addrenv.h header
to provide the required type definition.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 09:04:12 -03:00
Alexey Matveev
1a00d1b5c7 boards/stm32f103-minimum: Add GPIO in/out/int define
Added conditional compilation guards (#if/#endif) around GPIO function prototypes, operation structures, and interrupt handler to ensure proper compilation when GPIO input, output, or interrupt features are disabled.

Signed-off-by: Alexey Matveev <tippet@yandex.ru>
2026-01-16 08:57:09 -03:00
hujun5
2a08860a08 arch/arm64: fix backtrace register access and gdbstub config guard
Fix arm64_backtrace to access TCB register context directly instead of using
running_regs(), which may not reflect the actual context being backtraced.
Add CONFIG_ARCH_HAVE_DEBUG guard to prevent undefined references in non-debug builds.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 08:55:47 -03:00
hujun5
f3f9b7ecae libs/libc/gdbstub: fix smpcall called in irq context
Replace synchronous nxsched_smp_call with asynchronous nxsched_smp_call_async
in gdb debugpoint operations to prevent deadlocks when called from IRQ handlers.
Use static smp_call_data_s for async communication between SMP cores safely.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 08:55:47 -03:00
hujun5
ac8a61d70b arm64: add the interrupt status in the syscall
Set interrupt status flag in tpidr_el1 register (bit 0 set to 1) when entering
syscall handler to indicate IRQ-in-progress state, and clear it when exiting
to properly track kernel execution context across all code paths.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-16 08:55:07 -03:00
guoshichao
54ff28a47f sys/types.h: Fixed the conflict issue with the "OK" constant definition
When cross-compiling PSE52 VSX testcases based on Vela, VSX defines its
own "OK" constant as a macro, which conflicts with the "OK" constant
defined as an enum in <sys/types.h>. To ensure compatibility, we
have undef'd the macro version of "OK" in advance.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 16:16:21 +08:00
guoshichao
b945c7b505 limits: add _POSIX_PTHREAD_ constant for pthread management
Add three POSIX‑required pthread‑related constants to limits.h:
- _POSIX_THREAD_DESTRUCTOR_ITERATIONS
- _POSIX_THREAD_KEYS_MAX
- _POSIX_THREAD_THREADS_MAX

These constants are needed for full POSIX pthread compatibility and are
required by certain PSE52 test suites and applications.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 16:15:35 +08:00
guoshichao
ab572fe1cf lib_ulimit: fix the variable uninit coverity issue
Initialize the rlim_max field in the rlp structure when handling
UL_SETFSIZE command in ulimit(), resolving an uninitialized variable
warning from Coverity static analysis.

Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2026-01-16 10:03:53 +08:00