Commit Graph

54911 Commits

Author SHA1 Message Date
fangzhenwei
cc9d42804b local_sock: fix accept use-after-free
we should get next waiter before acceptor released

Signed-off-by: fangzhenwei <fangzhenwei@xiaomi.com>
2024-10-09 23:00:32 +08:00
raiden00pl
a8ffa96b65 arch/arm/Kconfig: fix copy-paste error
ARCH_CHIP_CSK6 has nothing to do with ST chips:
fix option string and move below ST related options
2024-10-09 23:00:06 +08:00
Lup Yuen Lee
7edb84c0c5 build.yml: Check out the correct branch of nuttx-apps
When building a branch like `releases/12.7`, the CI Workflow incorrectly checks out the `master` branch of `nuttx-apps`, instead of `releases/12.7`. This PR fixes a typo in `apps_ref`, to check out the correct branch.
2024-10-09 19:30:38 +08:00
hujun5
5f6eb292a8 sched: add nxsched_remove_self
reason:
1In the scenario of active waiting, context switching is inevitable, and we can eliminate redundant judgments.

code size
before
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ size nuttx
   text    data     bss     dec     hex filename
 262848   49985   63893  376726   5bf96 nuttx

after
hujun5@hujun5-OptiPlex-7070:~/downloads1/vela_sim/nuttx$ size nuttx
   text    data     bss     dec     hex filename
 263324   49985   63893  377202   5c172 nuttx

reduce code size by  -476

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:19:13 +08:00
chao an
9dbde04327 Revert "toolchain/ghs: Fix CONFIG_SCHED_CRITMONITOR_MAXTIME_XXX "zero used for undefined preprocessing identifier" warnings"
move private define to public

This reverts commit 236678d730.

Signed-off-by: chao an <anchao@lixiang.com>
2024-10-09 18:16:56 +08:00
hujun5
8cd52bee2e arm64: g_current_regs is only used to determine if we are in irq, with other functionalities removed.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
d573952790 irq: use up_interrupt_context to replace up_current_regs
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
4ecb6efee8 arm: tc32 nested interrupts are not supported
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
hujun5
ee81823546 arm: g_current_regs is only used to determine if we are in irq, with other functionalities removed.
reason:
by doing this we can reduce context switch time,
When we exit from an interrupt handler, we directly use tcb->xcp.regs

before
size nuttx
   text    data     bss     dec     hex filename
 225920     409   30925  257254   3ece6 nuttx

after
   text    data     bss     dec     hex filename
 225604     409   30925  256938   3ebaa nuttx

 szie change -316

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-09 18:16:43 +08:00
xuxingliang
b63826a736 arch/sim: fix uart could lose log
Need to loop to write untill all data written or error happened

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
2024-10-09 18:16:28 +08:00
Xiang Xiao
42ee317eab arch/sim: dataheap should disable exec permission
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-09 18:16:28 +08:00
yinshengkai
593768e11e sim/gcov: Fix conflicts between fprofile-orderate and __asan_default_options
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2024-10-09 18:16:28 +08:00
yinshengkai
b7121aac86 Revert "arch/sim: suppress libasan checks"
This reverts commit 53ddc3ef7f

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:16:28 +08:00
ligd
d8637788a7 sim: fix context-switch when do wdog callback()
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-09 18:16:28 +08:00
raiden00pl
dff79e8e54 boards/stm32f7/stm32f746g-disco: fix FMC pin
during migration from legacy pinout some of the FMC pins were ommited because
their names were identical to the new pinout, which didn't cause a compilation error.

This fixes LCD examples.

Also update incomplete stm32f769i-disco FMC support to avoid this kind of bug in the future
2024-10-09 00:04:57 +08:00
buxiasen
77d1f78996 board/arm/stm32: highpri up_interrupt_context to is_nesting_interrupt
up_interrupt_context indicates that we self inside interrupt/handler mode,
replaced to private function is_nesting_interrupt to make less confused.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:53:57 +08:00
buxiasen
431b848c79 board/arm/nrf52: fix use up_interrupt_context to is_nesting_interrupt
The case want to determine if a interrupt with higher priority and the
interrupt preemption occurred, but up_interrupt_context indicates that we
self inside interrupt/handler mode. As we previously did not handle the
ramvector interrupt correctly, after update breaked the case. We should
use a more clear private function is_nesting_interrupt.

Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-08 23:53:57 +08:00
chenxiaoyi
21501f65b1 sim: add link option /LARGEADDRESSAWARE:NO for windows64
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
a23ed77782 sim: add windows64 setjmp/longjmp support
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
835aac23b7 sim: change the type of xcpt_reg_t
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
2f512f78bf libc: fix build warning
nuttx\libs\libc\misc\lib_bitmap.c(1,1): warning C4819: The file contains a character that cannot
 be represented in the current code page (936).

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
753e4d64ee sim/irq: fix windows64 build error
nuttx\vs2022\include\arch\irq.h(144,9): error C2065: 'mov': undeclared identifier

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
d309d49cae sim/types: fix windows64 build error
nuttx\include\sys\types.h(133,22): error C2371: 'size_t': redefinition; different basic types

Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
chenxiaoyi
3100deda9d sim: add windows64 defconfig
Signed-off-by: chenxiaoyi <chenxiaoyi@xiaomi.com>
2024-10-08 23:51:33 +08:00
anjiahao
9403bc126b modlib/dlfcn:unify same code
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
79b4b39994 libc/modlib: free memory resource when rmmod elf
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
dongjiuzhu1
3b0e2be058 binfmt/modlib: support loading each sections to different memory for Relocate object
The feature depends on ARCH_USE_SEPARATED_SECTION
the different memory area has different access speed and cache
capability, so the arch can custom allocate them based on
section names to achieve performance optimization

test:
sim:elf
sim:sotest

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-08 23:51:33 +08:00
ligd
a965e3c3f9 math: remove is_power_of_2() keep IS_POWER_OF_2()
Caused it may conflict with other platfrom

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-08 23:50:47 +08:00
Ville Juven
10e44f8915 riscv_fork.c: Fix race condition when handling parent integer registers
We need to record the parent's integer register context upon exception
entry to a separate non-volatile area. Why?

Because xcp.regs can move due to a context switch within the fork() system
call, be it either via interrupt or a synchronization point.

Fix this by adding a "sregs" area where the saved user context is placed.
The critical section within fork() is also unnecessary.
2024-10-03 09:07:57 +08:00
Ville Juven
2d3c94411b riscv_fork.c: Fix vfork() for kernel mode + SMP
There was an error in the fork() routine when system calls are in use:
the child context is saved on the child's user stack, which is incorrect,
the context must be saved on the kernel stack instead.

The result is a full system crash if (when) the child executes on a
different CPU which does not have the same MMU mappings active.
2024-10-03 09:07:57 +08:00
hujun5
d1fec65e1b riscv: use g_running_task store current regs
This commit fixes the regression from https://github.com/apache/nuttx/pull/13561

In order to determine whether a context switch has occurred,
we can use g_running_task to store the current regs.
This allows us to compare the current register state with the previously
stored state to identify if a context switch has taken place.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-03 09:07:48 +08:00
likun17
57f84aaca8 sensor: Added 6dof motion and gesture related types. For details, see: https://developer.android.com/reference/android/hardware/SensorEvent#values
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-03 09:06:59 +08:00
likun17
a4e90b7268 inlclude/uorb.h:Update data types to be sorted by macro definition.
Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-03 09:06:59 +08:00
likun17
6a4196c572 sensor:sensor info power max_range and resolution are unified with Android type. 0e67aa0cae:include_all/hardware/sensors.h
Nuttx    <-------------------------------> Android
int32_t  <-- version                   --> int
float    <-- power                     --> float
float    <-- max_range                 --> float
float    <-- resolution                --> float
int32_t  <-- min_delay                 --> int32_t
int32_t  <-- max_delay                 --> int32/64_t
uint32_t <-- fifo_reserved_event_count --> uint32_t
uint32_t <-- fifo_max_event_count      --> uint32_t
char[]   <-- name                      --> char*
char[]   <-- vendor                    --> char*

Signed-off-by: likun17 <likun17@xiaomi.com>
2024-10-03 09:06:59 +08:00
dongjiuzhu1
eb0732a183 nuttx/uorb.h: align sensor_type value with aosp refs:0e67aa0cae:include_all/hardware/sensors-base.h
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-10-03 09:06:59 +08:00
buxiasen
40354619f3 Doc/ioexpand: add descriptions about ioexpander
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-03 09:06:04 +08:00
dulibo1
1179802cfe gpio:add feature for gpio wakeup
1.add pin type to cfg gpio as wake up source
2.add IOEXPANDER_OPTION_WAKEUPCFG for set wake up option

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
Signed-off-by: buxiasen <buxiasen@xiaomi.com>
2024-10-03 09:06:04 +08:00
Alin Jerpelea
2ec6c6e1fc Documentation: add NuttX-12.7.0 release notes
Add release notes for 12.7.0 release

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-10-02 20:56:47 +08:00
yangshuyong
a537ecdd0f Support nuttx pci endpoint driver framework
Signed-off-by: yangshuyong <yangshuyong@xiaomi.com>
Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28
56308bf202 bitmap: add bitmap_find_free_region
The pci ep framewoek use bitmap manage the pci outbond memory

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28
ca39dc2e74 math: Optimize the implementation of log2ceil and log2floor
and move common math funtions to math32.h:
div_round_up
div_round_closest
is_power_of_2
roundup_pow_of_two
rounddown_pow_of_two

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28
4fd78583f7 libc: add find_next_zero_bit
The pci ep framework use bitmap manage free bar

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
lipengfei28
b18262d78f bits:rename __set_bit to set_bit __clear_bit to clear_bit
This used for add pci ep drver framework

Signed-off-by: lipengfei28 <lipengfei28@xiaomi.com>
2024-09-23 10:03:54 +02:00
dongjiuzhu1
a2845faee3 fs/chmod/fchmod/lchmod: only set permissions by mode_t and ignore other bits
test case:

int main(void)
{
  struct stat buf;
  int ret;

  stat("test1.t", &buf);
  printf("test1.t st.mode:%x\n", buf.st_mode);
  stat("test.t", &buf);
  printf("test.t st.mode:%x\n", buf.st_mode);
  ret = chmod("test1.t", buf.st_mode);
  if (ret == 0)
    {
      stat("test1.t", &buf);
      printf("test1.t st.mode:%x\n", buf.st_mode);
    }

  return 0;
}

>>
test1.t st.mode:81b4
test.t st.mode:81fd
test1.t st.mode:81fd

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-23 14:57:37 +08:00
dependabot[bot]
a116a6210e build(deps): bump codelytv/pr-size-labeler from 1.10.0 to 1.10.1
Bumps [codelytv/pr-size-labeler](https://github.com/codelytv/pr-size-labeler) from 1.10.0 to 1.10.1.
- [Release notes](https://github.com/codelytv/pr-size-labeler/releases)
- [Commits](https://github.com/codelytv/pr-size-labeler/compare/v1.10.0...v1.10.1)

---
updated-dependencies:
- dependency-name: codelytv/pr-size-labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-23 14:37:02 +08:00
chao an
db5320fd9f drivers/syslog: compile syslog_device.c if console/char/file channel enabled
Add conditional compilation to syslog_device.c

Signed-off-by: chao an <anchao@lixiang.com>
2024-09-23 14:36:40 +08:00
chenrun1
ab4d72756e arch/samd2l2:Ignore atomic warning when using clang compiler
When the toolchain does not support atomic, it will use the version implemented by NuttX (low performance version). This scenario is consistent with the original design, so we can ignore it.

see bug here:
https://bugs.llvm.org/show_bug.cgi?id=43603

Error: inode/fs_inodeaddref.c:50:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0  bytes) [-Werror,-Watomic-alignment]
   50 |       atomic_fetch_add(&inode->i_crefs, 1);
      |       ^
/tools/clang-arm-none-eabi/lib/clang/17/include/stdatomic.h:152:43: note: expanded from macro 'atomic_fetch_add'
  152 | #define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST)
      |                                           ^
1 error generated.
make[1]: *** [Makefile:83: fs_inodeaddref.o] Error 1
Error: inode/fs_inodefind.c:74:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0  bytes) [-Werror,-Watomic-alignment]
   74 |       atomic_fetch_add(&node->i_crefs, 1);

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
chenrun1
76e83a5424 arch_atomic.c:Provide __sync_synchronize when the compiler does not support it
Summary:
  Configuration/Tool: zp214xpa/nsh,CONFIG_ARM_TOOLCHAIN_GNU_EABI
2024-09-14 06:11:00
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Enabling CONFIG_ARM_TOOLCHAIN_GNU_EABI
  Building NuttX...
arm-none-eabi-ld: /github/workspace/sources/nuttx/staging/libfs.a(fs_inoderemove.o): in function `inode_remove':
fs_inoderemove.c:(.text.inode_remove+0x94): undefined reference to `__sync_synchronize'
arm-none-eabi-ld: fs_inoderemove.c:(.text.inode_remove+0x9c): undefined reference to `__sync_synchronize'
make[1]: *** [Makefile:212: nuttx] Error 1
make: *** [tools/Unix.mk:548: nuttx] Error 2
make: Target 'all' not remade because of errors.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
chenrun1
03f215b374 nuttx/atomic.h:fix Fixed the pragma of ATOMIC_VAR_INIT in clang
Error: vfs/fs_epoll.c:126:3: error: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma]
  ATOMIC_VAR_INIT(1),     /* i_crefs */
  ^
/Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/stdatomic.h:54:41: note: macro marked 'deprecated' here
                                        ^
1 error generated.
make[1]: *** [fs_epoll.o] Error 1
Error: socket/socket.c:78:3: error: macro 'ATOMIC_VAR_INIT' has been marked as deprecated [-Werror,-Wdeprecated-pragma]
  ATOMIC_VAR_INIT(1),     /* i_crefs */

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00
chenrun1
4cec713dbf fs_inode:Change the type of i_crefs to atomic_int
Summary:
  1.Modified the i_crefs from int16_t to atomic_int
  2.Modified the i_crefs add, delete, read, and initialize interfaces to atomic operations
The purpose of this change is to avoid deadlock in cross-core scenarios, where A Core blocks B Core’s request for a write operation to A Core when A Core requests a read operation to B Core.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-09-23 14:07:03 +08:00