Commit graph

57555 commits

Author SHA1 Message Date
Ville Juven
bb85ad849e pthread_cond_wait: Use atomic_t to protect the waiter count
The load/compare and RMW to wait_count need protection. Using atomic
operations should resolve both issues.

NOTE:
The assumption that the user will call pthread_cond_signal /
pthread_cond_broadcast with the mutex given to pthread_cond_wait held is
simply not true. It MAY hold it, but it is not forced. Thus, using the
user space lock for protecting the wait counter as well is not valid!

The pthread_cond_signal() or pthread_cond_broadcast() functions may be called by a thread whether or not it currently owns the mutex that threads calling pthread_cond_wait() or pthread_cond_timedwait() have associated with the condition variable during their waits; however, if predictable scheduling behaviour is required, then that mutex is locked by the thread calling pthread_cond_signal() or pthread_cond_broadcast().

[1] https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cond_signal.html
2025-01-20 23:55:26 +08:00
Ville Juven
1a9241ca1c pthread_barrier_destroy: Fix return value, if sem_getvalue fails
sem_getvalue returns ERROR and sets errno if it fails, we don't want to
return OK in this case, we want to return the non-negated error number.
2025-01-20 23:55:26 +08:00
Ville Juven
516d1c069a pthread_conddestroy: Fix return value, if sem_getvalue fails
sem_getvalue returns ERROR and sets errno if it fails, we don't want to
return OK in this case, we want to return the non-negated error number.
2025-01-20 23:55:26 +08:00
Ville Juven
c3b2910178 drivers/video/fb.c: Replace sem_getvalue with nxsem_getvalue
Because sem_getvalue modifies errno.
2025-01-20 23:55:26 +08:00
Ville Juven
ddd279d700 mpfs_i2c.c: Replace sem_getvalue with nxsem_getvalue
Because sem_getvalue modifies errno.
2025-01-20 23:55:26 +08:00
Xiang Xiao
92e884bee2 libc: Rename LIBC_STRING_OPTIMIZE to LIBC_NEWLIB_OPTSPEED
and correct the dependence

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-20 22:27:19 +08:00
wangzhi16
ecaddbb0aa Use small lock to protect resources related to timers in arch risc-v, xtensa and tricore.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 09:57:01 -03:00
lipengfei28
4b91d76869 warning: #include outside of 'Included Files' section
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
656db16ff1 arch/tricore:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
565b0e6eaf arch/ceva:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
e39cb350f1 arch/x86_64:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
6949c82310 arch/arm:use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
d3e3993682 arch/riscv: use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
82cf59bff5 arch/arm64: use UP_DSB, UP_DMB, UP_ISB as barrier standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
lipengfei28
2d1af01d44 mem barrier: use UP_DMP UP_DSP as barriers standard API
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2025-01-20 20:13:07 +08:00
Neo Xu
afe90db5c4 gdbstub: change send buffer to const char
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2025-01-20 20:07:13 +08:00
wangzhi16
8b5ea40a2b Use small lock to protect resources related to cpufifo.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 20:03:24 +08:00
dongjiuzhu1
e7f38fe6fa drivers/sensor: add new sensot type to align android sensor type
new sensor type:
SENSOR_TEMPERATURE
SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED
SENSOR_TYPE_GYROSCOPE_UNCALIBRATED
SENSOR_TYPE_MAGNETIC_FILED_UNCALIBRATED

refs:
https://cs.android.com/android/_/android/platform/hardware/libhardware/+/
0e67aa0caee9500b61b9c1c8b6e5cab18301364c:include_all/hardware/sensors-base.h

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2025-01-20 19:57:42 +08:00
chao an
0e1214d89a syslog/intbuffer: fix spinlock deadlock
just read the code, still have the deadlock after below change:

| commit 3b6f463ce2
| Author: chenrun1 <chenrun1@xiaomi.com>
| Date:   Tue Dec 31 14:31:46 2024 +0800
|
|     syslog_inbuffer:Fixed the lock reentry issue in single core + spinlock scenario
|
|     Summary:
|       When spinlock.h is enabled in a single-core scenario, spinlock reentry and exceptions may occur when spin_lock_irqsave_wo_note is used in syslog_add_intbuffer
|
|     Signed-off-by: chenrun1 <chenrun1@xiaomi.com>

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-20 17:42:40 +08:00
Huang Qi
685f3ab20c Documentation: Fix typo and list format in Rust guide
Summary:
- Fixed a typo in the Rust guide ("Pleae" -> "Please")
- Improved list formatting for better readability and consistency

Impact:
- Improves documentation quality and readability
- Ensures users have complete and accurate configuration information
- Maintains consistency with the actual requirements for Rust development in NuttX

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-20 17:41:52 +08:00
chenrun1
2375a55517 v9fs:add Documentation
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-20 17:12:14 +08:00
chenrun1
99a1f0dc65 inet_sockif:support multiple iov recv
Summary:
  Implement multiple iovlen recvmsg in inet_sockif, only TCP mode
  support at current.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-20 17:12:14 +08:00
Zhe Weng
87a7714103 net: Split msg_iovlen check in recvmsg into each protocol
To prepare for supporting multiple iov in each protocol.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-20 17:12:14 +08:00
chenrun1
4d17c353dd v9fs:socket driver
Summary:
  1.Add new api for socket parsing header - v9fs_parse_size
  2.Add socket driver for 9pfs

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-20 17:12:14 +08:00
wangzhi16
5f77da4c51 Use small lock to protect timer related resources in arch ARM.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 17:02:30 +08:00
chao an
e1285d73fa Documentation: Replace NSH_LINELEN with LINE_MAX
forget in:
commit 38a0049f56
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Sun Jan 19 11:59:01 2025 +0800

    Documentation: Replace NSH_LINELEN with LINE_MAX

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-20 16:44:55 +08:00
wangzhi16
e177ff9c0c Use small lock to protect usbdev and endpoint in arch ARM.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
2025-01-20 11:47:19 +08:00
Jorge Guzman
4857ea211f stm32h7/linum-stm32h753bi: add touch screen support
Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
2025-01-20 09:20:51 +08:00
wanggang26
1fd21bbd69 coredump: fix crash dump failed when items of pr_regs not equal with regs_num
elf_emit_tcb_note: nitems(status.pr_regs) is 18, g_tcbinfo.regs_num is 17, then g_tcbinfo.reg_off.p[17] has been out of bounds

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2025-01-19 19:43:53 +08:00
Xiang Xiao
38a0049f56 Documentation: Replace NSH_LINELEN with LINE_MAX
forget in:
commit 71a37b4f2d
Author: chao an <anchao.archer@bytedance.com>
Date:   Wed Jan 15 09:56:44 2025 +0800

    Documentation: clean up of CONFIG_NSH_LINELEN define

    Signed-off-by: chao an <anchao.archer@bytedance.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-19 18:38:46 +08:00
hujun5
3193457dd0 sched/timer: remove critical section in setitimer
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-19 17:08:32 +08:00
hujun5
fcfc300f7a group: use tg_mutex to replace tg_joinlock
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-19 17:08:32 +08:00
hujun5
544da3c64c sched/timer: remove critical section in timer_deleteall
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-19 17:08:32 +08:00
hujun5
7c9c9422d0 fix compile error
common/espressif/esp_pcnt.c: In function 'esp_pcnt_isr_default':
common/espressif/esp_pcnt.c:396:41: warning: passing argument 1 of 'spin_lock_irqsave' makes pointer from integer without a cast [-Wint-conversion]
  396 |           flags = spin_lock_irqsave(unit->lock);
      |                                     ~~~~^~~~~~
      |                                         |
      |                                         spinlock_t {aka unsigned char}
In file included from common/espressif/esp_pcnt.c:44:
/home/hujun5/下载/vela_sim/nuttx/include/nuttx/spinlock.h:507:55: note: expected 'volatile spinlock_t *' {aka 'volatile unsigned char *'} but argument is of type 'spinlock_t' {aka 'unsigned char'}
  507 | irqstate_t spin_lock_irqsave(FAR volatile spinlock_t *lock)
      |                                  ~~~~~~~~~~~~~~~~~~~~~^~~~

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-19 17:04:36 +08:00
Ian Douglas Scott
c937899997 rp2040: Set BOARD_XOSC_STARTUPDELAY for Adafruit, Seeed XIAO
This matches how `PICO_XOSC_STARTUP_DELAY_MULTIPLIER` is set in
pico-sdk.

This should fix issues on startup for some units of these boards. It
seems not all are affected. See
https://github.com/raspberrypi/pico-sdk/pull/457 and the issue linked
there for more information.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-18 21:05:07 +08:00
Ian Douglas Scott
806c063223 arm/rp2040,rp2350: Allow configuring XOSC startup delay
This follows the formula in the "Startup Delay" section of the
datasheets, where `BOARD_XOSC_STARTUPDELAY` is the time in milliseconds,
which is then multiplied by the clock fequency in kHz, divided by 256
cycles, and rounded up.

This differs from `pico-sdk`, which just multiplied the value of the
expression it previously used by a `PICO_XOSC_STARTUP_DELAY_MULTIPLIER`.
This seems less correct, though it should be essentially the same except
rounding. (`BOARD_XOSC_STARTUPDELAY_MULTIPLIER` also wouldn't fit nicely
the way the `#define`s are aligned.)

This sets `BOARD_XOSC_STARTUPDELAY` to `1` for all boards, so this will
produce the same output and not change behavior.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-18 21:05:07 +08:00
Ian Douglas Scott
4401036406 arm/rp2040,rp2350: Use BOARD_XOSC_FREQ for calculating startup delay
Previously this used a hard-coded value of 12 MHz, but this presumably
should use `BOARD_XOSC_FREQ`. Similarly to how it is done in pico-sdk.

It looks like all boards are currently defined to use 12 MHz XOSC
clocks, so this won't change behavior with any of them.

Signed-off-by: Ian Douglas Scott <ian@iandouglasscott.com>
2025-01-18 21:05:07 +08:00
chao an
9f5a45340f cmake: Use EXTRAFLAGS to define customized compilation options
align them with the usage habits of makefile

cmake:

cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja -DEXTRAFLAGS="-DCONFIG_AAA=1 -DCONFIG_BBB=1 -Werror"

makefile:

make -j12 EXTRAFLAGS="-DCONFIG_AAA=1 -DCONFIG_BBB=1 -Werror"

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-18 14:12:49 +08:00
Ville Juven
4c2be5bb7f mpfs_opensbi_setup: Provide hartid and next_addr as parameters
No reason to keep asking for these over and over. Also fix bumping
the CPU booted counter when SBI is enabled.

Must also read g_hart_use_sbi before bumping the CPU booted counter.
2025-01-18 10:11:32 +08:00
chao an
36b2b90bc0 cmake/mkconfig: add support of set custom command options to config.h
add support of set custom command options to config.h
Use the -D parameter to pass the config to header file.
NOTE which must begin with the CONFIG_ prefix.
eg:
  cmake -DCONFIG_AAA=1 -DCONFIG_BBB=1 -B build -DBOARD_CONFIG=sim/nsh -GNinja

Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-17 22:00:07 -03:00
Yanfeng Liu
e0ed715076 boards/arm: add qemu-armv7r board
This adds support for qemu-armv7r board with flat mode sample
config for using with QEMU emulated Cortex-R5 processor.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 17:50:33 -03:00
Yanfeng Liu
55e1e11f1e arm/chip/qemu: add chip QEMU_CORTEXR5
This adds support for QEMU Cortex-R5 virtual processor on existing QEMU
Cortex-A7 code base with profile support in `armv7-r/` and `armv7-a/`.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 17:50:33 -03:00
Yanfeng Liu
3f85df583c arch/armv7-r: revise headers to support QEMU armv7-r
This revise armv7-r/ header files needed to support QEMU cortex-r5
virtual process for armv7-r family.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 17:50:33 -03:00
chao an
2779989add sched/wqueue: some minor improve to reduce sched_lock range
Signed-off-by: chao an <anchao.archer@bytedance.com>
2025-01-17 23:33:23 +08:00
simbit18
1bfd1d7303 [CI] testbuild.sh: Msys2 fix toolchain change
In the Msys2 (Windows) environment, this search filter is not sufficient.

$ grep _TOOLCHAIN_ .config | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y
CONFIG_TOOLCHAIN_WINDOWS=y
CONFIG_ARM_TOOLCHAIN_GNU_EABI=y

It is necessary to add
$ grep _TOOLCHAIN_ .config |  grep -v CONFIG_TOOLCHAIN_WINDOWS | grep -v CONFIG_ARCH_TOOLCHAIN_* | grep =y
CONFIG_ARM_TOOLCHAIN_GNU_EABI=y
2025-01-17 23:25:46 +08:00
Yanfeng Liu
1b369544ca modlib/gnu-elf.ld.in: fix regression with armv7a
As armv7-a addrenv layout is not in line with other archs, we need
align it with others by defining ARCH_DATA_RESERVE_SIZE as same as
MM_PGSIZE for now to keep gnu-elf.ld.in unified.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 23:16:26 +08:00
raiden00pl
d4a0abec82 sched/mqueue/CMakeLists.txt: fix compilation for CONFIG_DISABLE_MQUEUE_SYSV=n
fix compilation for CONFIG_DISABLE_MQUEUE_SYSV=n in cmake
2025-01-17 23:14:39 +08:00
Yanfeng Liu
1bfff5a38d arch/armv7-r: fix gic.h build error
This fixes compilation error:

```
/tmp/nuttx/arch/arm/src/armv7-r/gic.h:699:17: error:
'GIC_ICDSGIR_NSATT_GRP1' undeclared; did you mean 'GIC_ICDSGIR_NSATT'?
```

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 19:01:22 +08:00
hujun5
b8660fc39c sim: fix regression from https://github.com/apache/nuttx/pull/14623
reason:
work_timer_expiry may be called in thread context

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2025-01-17 18:59:29 +08:00
Yanfeng Liu
8f435a2941 arch/Kconfig: allow FLASH config for non-MMU chips
This allows using FLASH_START and FLASH_SIZE config for chips with
no MMU.

Signed-off-by: Yanfeng Liu <p-liuyanfeng9@xiaomi.com>
2025-01-17 16:38:17 +08:00