Commit Graph

6840 Commits

Author SHA1 Message Date
chao an
b9a74f30c6 sched/init: refine init state interface
N/A, refine init state interface

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-23 01:04:15 +08:00
ligd
a1836de09a fdt: move fdx_xx extend APIs from boards to drivers
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-22 18:51:33 +08:00
zhanghongyu
430247cc99 include: format alignment
Align the comments in the include directory

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-03-21 19:53:05 +08:00
shizhenghui
5a313d0da3 Update v4l2 ctrls & v4l2_outputparm
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-03-21 19:23:53 +08:00
Xiang Xiao
d680ba47c4 Move video_controls.h from include/nuttx/video to include/sys
The video_controls.h is a public header file, and it is used by
videoio.h. So it should be moved to the include/sys directory.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-03-21 19:23:53 +08:00
shizhenghui
3afd26bcd1 Add ioctl interface used in v4l2m2m
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-03-21 19:23:53 +08:00
chao an
feb6ede434 sched/cpu: replace up_cpu_index() to this_cpu()
In SMP mode, up_cpu_index()/this_cpu() are the same, both return the index of the physical core.
In AMP mode, up_cpu_index() will return the index of the physical core, and this_cpu() will always return 0

| #ifdef CONFIG_SMP
| #  define this_cpu()             up_cpu_index()
| #elif defined(CONFIG_AMP)
| #  define this_cpu()             (0)
| #else
| #  define this_cpu()             (0)
| #endif

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-21 18:52:35 +08:00
chao an
4e62d0005a sched: replace some global variables to macro
replace to macro will help to extend the scheduling implementation

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-21 18:51:25 +08:00
Radek Pesina
8f9c337c66 drivers/can/sja1000: Add SJA1000 CAN driver support
This driver is based on ESP32 TWAI CAN drivers currently available
in Nuttx, and captures the differences currently present across the
TWAI drivers for easy future adaption to remaining ESP32 platforms
with no loss of support/function. Also provides a generic SJA1000 CAN
driver solution that is CPU-architecture independent.

Changes:
- Low-level driver re-written to allow usage independent of CPU
architecture, and support both SJA1000 and TWAI CAN controllers.
- Platform-specific settings abstracted away to be provided by board
layer.
- Support for multiple instances of SJA1000 driver.
2024-03-19 15:45:53 -03:00
TaiJu Wu
23d65cb97f shced:sem: replace mutex with spinlock
The overhead of spinlok is less than mutext (mutex need to call
enter_critical section.)
After this patch, `down_write_trylock` and `down_read_trylock` can be
use in interrupt context.

The instruction is protected with mutex only one instruction so using
spinlock is better.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2024-03-19 18:06:12 +08:00
zhangyuan21
9c0d2e1a3c armv7-a/gicv2: move IRQ to group1 and group0 as the FIQ
Purpose: make the the os crash when busyloop with interrupt disable

Follow the arm gicv2 spec, if we want to use the IRQ and FIQ
simultaneously when not using the processor Security Externsions.
We should:
1. IRQ to Group 1 and FIQ to Group 0;
2. Set CICC_CTLR.FIQEn to 1;

Then in NuttX:
1. implement the arm_decodefiq and directly crash in it;
2. provide interface to change the IRQ to FIQ, e.g. change the
   watchdog IRQ to FIQ, so the watchdog can trigger even with the
   interrupt disabled (up_irq_save() called);

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>
Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-19 18:24:42 +09:00
chao an
d4d49e9645 stdio/file: unify group file list to common single queue
unify group file list to common single queue

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-18 19:32:49 +08:00
raiden00pl
8bf6b17cc0 sensors/bmi270: fix accel and gyro data position
accel registers are DATA_8 to DATA_13
gyro registers are DATA_14 to DATA_19
2024-03-14 21:16:46 -03:00
chao an
2b4002d9ad sched/signal: move unblock signal info to stack
struct tcb_s will reduce by 24 bytes

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-15 01:10:55 +08:00
wangmingrong
d2fd043575 mm: Using Macros Instead of Memory to Fill Labels
Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-03-14 22:48:19 +08:00
wangmingrong
737b9c843d .gitignore: add ignore
Signed-off-by: wangmingrong <wangmingrong@xiaomi.com>
2024-03-14 22:47:55 +08:00
chao an
df30a1f8d3 sched/pthread/join: refactor pthread join to support join task
1. add support to join main task

| static pthread_t self;
|
| static void *join_task(void *arg)
| {
|   int ret;
|   ret = pthread_join(self, NULL);          <---  /* Fix Task could not be joined */
|   return NULL;
| }
|
| int main(int argc, char *argv[])
| {
|   pthread_t thread;
|
|   self = pthread_self();
|
|   pthread_create(&thread, NULL, join_task, NULL);
|   sleep(1);
|
|   pthread_exit(NULL);
|   return 0;
| }

2. Detach active thread will not alloc for additional join, just update the task flag.
3. Remove the return value waiting lock logic (data_sem),
   the return value will be stored in the waiting tcb.
4. Revise the return value of pthread_join(), consistent with linux
   e.g:
       Joining a detached and canceled thread should return EINVAL, not ESRCH

   https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_join.html

   [EINVAL]
      The value specified by thread does not refer to a joinable thread.

NOTE:

This PR will not increase stack usage, but struct tcb_s will increase 32 bytes.

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-13 18:06:56 +09:00
shizhenghui
255090d594 Refactor nuttx v4l2
Adjust the v4l2 framework to support both capture and v4l2m2m,
and can easily add other v4l2 features.

Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2024-03-13 09:51:08 +08:00
yaojingwei
c3a3f79741 video: extend imgsensor_s interface for getting sensor device params.
Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
2024-03-13 09:51:08 +08:00
Tiago Medicci Serrano
2b18917a6b Revert "assert/panic: disable panic message to save the code size"
This reverts commit 9b1c451f2f.
2024-03-13 09:44:51 +08:00
SPRESENSE
75a0a08a4d drivers/video: Modify control id definition
Modify control id definition to avoid duplication even if
the control ids belong to the same control class.
Also, not refer to control class in driver.
2024-03-11 15:44:39 +01:00
chao an
68c21df444 sched/pthread/join: remove unused joininfo
remove unused joininfo, minor issue found from code reading

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-11 22:05:33 +08:00
Yanfeng Liu
5ac401d941 mm/kconfig: fix typo in MM_DEFAULT_ALIGNMENT
This fixes minor typo in MM_DEFAULT_ALIGNMENT

Signed-off-by: Yanfeng Liu <yfliu2008@qq.com>
2024-03-11 13:12:34 +08:00
chao an
29e50ffa73 sched/group: move task group into task_tcb_s to improve performance
move task group into task_tcb_s to avoid access allocator to improve performance

for Task Termination, the time consumption will be reduced ~2us (Tricore TC397 300MHZ):
15.97(us) -> 13.55(us)

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-10 11:45:46 -03:00
raiden00pl
79e8aa5e21 sensors: add uorb support for lsm9ds1 2024-03-09 11:53:57 +08:00
chao an
ec08031e4b sched/group: change type of task group member to single queue
Change the type of task group member to single list chain to
avoid accessing the memory allocator to improve the performance

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-07 12:39:29 +08:00
chao an
eb6fe17baa nuttx/list/queue: add helper macro list/sq/dq_is_singular()
add helper macro list/sq/dq_is_singular() to tests whether a list has just one entry.

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-07 12:39:29 +08:00
chao an
d29748258b fs/inode: add pre-allocated task files to avoid allocator access
Pre-allocated files to avoid allocator access during thread creation
phase, For functional safety requirements, increase
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK could also avoid allocator access
caused by the file descriptor exceeding the limit.

For Task Termination, the time consumption will be reduced ~3us (Tricore TC397 300MHZ):
10.65(us) -> 7.35(us)

NOTE:
This commit will not waste of extra heap, just pre-allocates the list of files for task_group.

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-07 10:58:55 +08:00
ligd
e1cd082c29 fs: enhance dup3() mulit-threads saftey
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-07 09:08:48 +08:00
hujun5
577eb47966 fdcheck: Enable fdcheck to automatically detect ownership of fd
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-03-07 09:08:48 +08:00
chao an
6233680cad nuttx/sched: remove unused group link node
This change is missing from the below commit:

| commit 7cb1f3b3c0
| Author: chao an <anchao@lixiang.com>
| Date:   Tue Mar 5 10:23:30 2024 +0800
|
|     sched/group: replace group_findbypid to task_getgroup
|
|     Task group could find from process id, replace group_findbypid to
|     task_getgroup to simplify the search logic
|
|     Signed-off-by: chao an <anchao@lixiang.com>

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-06 13:32:02 +08:00
chao an
8592e7e009 sched/task: save argument counter to avoid limit check
The maximum startup parameters have been checked accordingly in nxtask_setup_stackargs(),
let us save argument counter to avoid limit check.

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-05 22:25:28 +08:00
ligd
d45a45da94 sched.h: add empty realize when NO CONFIG_SMP
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-05 17:50:58 +08:00
ligd
27de65edc0 sched.h: fix CPU_EQUAL(s1, s2) write error
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-05 17:50:58 +08:00
Tiago Medicci Serrano
ae9ef972c0 paging: Rename existing CONFIG_PAGING to CONFIG_LEGACY_PAGING
Current `CONFIG_PAGING` refers to an experimental implementation
to enable embedded MCUs with some limited RAM space to execute
large programs from some non-random access media.

On-demand paging should be implemented for the kernel mode with
address environment implementation enabled.
2024-03-05 09:45:49 +08:00
Saurav Pal
1bec133385 drivers/mtd/mtd_nandram: Adds virtual NAND Flash device simulator.
Adds virtual NAND Flash device simulator, NAND flash log wrapper, and documentation for it.

Signed-off-by: Saurav Pal <resyfer.dev@gmail.com>
2024-03-04 10:38:08 -03:00
chao an
9489953230 sched/tcb: add free tcb flag to support static tcb
Add support for static tcb, applications in some special case can
initialize system resources in advance through static tcb.

|  static struct task_tcb_s g_tcb;
|
|  memset(&g_tcb, 0, sizeof(struct task_tcb_s));
|  g_tcb.cmn.flags = TCB_FLAG_TTYPE_KERNEL;
|  nxtask_init(&g_tcb, "PTCB", 101, NULL, 1024, ptcb_task, NULL, NULL, NULL);
|
|  ...
|  nxtask_activate(&g_tcb.cmn);

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-04 20:05:11 +08:00
ligd
fd2da7f4bc cpuload: change cpuload type to clock_t
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-03 02:15:40 +08:00
ligd
2241969e5a SMP: fix crash when switch to new task which is still running
cpu0 thread0:                        cpu1:
sched_yield()
nxsched_set_priority()
nxsched_running_setpriority()
nxsched_reprioritize_rtr()
nxsched_add_readytorun()
up_cpu_pause()
                                     IRQ enter
                                     arm64_pause_handler()
                                     enter_critical_section() begin
                                     up_cpu_paused() pick thread0
                                     arm64_restorestate() set thread0 tcb->xcp.regs to CURRENT_REGS
up_switch_context()
  thread0 -> thread1
arm64_syscall()
    case SYS_switch_context
     change thread0 tcb->xcp.regs
    restore_critical_section()
                                     enter_critical_section() done
                                     leave_critical_section()
                                     IRQ leave with restore CURRENT_REGS
                                     ERROR !!!

Reason:
As descript above, cpu0 swith task: thread0 -> thread1, and the
syscall() execute slowly, this time cpu1 pick thread0 to run at
up_cpu_paused(). Then cpu0 syscall execute, cpu1 IRQ leave error.

Resolve:
Move arm64_restorestate() after enter_critical_section() done

This is a continued fix with:
https://github.com/apache/nuttx/pull/6833

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-03-01 21:05:00 +09:00
chao an
954bffcbd7 sched/tls: inline group info in flat mode to improve performance
inline group info in flat mode to improve the task create/destroy performance

Signed-off-by: chao an <anchao@lixiang.com>
2024-03-01 17:27:26 +08:00
chao an
6d50274ebe nuttx/list: rename container_of to list_container_of from public header
Use private naming to avoid conflicts with user applications

In file included from libuv/src/unix/internal.h:25,
                 from libuv/src/unix/udp.c:23:
libuv/src/uv-common.h:57: warning: "container_of" redefined
   57 | #define container_of(ptr, type, member) \
      |
In file included from nuttx/include/nuttx/list.h:47,
                 from nuttx/include/nuttx/tls.h:40,
                 from nuttx/include/nuttx/sched.h:48,
                 from nuttx/include/nuttx/arch.h:87,
                 from nuttx/include/nuttx/userspace.h:35,
                 from nuttx/include/nuttx/mm/mm.h:30,
                 from nuttx/include/nuttx/kmalloc.h:34,
                 from nuttx/include/nuttx/lib/lib.h:31,
                 from nuttx/include/stdio.h:35,
                 from apps/system/libuv/libuv/include/uv.h:59,
                 from libuv/src/unix/udp.c:22:
nuttx/include/nuttx/nuttx.h:48: note: this is the location of the previous definition
   48 | #define container_of(ptr, type, member) \
      |

Signed-off-by: chao an <anchao@lixiang.com>
2024-02-29 19:44:54 +08:00
chao an
9b1c451f2f assert/panic: disable panic message to save the code size
Requirement of nuttx as a minimum scheduler os.

Test build on Cortex-R52, fvp-armv8r-aarch32/nsh

Disable CONFIG_DEBUG_ASSERTIONS and without this change:
$ size nuttx
   text	   data	    bss	    dec	    hex	filename
  19484	    104	   1092	  20680	   50c8	nuttx

Disable CONFIG_DEBUG_ASSERTIONS and with this change:
$ size nuttx
   text	   data	    bss	    dec	    hex	filename
  17604	     80	    848	  18532	   4864	nuttx

Signed-off-by: chao an <anchao@lixiang.com>
2024-02-27 10:33:43 -03:00
SPRESENSE
51b3dbb78d sensors: Remove duplicated defnitions from bmi160.h
Remove duplicated defnitions from bmi160.h.
2024-02-27 13:00:23 +01:00
chao an
17198594a8 nuttx/tls: remove the tls warning since pthread could be disabled
include/nuttx/tls.h:52:4: warning: #warning CONFIG_TLS_NELEM is not defined [-Wcpp]
   52 | #  warning CONFIG_TLS_NELEM is not defined
      |    ^~~~~~~
In file included from include/nuttx/sched.h:48,
                 from include/nuttx/arch.h:87,
                 from include/nuttx/userspace.h:35,
                 from include/nuttx/mm/mm.h:30,
                 from include/nuttx/kmalloc.h:34,
                 from sim_bringup.c:33:
include/nuttx/tls.h:52:4: warning: #warning CONFIG_TLS_NELEM is not defined [-Wcpp]
   52 | #  warning CONFIG_TLS_NELEM is not defined
      |    ^~~~~~~

Signed-off-by: chao an <anchao@lixiang.com>
2024-02-27 13:21:54 +08:00
Michał Łyszczek
84a2cab886 drivers/analog/hx711.c: Add driver for hx711 adc
Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
2024-02-26 19:16:51 -03:00
wangyongrong
be4875ed30 rptun ioctl: remove rptun_panic and rptun_dump_all
In the previous patch, we moved rptun_panic and rptun_dump_all in rptun to rpmsg.
In order to ensure CI pass, this two API in rptun is not removed. So we remove rptun_panic and rptun_dump_all in this patch.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-02-21 21:38:05 -08:00
Masayuki Ishikawa
1a11479831 Revert "assert: change the do-while of assert to a conditional expression"
This reverts commit 23aba6c2a1.
2024-02-21 21:29:48 -08:00
Masayuki Ishikawa
e6ca27ac2f Revert "assert: When defining NDEBUG, do not use macro parameters"
This reverts commit 3b6e7c1927.
2024-02-21 21:29:48 -08:00
chenrun1
5c6bd833ed fs_lock:Implementing file locks
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-02-21 13:29:36 -03:00
chenrun1
17ede2fde4 list.h:add list_for_every_entry_safe_from
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-02-21 13:29:36 -03:00