Commit graph

1412 commits

Author SHA1 Message Date
fangzhenwei
e4ed6156ca arch/sim: fix incomplete HCI socket data reading in simulator interrupt handler
The sim_bthcisock_interrupt() handler for Bluetooth HCI sockets in the simulatorwas using
an if statement to check for available data on the HCI socket. Thismeant that only a single
packet would be read and processed per interrupt trigger,even if multiple packets were waiting
in the socket buffer.

This led to incomplete data processing: unread packets would remain in the bufferuntil the next
interrupt tick, causing delayed handling of Bluetooth HCI events/commands,packet backlogs,
or missed data in high-throughput scenarios.

This fix replaces the if with a while loop to:

1. Continuously check for and read available data from the HCI socket until no more
   packets are present in the buffer.
2. Ensure all pending HCI packets are processed in a single interrupt handler invocation.
3. Eliminate packet backlogs and reduce latency in Bluetooth HCI communication.

The change maintains the same core data reception logic (bthcisock_receive()) butensures it runs
for all available packets, improving the reliability and responsivenessof the simulator's Bluetooth HCI socket implementation.

Signed-off-by: chao an <anchao.archer@bytedance.com>
2026-02-26 08:15:28 -03:00
SPRESENSE
72b67832ea Makefile: Remove make depend files by make distclean
Intermediate files of make depend like .ddc and .dds may remain
when make is interrupted. Remove them using make distclean.

Signed-off-by: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com>
2026-02-16 16:27:57 +01:00
yaojingwei
c5549143ad sim_camera: support enum pixel format.
Expose enum pixel format support in sim_camera.

Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
2026-02-09 20:56:46 -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
ganjing
206aaa8612 arch/sim: improve heap management on Simulator
and proper accounting of heap metadata

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
ganjing
e941b18e29 mm/umm: Allow customizing the implementation of umm heap
and migrate arch/sim from the customized mm_heap to
umm_heap, so the default mm_heap implementation can
still be used(e.g. shared memory in OpenAMP).

Signed-off-by: ganjing <ganjing@xiaomi.com>
2026-01-27 21:27:53 +08:00
xuxin19
80505da579 cmake(bugfix):remove unused libmad link in SIM build
libmad has been ported into apps
and does not require linking to the host.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-27 20:54:26 +08:00
hujun5
a3273e6a96 arch: Add stack alignment and stack size checking when CONFIG_TLS_ALIGNED=y
Add validation to ensure allocated stack size does not exceed TLS_MAXSTACK when
CONFIG_TLS_ALIGNED is enabled, and verify proper stack alignment using STACK_ALIGN_MASK
across all architectures. This improves stack safety and prevents potential TLS overflow conditions.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 22:18:11 +08:00
hujun5
6f03601169 arch: rename STACK_ALIGNMENT to STACKFRAME_ALIGN across all architectures
Rename STACK_ALIGNMENT macro to STACKFRAME_ALIGN throughout the codebase
to provide clearer naming semantics. The new name better reflects the macro's
purpose of frame alignment rather than general stack alignment.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-22 15:37:24 +08:00
hujun5
e604bacd42 sim: it is not necessary to call restore_critical_section in irq
Remove restore_critical_section() call from up_switch_context() in simulator
as it is not necessary during interrupt context switching. The critical
section state is properly managed elsewhere in the interrupt handling flow.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-20 12:22:18 -03:00
hujun5
63e59e26c0 arch: move some macros to public code.
Move stack alignment and kernel stack macros from architecture-specific internal
headers to public include/nuttx/irq.h. Consolidates duplicate definitions across
17 architecture families, reducing code duplication while enabling common code
to access these core alignment utilities without architecture dependencies.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-20 01:53:08 +08:00
zhangshuai39
1c2d1c579f simwifi: Fix compilation warning
Added the `<nuttx/kmalloc.h>` header file and fixed the implicit conversion issue.

Signed-off-by: zhangshuai39 <zhangshuai39@xiaomi.com>
2026-01-19 12:14:18 -03:00
xuxin19
a7c6f589f9 cmake(bugfix):fix sim loadable elf build support
1.add sanity check for START_OBJS
2.make laodable -e entry setting in each arch elf.cmake
3.add sim elf.cmake

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
2026-01-19 14:45:37 +08:00
hujun5
8bb250a4c0 arch: move STACK_ALIGNMENT to irq.h
Move STACK_ALIGNMENT macro definitions from architecture-specific internal
headers to public irq.h headers. This enables common code to directly access
STACK_ALIGNMENT without requiring internal header inclusion, improving code
organization and reducing header dependencies. Applies to all architectures:
ARM, ARM64, AVR, HC, MIPS, or1k, Renesas, RISC-V, SIM, SPARC, TriCore, x86,
x86_64, Xtensa, Z16, and Z80.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2026-01-19 14:43:43 +08:00
Bowen Wang
e686a3ac42 mm/mm_heap: use struct mm_heap_config_s to init the memory heap
To avoid add new parameters to the mm_initialize_heap() and
mm_initialize_pool()

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
anjiahao
6ed4ea63d8 mm: support mm_initialize_heap to specify a specific heap pointer
Support user pass it own heap struct to the mm_initialize_heap() to
avoid the heap struct is reserved from the heap range

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang
0bc9f94304 sim/sim_rptun: modify sim_rptun to port new rptun framework
1. Use reserved[0] filed in struct fw_rsc_vdev and the driver
master/slave to judge the device role;
2. Use struct fw_rsc_carveout in resource table to provide the
share memory to virtio driver side;

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang
47b6c1f2a9 sim/sim_rptun: use host_kill() to kill proxy core when stop proxy
To avoid hang in the host_waitpid() in sim_rptun_stop()

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Bowen Wang
906299df21 sim/posix: add host_kill API to kill other thread
sim rptun need use this api to kill the proxy core

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2026-01-19 14:18:27 +08:00
Yongrong Wang
911ab7c55b drivers/rptun and rpmsg_virtio: remove cmd initialize
don't need initialize in sim

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2026-01-19 14:18:27 +08:00
wangchengdong
2a0990bd31 arch/sim: Add support to disable signals actions related data struct
Add support to disable signals actions related struct

Co-authored-by: guoshichao <guoshichao@xiaomi.com>
Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
2026-01-18 08:24:13 -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
guanyi3
f99dd20c4e sim/usrsock: move g_work_queue init before net_initialize
usrsock register work in net_initialize before g_work_queue is created, so move g_work_queue in irq_initialize.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-01-16 09:39:02 +08:00
guanyi3
7dde767155 sim: add global work queue to replace HPWORK
rpmsg work in hpwork are waiting for remote buffer, remote get buffer and callback, but callback also in hpwork, deadlock occurs here.
now we move periodic work to global work queue instead of hpwork to fix deadlock.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-01-16 09:39:02 +08:00
guanyi3
27c9d388d9 sim: replace wdog to work queue to avoid deadlock
The wdog callbacks are executed in the host's signal handler context, which has strict limitations on what operations can be safely performed. Specifically, signal handlers should not call non-async-signal-safe functions (e.g., sim_alsa use mutex_lock in wdog and cause deadlock).

This change only replaces uses of wdog for periodic tasks. Other interrupt callbacks that are still invoked from the host signal handler are not replace to work queue.

Signed-off-by: guanyi3 <guanyi3@xiaomi.com>
2026-01-16 09:39:02 +08:00
daichuan
1817484bcd arch/sim: support SOCK_RAW in host_usrsock_socket
Convert NUTTX_SOCK_RAW to native SOCK_RAW in the simulator usrsock implementation.

Signed-off-by: daichuan <daichuan@xiaomi.com>
2026-01-16 09:38:46 +08:00
liqinhui
0e4d291156 sim: Pass through unknown sockopt to system.
Remove the interception of unknown levels and option names in sim usrsock.
This allows the system socket interface to handle them and return the correct error codes or behavior, rather than returning a generic error locally.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-15 13:29:56 -08:00
cuiziwei
e9bbf2928b libcxx: porting libcxx test.
porting libcxx test case to nuttx.

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-01-15 13:40:42 -03:00
liqinhui
1d8eab937f simwifi: refactor the interfaces of simwifi and simnet
Fix CMake logic to correctly include sim_wifihost.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:54 +08:00
liqinhui
3843f7b4fe wifi: Support the wifi operations based on the bss file.
Add support for BSS file-based WiFi simulation.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:54 +08:00
liqinhui
dce89e1820 simwifi: Refactor the interfaces of simwifi and simnet
Refactor simwifi to separate host and sim logic.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2026-01-14 09:22:54 +08:00
buxiasen
1058397807 arch/sim: save errno when do context switch
Avoid the errno changed after interrupt in sim and make return value
mistake when according to errno.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-13 10:29:24 +08:00
buxiasen
100c9dd20b arch/sim: add host_errno_get/set for sim to backup/restore in "irq"
Avoid the errno changed after interrupt in sim and make return value
mistake when according to errno.
Move host_errno_convert from macro to sim_errno.c.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-13 10:29:24 +08:00
buxiasen
cd2bf49474 arch/sim/rawgadget: remove the host_uninterruptible_errno
We will remove the API in next commit, so remove the errno manual save
API and save errno more commonly.
After whole pull request, should no longer need to care about errno.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-13 10:29:24 +08:00
buxiasen
8d2ef7f43c Revert "arch/sim: avoid host-call being interrupted before getting errno"
This reverts commit ac5b38c9e5.

Keep host_errno_convert as a common interface in sim_internal.h
Keep the up_irq_save & up_irq_restore as common interface

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2026-01-13 10:29:24 +08:00
zhanghongyu
fa6c8579dd driver/net: replace net_lock with netdev_lock
modify the code of the adapted protocol stack to avoid deadlocks and the
logic that cannot be protected by locks after modification.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2026-01-06 16:08:30 +08:00
yezhonghui
227d7237ab gpiochip: export ioexpander pointer to user
sim gpiochip ioexpander export to user

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2026-01-05 15:10:41 -03:00
yezhonghui
36f91643ae sim/gpiochip: add sim gpiochip for gpio autotest
add sim gpiochip driver

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2026-01-05 15:10:41 -03:00
yangsong8
59f200ac4f arch/sim: Explicitly compare whether transfer is NULL in usbhost
if (!transfer)  ==>  if (transfer == NULL)

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
v-tangmeng
2c24420a1c arch/sim: fix the compile error
USB_EP_MAXP_MASK ==> USB_EP_MAX_PACKET_MASK

Signed-off-by: v-tangmeng <v-tangmeng@xiaomi.com>
2026-01-05 09:59:06 +08:00
yangsong8
bc2daa48cc arch/sim: Optimize sim usbhost isoc endpoint transmission
The USB driver framework only implements a single ISOC transfer.
If multiple transfers are needed, the class driver can initiate
multiple urbs to meet the real-time requirements of the ISOC
 endpoint. The class driver's urb record the buf address, length,
and number of packets sent. The callback function calculates the
data location in the buf based on the callback number and length
returned.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
yangsong8
199290c0ee sim/usbhost: modify ctrlin return value
On success, zero (OK) is returned. On a failure, a negated errno value
is returned indicating the nature of the failure.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
yangsong8
96707bd967 sim/usbhost: fix usbhost async sending data exception
If the callback function is empty during asynchronous sending,
an exception will occur.

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
yangsong8
9934dcef76 arch/sim: add usb host async function
add sim usb host async function

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
yangsong8
216ceb9242 arch/sim: add usb host iso ep trans function
add sim usb host iso ep trans function

Signed-off-by: yangsong8 <yangsong8@xiaomi.com>
2026-01-05 09:59:06 +08:00
zhanghongyu
ac3a7da8ed sim_netdriver: add addmac/rmmac support
Avoid PACKET_ADD_MEMBERSHIP calls returning errors.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2025-12-25 10:01:43 +08:00
yezhonghui
ba681d3ddf sim_uart: used wd timer to process transmit
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
276095dc77 sim_rptun: used wd timer to process transmit
used wdt thread process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
aeda575c5b sim_hcisock: used wd timer to process transmit
used wdt thread to process event

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00
yezhonghui
93bf613505 sim/loop: delete sim loop theads at bringup
wdt thread replace sim loop thread

Signed-off-by: yezhonghui <yezhonghui@xiaomi.com>
2025-12-24 22:50:24 +08:00