Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature k210 #16

Merged
merged 5 commits into from
Dec 31, 2019
Merged

feature k210 #16

merged 5 commits into from
Dec 31, 2019

Conversation

masayuki2009
Copy link
Contributor

Summary

  • Added initial support for Sipeed Maix Bit board with Kendryte K210 processor.
  • K210 has two RV64GC cores but in this PR only the primary core is enabled.

Impact

  • Some common files for RISC-V have been modified to support RV64GC.
  • I also checked this PR with my SparkFun RED-V Plus which has SiFive FE310 core (RV32IMAC)

Limitations / TODO

  • Because this is a initial porting some drivers such as GPIO/I2C/SPI are missing.
  • Also, nuttx (elf file) must be loaded with openocd-k210.

These limitations and TODO are described in README.txt under the board directory.

Testing

  • I confirmed that ostest passed. Also, basic commands such as uname/ps/free/sleep work as well.

include/stdint.h Outdated
typedef _intptr_t intptr_t;
typedef _uintptr_t uintptr_t;
#endif

Copy link
Contributor

@patacongo patacongo Dec 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe that this is a correct change. You should not put any CPU specific definitions in the POSIX standard stdint.h. That is the wrong way to go. It violates the basic layering within the OS.

Instead, you need to change arch/risc-v/include/types.h. That is the appropriate place for this change. arch/risc-v/include/types.h defines _intptr_t and _uintptr_t and is included by include/stdint.h. This was designed this way to specifically to prohibit CPU-specific changes in stdint.h.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@patacongo Thanks for the comment. I understand what I should do. I'll fix the commits and force to push again.

@masayuki2009
Copy link
Contributor Author

@patacongo I fixed what you pointed out and pushed again.

@patacongo patacongo changed the base branch from master to dev December 31, 2019 14:53
@patacongo patacongo merged commit fbc046e into apache:dev Dec 31, 2019
patacongo pushed a commit that referenced this pull request Dec 31, 2019
Author: Gregory Nutt <[email protected]>

    Run all .c and .h modified in PR through nxstyle.

Author: Masayuki Ishikawa <[email protected]>

    feature k210 (#16)

    * arch: risc-v: Add support for __LP64__ to types.h
    * arch: risc-v: Add support for RV64GC to common files
    * arch: risc-v: Add support for Kendryte K210 processor (RV64GC)
    * boards: risk-v: Add support for Sipeed Maix Bit with K210
    * tools: Add support for Kendryte K210 processor
xiaoxiang781216 referenced this pull request in xiaoxiang781216/incubator-nuttx Dec 31, 2019
Author: Gregory Nutt <[email protected]>

    Run all .c and .h modified in PR through nxstyle.

Author: Masayuki Ishikawa <[email protected]>

    feature k210 (#16)

    * arch: risc-v: Add support for __LP64__ to types.h
    * arch: risc-v: Add support for RV64GC to common files
    * arch: risc-v: Add support for Kendryte K210 processor (RV64GC)
    * boards: risk-v: Add support for Sipeed Maix Bit with K210
    * tools: Add support for Kendryte K210 processor
@masayuki2009 masayuki2009 deleted the feature_k210 branch March 20, 2020 01:07
anchao added a commit to anchao/nuttx that referenced this pull request Jun 15, 2020
ASAN trace:
...
==32087==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4502120 at pc 0x56673ca3 bp 0xff9b6a08 sp 0xff9b69f8
WRITE of size 1 at 0xf4502120 thread T0
    #0 0x56673ca2 in strcpy string/lib_strcpy.c:64

0xf4502120 is located 0 bytes to the right of 8224-byte region [0xf4500100,0xf4502120)
allocated by thread T0 here:
    #0 0xf7a60f54 in malloc (/usr/lib32/libasan.so.4+0xe5f54)
    #1 0x5667725d in up_create_stack sim/up_createstack.c:135
    #2 0x56657ed8 in nxthread_create task/task_create.c:125
    #3 0x566580bb in kthread_create task/task_create.c:297
    #4 0x5665935f in work_start_highpri wqueue/kwork_hpthread.c:149
    #5 0x56656f31 in nx_workqueues init/nx_bringup.c:181
    #6 0x56656fc6 in nx_bringup init/nx_bringup.c:436
    apache#7 0x56656e95 in nx_start init/nx_start.c:809
    apache#8 0x566548d4 in main sim/up_head.c:95
    apache#9 0xf763ae80 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18e80)

CALLSTACK:
    apache#8  0xf79de7a5 in __asan_report_store1 () from /usr/lib32/libasan.so.4
    apache#9  0x565fd4d7 in strcpy (dest=0xf4a02121 "", src=0xf5c00895 "k") at string/lib_strcpy.c:64
    apache#10 0x565e4eb2 in nxtask_setup_stackargs (tcb=0xf5c00810, argv=0x0) at task/task_setup.c:570
    apache#11 0x565e50ff in nxtask_setup_arguments (tcb=0xf5c00810, name=0x5679e580 "hpwork", argv=0x0) at task/task_setup.c:714
    apache#12 0x565e414e in nxthread_create (name=0x5679e580 "hpwork", ttype=2 '\002', priority=224, stack=0x0, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:143
    apache#13 0x565e42e3 in kthread_create (name=0x5679e580 "hpwork", priority=224, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:297
    apache#14 0x565e5557 in work_start_highpri () at wqueue/kwork_hpthread.c:149
    apache#15 0x565e3e32 in nx_workqueues () at init/nx_bringup.c:181
    apache#16 0x565e3ec7 in nx_bringup () at init/nx_bringup.c:436
    apache#17 0x565e3d96 in nx_start () at init/nx_start.c:809
    apache#18 0x565e3195 in main (argc=1, argv=0xffe6b954, envp=0xffe6b95c) at sim/up_head.c:95

Change-Id: I096f7952aae67d055daa737e967242eb217ef8ac
Signed-off-by: chao.an <[email protected]>
patacongo pushed a commit that referenced this pull request Jun 15, 2020
ASAN trace:
...
==32087==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4502120 at pc 0x56673ca3 bp 0xff9b6a08 sp 0xff9b69f8
WRITE of size 1 at 0xf4502120 thread T0
    #0 0x56673ca2 in strcpy string/lib_strcpy.c:64

0xf4502120 is located 0 bytes to the right of 8224-byte region [0xf4500100,0xf4502120)
allocated by thread T0 here:
    #0 0xf7a60f54 in malloc (/usr/lib32/libasan.so.4+0xe5f54)
    #1 0x5667725d in up_create_stack sim/up_createstack.c:135
    #2 0x56657ed8 in nxthread_create task/task_create.c:125
    #3 0x566580bb in kthread_create task/task_create.c:297
    #4 0x5665935f in work_start_highpri wqueue/kwork_hpthread.c:149
    #5 0x56656f31 in nx_workqueues init/nx_bringup.c:181
    #6 0x56656fc6 in nx_bringup init/nx_bringup.c:436
    #7 0x56656e95 in nx_start init/nx_start.c:809
    #8 0x566548d4 in main sim/up_head.c:95
    #9 0xf763ae80 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x18e80)

CALLSTACK:
    #8  0xf79de7a5 in __asan_report_store1 () from /usr/lib32/libasan.so.4
    #9  0x565fd4d7 in strcpy (dest=0xf4a02121 "", src=0xf5c00895 "k") at string/lib_strcpy.c:64
    #10 0x565e4eb2 in nxtask_setup_stackargs (tcb=0xf5c00810, argv=0x0) at task/task_setup.c:570
    #11 0x565e50ff in nxtask_setup_arguments (tcb=0xf5c00810, name=0x5679e580 "hpwork", argv=0x0) at task/task_setup.c:714
    #12 0x565e414e in nxthread_create (name=0x5679e580 "hpwork", ttype=2 '\002', priority=224, stack=0x0, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:143
    #13 0x565e42e3 in kthread_create (name=0x5679e580 "hpwork", priority=224, stack_size=8192, entry=0x565e54e1 <work_hpthread>, argv=0x0) at task/task_create.c:297
    #14 0x565e5557 in work_start_highpri () at wqueue/kwork_hpthread.c:149
    #15 0x565e3e32 in nx_workqueues () at init/nx_bringup.c:181
    #16 0x565e3ec7 in nx_bringup () at init/nx_bringup.c:436
    #17 0x565e3d96 in nx_start () at init/nx_start.c:809
    #18 0x565e3195 in main (argc=1, argv=0xffe6b954, envp=0xffe6b95c) at sim/up_head.c:95

Change-Id: I096f7952aae67d055daa737e967242eb217ef8ac
Signed-off-by: chao.an <[email protected]>
donghengqaz pushed a commit to donghengqaz/incubator-nuttx that referenced this pull request Jul 20, 2020
…nnerat-images-devkit

Feature/sdc integration generation images for devkit
anchao added a commit to anchao/nuttx that referenced this pull request Dec 14, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|apache#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|apache#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|apache#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|apache#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|apache#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|apache#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|apache#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|apache#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|apache#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|apache#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|apache#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|apache#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|apache#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|apache#21 0x08049713 in nxtask_start () at task/task_start.c:144
|apache#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Dec 14, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|apache#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|apache#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|apache#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|apache#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|apache#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|apache#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|apache#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|apache#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|apache#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|apache#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|apache#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|apache#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|apache#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|apache#21 0x08049713 in nxtask_start () at task/task_start.c:144
|apache#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Dec 15, 2020
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|#21 0x08049713 in nxtask_start () at task/task_start.c:144
|#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <[email protected]>
GUIDINGLI added a commit to GUIDINGLI/incubator-nuttx that referenced this pull request Mar 25, 2022
VELAPLATFO-1942

-apache#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-apache#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-apache#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-apache#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-apache#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-apache#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-apache#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-apache#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-apache#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-apache#18 0x5684427a in nxtask_start () at task/task_start.c:133
-apache#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Change-Id: I0096ac691ce9cf4169d1fb8bfa6d27a8c1ee7d52
Signed-off-by: ligd <[email protected]>
GUIDINGLI added a commit to GUIDINGLI/incubator-nuttx that referenced this pull request Mar 25, 2022
-apache#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-apache#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-apache#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-apache#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-apache#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-apache#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-apache#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-apache#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-apache#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-apache#18 0x5684427a in nxtask_start () at task/task_start.c:133
-apache#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Signed-off-by: ligd <[email protected]>
pkarashchenko pushed a commit that referenced this pull request Mar 27, 2022
-#9  0xf7abf899 in __asan::__asan_report_load2 (addr=4072681776) at ../../../../../src/libsanitizer/asan/asan_rtl.cc:117
-#10 0x5693f718 in inode_release (node=0xf2c03124) at inode/fs_inoderelease.c:69
-#11 0x568ea61b in file_close (filep=0xf55fedd0) at vfs/fs_close.c:79
-#12 0x568e7e56 in nx_close (fd=3) at inode/fs_files.c:528
-#13 0x568e7f0e in close (fd=3) at inode/fs_files.c:562
-#14 0x56e76c39 in epoll_close (epfd=3) at vfs/fs_epoll.c:252
-#15 0x56c33829 in sensor_service_delete (ctrl=0x578b8540 <control>) at src/common.c:439
-#16 0x56a0561e in sensor_middle_service_main (argc=1, argv=0xf55de820) at sensor_main.c:118
-#17 0x56878675 in nxtask_startup (entrypt=0x56a054cc <sensor_middle_service_main>, argc=1, argv=0xf55de820) at sched/task_startup.c:70
-#18 0x5684427a in nxtask_start () at task/task_start.c:133
-#19 0xdeadbeef in ?? ()

reason:
epoll_close -> close -> epoll_do_close (free inode)
                     -> inode_release  (reuse inode, crash)

fix:
use the global inode to match the fd which will return to user.
like the g_sock_inode in fs/socket/socket.c

Signed-off-by: ligd <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Apr 12, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], apache#16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Apr 12, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], apache#16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Apr 13, 2022
The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], #16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <[email protected]>
SimonFilgis referenced this pull request in SimonFilgis/incubator-nuttx May 3, 2022
Signed-off-by: 田昕 <[email protected]>

workqueue: add work_foreach support

Signed-off-by: ligd <[email protected]>

arch/risc-v: Rename up_fpuconfig to riscv_fpuconfig

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Use riscv_fpuconfig to enable FPU

Use common function instead of chip specified code.

Signed-off-by: Huang Qi <[email protected]>

riscv/bl602: Implement SPI Cmd/Data

To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO.

To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside `bl602_spi_cmddata()`.

When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside `bl602_spi_select()`.

[More Details Here](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

This change impacts 3 LCD drivers that call `SPI_CMDDATA()`: ST7735, ST7789, GC9A01.

Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used.

After the change, the above drivers will set the LCD Data/Command Pin correctly.

We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602:

-   [Testing with Logic Analyser](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

We also tested LVGL with ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-29)

arch/risc-v/litex: add cache_invalidate

driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode

arch/risc-v/src/litex/litex_sdio: add litesdcard peripheral driver

See the following for details on the pepheral:
https://github.com/enjoy-digital/litesdcard

boards/risc-v/litex/arty_a7: add SDCARD support for the Arty_A7 board

boards/risc-v/litex/arty_a7: update README to include building in LITESDCARD peripheral

opendir: use inode_find() instead when opendir()

Signed-off-by: ligd <[email protected]>

arm/cortex-[a|r]: IRQ Switch return should with shadow SPSR

The SPSR is used to store the current value of the CPSR when an exception
is taken so that it can be restored after handling the exception.
Each exception handling mode can access its own SPSR.

User mode and System mode do not have an SPSR because they are not
exception handling modes.

Signed-off-by: chao.an <[email protected]>

signal: Don't do schedule_sigaction when there is no action

Signed-off-by: ligd <[email protected]>

task: don't set default signal in kernal thread

Signed-off-by: ligd <[email protected]>

riscv/bl602: Remove check for LCD driver

`bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

We tested with LVGL and ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30)

riscv/esp32c3: Remove check for LCD driver

`esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

This is a minor patch so no testing is needed.

xtensa: Move XCHAL_SWINT_CALL definition into syscall header

This is required to avoid the interface header (syscall.h) depending on
the xtensa_swi.h header from the implementation

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

xtensa: Build OS-assisted atomic operations on ESP32-S2

ESP32-S2 lacks support for conditional load/store instructions.

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

risc-v/esp32c3: Fix inclusion of C++ constructors/destructors table

RISC-V GCC is configured with --enable-initfini-array so it emits an
.init_array section instead of .ctors

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

xtensa|risc-v: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

libcxx: Add patch for preventing redefinition of PS macro on Xtensa

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

libcxx: Fix libc++ for archs without conditional load/store support

This commit brings a patch already merged to upstream LLVM project:
https://reviews.llvm.org/D118391

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

esp32[s2/s3/c3]: Add defconfigs for testing C++

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

arch/arm: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

documentation: Add release notes for 10.3.0 release

This is a local copy taken from the confluence notes
https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.3

Signed-off-by: Alin Jerpelea <[email protected]>

fs/romfs: fix bug about compare path with same prefix

Signed-off-by: Jiuzhu Dong <[email protected]>

boards/boardctl:common boardctl to read reset cause.

Signed-off-by: 田昕 <[email protected]>

rptun: set rptun thread default stack size to 4K

Signed-off-by: ligd <[email protected]>

rptun: add rptun_force_panic support

Signed-off-by: ligd <[email protected]>

rptun: add rptun_reset support

Signed-off-by: ligd <[email protected]>

rptun: use HPWORK instead of thread

Signed-off-by: ligd <[email protected]>

rptun: add rptun_panic for both master & salve

Signed-off-by: ligd <[email protected]>

rptun: add rpmsg_wait/post support for recursive dispatch

Signed-off-by: ligd <[email protected]>

rptun: divide shram to TX & RX

Signed-off-by: ligd <[email protected]>

rptun: add rptun dump support

Signed-off-by: ligd <[email protected]>

rptun: pm_stay when send msg & pm_relax when all tx buffer returned

Signed-off-by: ligd <[email protected]>

rptun: enable rx interrupts for virtq

use wait_tx_buffer method need enable rx interrupts

Signed-off-by: ligd <[email protected]>

rptun: add ping rpmsg support

Signed-off-by: ligd <[email protected]>

openamp: add openamp patches

0006-openamp-fix-scenario-case.patch
0007-openamp-divide-shram-to-TX-shram-RX-shram.patch
0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch

Signed-off-by: ligd <[email protected]>

rptun: forward panic/reset to lowerhalf

Signed-off-by: ligd <[email protected]>

remove DISCLAIMER-WIP

most licenses have been converted to Apache and the non Apache
licenses have been documented.
We can assume that now it should be the time to remove DISCLAIMER-WIP

Signed-off-by: Alin Jerpelea <[email protected]>

arch/risc-v/mpfs: Remove duplicated riscv_restorefpu

Signed-off-by: Huang Qi <[email protected]>

ioe_rpmsg: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <[email protected]>

arch/risc-v: Store/Restore FPU register in exception_common

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Rename up_doirq to riscv_doirq

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Remove deprecated logic from riscv_doirq

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Merge duplicated logic by riscv_doirq

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Dont' disable/enable irq in riscv_doirq

Since these codes added to all chips but not fully tested,
so we should changd this behavior.

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Remove unneeded group_addrenv call which handled by riscv_doirq

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h

Signed-off-by: Petro Karashchenko <[email protected]>

arch/risc-v: include csr.h indirectly through nuttx/irq.h

Signed-off-by: Petro Karashchenko <[email protected]>

arch/risc-v: fix ARCH_RV32 offset for the stub lookup table calculation

Signed-off-by: Petro Karashchenko <[email protected]>

mm/mm_heap: place alloc-bit at the LSB of node->preceeding.

Heap always allocate the memory at least 2bytes alignment.

Signed-off-by: wangbowen6 <[email protected]>

mm_heap: heapsize align with MM_MIN_CHUNK.

Signed-off-by: wangbowen6 <[email protected]>

driver/syslog: Add microseconds after date time

Signed-off-by: Jiuzhu Dong <[email protected]>

ARCH_ADDRENV: Add guard against mis-configuration

When process a is switched to process b, the address environment is
swapped with a call to group_addrenv(). The stack upon entry will be
a's, and upon exit b's. This will fail, so a neutral stack is required,
either a kernel stack or an IRQ stack.

Infrastructure for an IRQ stack is already in place, so give a hint
that an interrupt stack should be provided if address environments
are enabled.

arch/risc-v: get wider visibility for arch instruction macros

Signed-off-by: Petro Karashchenko <[email protected]>

rpmsgfs: add wait ready to rpmsgfs

Signed-off-by: ligd <[email protected]>

rpmsgfs: add timeout when mount in rpmsgfs

Signed-off-by: ligd <[email protected]>

rpmsgfs: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <[email protected]>

sigact: get free sigact from freelist always successful

Signed-off-by: Jiuzhu Dong <[email protected]>

netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression

This fixes a regression caused by the following commit,
which prevents the file flag from being updated.

```
commit 28860b5242dd5efd86b5da8a089e5d898cd8a9a1
Author: chao.an <[email protected]>
Date:   Sat Mar 19 14:47:37 2022 +0800

    net/netdev: fix switch case missing break

    Signed-off-by: chao.an <[email protected]>
```

Note: some applications like mbedtls uses F_GETFL to confirm
the nonblock-ness of the socket. This is critical for such
applications.

nuttx: Add "#include <nuttx/fs/ioctl.h>" to tioctl.h

Signed-off-by: zhouliang3 <[email protected]>

fs/unionfs: fix bug about use after free about ui

Signed-off-by: Jiuzhu Dong <[email protected]>

fs/unionfs: check return value to avoid unused value

Signed-off-by: Jiuzhu Dong <[email protected]>

fs/unionfs: add sanity check for parameter

if relpath is NULL, it will cause system crash:
unionfs_opendir with relpath NULL
    ->	unionfs_tryopendir
	    ->	unionfs_offsetpath
		->  strncmp(prefix, relpath, pfxlen

Signed-off-by: Jiuzhu Dong <[email protected]>

SEGGER_RTT: solve compile error when enable segger rtt in armv7m.

1. SEGGER_RTT_ASM_ARMv7M include SEGGER_RTT.h, and SEGGER_RTT.h
include SEGGER_RTT_Conf.h, so add __ASSEMBLY__ in
SEGGER_RTT_Conf.h;
2. AFLAG add segger/config because SEGGER_RTT_ASM_ARMv7M.S
include SEGGER_RTT_Conf.h;

Signed-off-by: wangbowen6 <[email protected]>

fs/procfstcbinfo: minor bug about print address

Signed-off-by: Jiuzhu Dong <[email protected]>

fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1

Signed-off-by: Jiuzhu Dong <[email protected]>

fs and unistd: increase OPEN_MAX by claiming a Kconfig.

Signed-off-by: 田昕 <[email protected]>

rpmsgfs: do NOT access the pointer when do remote ioctl

Signed-off-by: ligd <[email protected]>

fs/rpmsgfs: fix bug about using uninit variable "times"

Signed-off-by: Jiuzhu Dong <[email protected]>

arch/xtensa: add syscall note support in the flat build

Signed-off-by: chao.an <[email protected]>

sched/note: unify the data format

Signed-off-by: chao.an <[email protected]>

sched/trace: correct the note print format

note print should with Instruction pointer.

e.g:

        trace_printk("hello NuttX");

trace dump:

hello-6  [000] .... 23080.367994: 0xc044a005: hello NuttX

Signed-off-by: chao.an <[email protected]>

sched/note: add support of trace section mark

The implementation of this feature is based on android systrace:

https://source.android.com/devices/tech/debug/ftrace

Application developers are more concerned about the performance of
the specified application section,
added two APIs to implement performance measurement:

void sched_note_begin(uintptr_t ip, FAR const char *buf);
void sched_note_end(uintptr_t ip, FAR const char *buf);
or
SCHED_NOTE_BEGIN();  /* defined to sched_note_begin(_THIS_IP_, __FUNCTION__) */
SCHED_NOTE_END();    /* defined to sched_note_end(_THIS_IP_, __FUNCTION__) */

Signed-off-by: chao.an <[email protected]>

unistd:rename CONFIG_OPEN_MAX to CONFIG_LIBC_OPEN_MAX

Signed-off-by: 田昕 <[email protected]>

sim: Fix init of static C++ constructors when using glibc >= 2.34

glibc 2.34 changed the dynamic linker behavior during the startup
process, which makes the previous "__init_array_start" replacement trick
non-effective.
Now the dynamic linker parses the constructors/destructors information
from the DYNAMIC segment of the program.

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

libs/libc/lib_err.c:add va_end to vwarn

call va_copy,after need call va_end
Signed-off-by: anjiahao <[email protected]>

local socket: cancel assert about backlog exceed 255

Signed-off-by: zhanghu6 <[email protected]>

net/local: change 255 to UINT8_MAX

Signed-off-by: Xiang Xiao <[email protected]>

power: unify lock states

unify critical_section and nxsem with pm_lock/pm_unlock

Signed-off-by: zhuyanlin <[email protected]>

power:driver: move pm_auto_update to outer dir

Pm_auto_update maybe called by outter PM users

Signed-off-by: zhuyanlin <[email protected]>

lib_chdir:use change ret judgment method

Signed-off-by: anjiahao <[email protected]>

modlib/modlib_bind:fix unsigned_compare with zero

Signed-off-by: anjiahao <[email protected]>

Update libs/libc/modlib/modlib_bind.c

u are right

Co-authored-by: Petro Karashchenko <[email protected]>

Update libs/libc/modlib/modlib_bind.c

Co-authored-by: Petro Karashchenko <[email protected]>

mmcsd: Add gotextcsd callback to sdio_dev_s

so the driver implementation could get critical EXTCSD info

Signed-off-by: anjianjun <[email protected]>

mmcsd: Move SDIO_GOTEXTCSD after SDIO_DMASENDSETUP

Signed-off-by: Xiang Xiao <[email protected]>

mmcsd: Fix mmc card error but system can not catch it

Signed-off-by: anjianjun <[email protected]>

risc-v/esp32c3: Fix regression on IRQ handling for ECALL instruction

Signed-off-by: Gustavo Henrique Nihei <[email protected]>

RISC-V: Implement option to run NuttX in supervisor mode (S-mode)

- Add config "ARCH_USE_S_MODE" which controls whether the kernel
  runs in M-mode or S-mode
- Add more MSTATUS and most of the SSTATUS register definitions
- Add more MIP flags for interrupt delegation
- Add handling of interrupts from S-mode
- Add handling of FPU from S-mode
- Add new context handling functions that are not dependent on the trap
  handlers / ecall

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
      thus S-mode is not usable as is, yet.

RISC-V: Implement skeleton for a per CPU structure

It might be useful to store things in memory per CPU. The tricky part
is that all CPUs run the same code and see the same memory, so some
kind of centralized access is required.

For now, the structure contains the hart id.

Access to the structure elements is provided via sscratch, which is
unique for every hart!

Fix ESP32-C3 toolchain download link

arch/xtensa: Add xtensa_tcbinfo struct that contains helpful offsets.

Signed-off-by: Abdelatif Guettouche <[email protected]>

fix:Temporarily remove udp send large pkt assert

Signed-off-by: zhanghongyu <[email protected]>

net: tcp/udp/icmp/icmpv6 add FIONSPACE support

Signed-off-by: zhanghongyu <[email protected]>

timerexpiration:fix DEADCODE when RR_INTERVAL or SCHED_SPORADIC not select

tmp is always true for CONFIG_RR_INTERVAL > 0
and CONFIG_SCHED_SPORADIC not select

Signed-off-by: zhuyanlin <[email protected]>

arch/riscv: Align the macro definition in csr.h

Signed-off-by: Xiang Xiao <[email protected]>

arch/riscv: Rename riscv_syscall_dispatch to riscv_dispatch_syscall

follow other function naming(e.g. riscv_dispatch_irq)

Signed-off-by: Xiang Xiao <[email protected]>

arch/riscv: Remove riscv_sbi.c since it doesn't exist

Signed-off-by: Xiang Xiao <[email protected]>

arch/riscv: Rename riscv_exception_macros.S to riscv_macros.S

since macro defined in this file is also used in the normal context

Signed-off-by: Xiang Xiao <[email protected]>

arch/riscv: Access [m|s]scratch through CSR_SCRATCH macro

Signed-off-by: Xiang Xiao <[email protected]>

arch/riscv: Rename g_scratch to g_percpu

Signed-off-by: Xiang Xiao <[email protected]>

sched_note: fix buffer size warning in coverity

Signed-off-by: zhuyanlin <[email protected]>

mod_insmod: fix coverity warning

Signed-off-by: zhuyanlin <[email protected]>

stm32: add support for up_perf

boards/nucleo-f446re: initialize up_perf

note_sysview.c: fix compilation for CONFIG_TASK_NAME_SIZE == 0

note_sysview.c: fix compilation if CONFIG_SCHED_INSTRUMENTATION_FILTER not defined

arm/chip: add backtrace support for all chips that support thumb instruction set.

Signed-off-by: wangbowen6 <[email protected]>

usrsock: Move event field to usrsock_message_common_s

Signed-off-by: zhanghongyu <[email protected]>

net:fix coverity warning

Signed-off-by: hejianliang3 <[email protected]>

stm32u5: stm32_stdclockconfig fixes

Fix stm32_stdclockconfig for stm32u585xx to the extend that the
B-U585I-IOT02A board's clock tree can be configured.  This board uses
the MSIS as PLL1's input clock and the LSE to autotrim the MSIS.

b-u585i-iot02a: Fix stdclock initialization

Correct the respective defines to initialize the B-U585I-IOT02A clock
tree correctly by means of stm32_stdclockconfig().

b-u585i-iot02a:nsh: Drop TrustedFirmware-M dependency

Make the nsh defconfig for the b-u585i-iot02a run stand-alone (i.e. not
as a companion that relies on TF-M doing low-level board
initialization).

net/utils: fix IPv4 checksum calculation

Signed-off-by: Petro Karashchenko <[email protected]>

arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm

Signed-off-by: Petro Karashchenko <[email protected]>

arch/riscv: Rename SCRATCH_HARTID_OFFSET to RISCV_PERCPU_HARTID_OFFSET

and fix the typo error

Signed-off-by: Xiang Xiao <[email protected]>

modlib_bind.c: Restore "Relocation address out of range" checks

Restore the checks which got completely broken by the following change.
```
commit 15142a8b106bee8db6ac744b963969feba5c8289
Author: anjiahao <[email protected]>
Date:   Fri Apr 1 16:20:03 2022 +0800

    modlib/modlib_bind:fix unsigned_compare with zero

    Signed-off-by: anjiahao <[email protected]>
```

syscall: Fix Makefile:69: target 'syscall_names.o' given more than once in the same rule

Signed-off-by: Xiang Xiao <[email protected]>

libc/netdb: Support the recursive lock

Signed-off-by: Xiang Xiao <[email protected]>

libc/netdb: Remove the temporary unlock in dns_foreach_nameserver

since netdb support the recursive lock

Signed-off-by: Xiang Xiao <[email protected]>

libc/netdb: Hold dns lock when operating with resolv.conf

Signed-off-by: Xiang Xiao <[email protected]>

arch/xtensa: Build the xtensa_tcbinfo.c file for S2 and S3.

Signed-off-by: Abdelatif Guettouche <[email protected]>

nuttx: unify FAR attribute usage across the code

Signed-off-by: Petro Karashchenko <[email protected]>

RISC-V: Fix file name of riscv_dispatch_syscall

RISC-V: Fix usage of static_assert in riscv_percpu.c

There is no alias for struct riscv_percu_s

Update cpp_cmake.rst

update CMAKE_C_FLAGS when compile C file

Update cpp_cmake.rst

openamp: Change the dependence from OPENAMP to RPTUN

since all rpmsg driver need the extension api exposed by rptun driver

Signed-off-by: Xiang Xiao <[email protected]>

libc/string: Fix the minor style issue

Signed-off-by: Xiang Xiao <[email protected]>

libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively

please reference the similar change done by other libc implementation:
https://reviews.llvm.org/D68028?id=224286
https://github.com/bminor/glibc/commit/85c2e6110c9a01ec817c30f1b7e20549d7229987
https://github.com/bminor/musl/commit/4a1f55e92fa74ee382909baa96302231f566b5e1
https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1

Signed-off-by: Xiang Xiao <[email protected]>

arch:tcbinfo: update tcbinfo as xcpcontext update

Signed-off-by: zhuyanlin <[email protected]>

jlink-nuttx: update regs as nuttx regs save path change

Signed-off-by: zhuyanlin <[email protected]>

include/nuttx: remove double definitions of UNUSED macro

Signed-off-by: Petro Karashchenko <[email protected]>

fix uinput rpmsg logic error

xtensa/esp32: Add support to TWAI/CANBus controller

esp32: Add board support to TWAI/CANBus

arch/sim: support simulator keyboard devices

arch/risc-v: Replace riscv_fault with riscv_exception

Remove riscv_fault since its code is duplicated with riscv_exception,
and there are textual excpetion reason in riscv_exception.

Signed-off-by: Huang Qi <[email protected]>

fs/epoll: change type of eventset from uint8_t to uint32_t

to support EPOLLONESHOT and so on.

Signed-off-by: Jiuzhu Dong <[email protected]>

fs/poll: change format for type pollevent_t

Signed-off-by: Jiuzhu Dong <[email protected]>

lib_lib_vsprintf/backtrace: fix the type issue

using 't': For integer types, causes printf to expect
a ptrdiff_t-sized integer argument.

Signed-off-by: Jiuzhu Dong <[email protected]>

fs/poll: change format for type pollevent_t

complete the following commits:

commit d87cf8d4ca5fe69c71c131015a7b64b68c917593
Author: Jiuzhu Dong <[email protected]>
Date:   Fri Apr 1 20:59:55 2022 +0800

    fs/poll: change format for type pollevent_t

    Signed-off-by: Jiuzhu Dong <[email protected]>

commit d535943a69f03033b077cb95cce162bb28b40b56
Author: Jiuzhu Dong <[email protected]>
Date:   Fri Apr 1 17:49:10 2022 +0800

    fs/epoll: change type of eventset from uint8_t to uint32_t

    to support EPOLLONESHOT and so on.

    Signed-off-by: Jiuzhu Dong <[email protected]>

Signed-off-by: chao.an <[email protected]>

arch/risc-v: Remove the unnecessary inclusion of board header files

Signed-off-by: Xiang Xiao <[email protected]>

MPFS: Prepare support for S-mode

- Access to PLIC via S-mode registers
- Access to IRQs via S-mode registers / definitions
- Initialize S-mode registers upon boot
- Initialize per CPU area before nx_start

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
thus S-mode is not usable as is, yet.

esp32c3: Simplify irq dispatch logic

ESP32C3 use customized irq encoding so it's hard to share further code
with other risc-v based chips, in this patch, we keep the exception
number definition with risc-v spec.

Signed-off-by: Huang Qi <[email protected]>

Documentation/guides/pysimcoder.rst: update pysimCoder dependencies

CONFIG_LIBM option may be required by some toolchains that do not include
standard math library. Morover CONFIG_PTHREAD_STACK_MIN was listed twice
in the list.

Signed-off-by: Michal Lenc <[email protected]>

arch/riscv: Minor style change and text correction

Signed-off-by: Huang Qi <[email protected]>

sched/pthread:need check pthread is DETACHED

pthread_join need check thread is DETACHED,
Whether to wait according to the result.And,
if a thread is DETACHED,it will not set a new
attr.
Signed-off-by: anjiahao <[email protected]>

sched/note: add dummy definition if CONFIG_SCHED_INSTRUMENTATION disabled

Signed-off-by: chao.an <[email protected]>

sched/note: correct flatten format

Signed-off-by: chao.an <[email protected]>

arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

Signed-off-by: chao.an <[email protected]>

fs/vfs: fix st_mode mask check

The full mask for st_mode is 0177777
Now modify any file permissions in hostfs and all will fail

arch/risc-v: Add handler for misaligned load/store

Some risc-v based chips don't support unaligned data access,
it will trigger a exception and then lead to crash.

In this patch, we handle the misaligned access by software to make
system run continue.

Signed-off-by: Huang Qi <[email protected]>

tools/checkrelease.sh: Don't check DISCLAIMER-WIP anymore

since all license is clean up now

Signed-off-by: Xiang Xiao <[email protected]>

sched/wqueue: Simplify CALL_WORKER dispatch condition

Signed-off-by: Xiang Xiao <[email protected]>

sched/irq: Remove CONFIG_SCHED_IRQMONITOR when define CALL_VECTOR

since up_perf_ API doesn't couple with CONFIG_SCHED_IRQMONITOR

Signed-off-by: Xiang Xiao <[email protected]>

sched/irq: Fix array overrun in coverity check

Signed-off-by: Xiang Xiao <[email protected]>

boards/nucleo-h743zi2: Enable up_perf API

Signed-off-by: Xiang Xiao <[email protected]>

boards/lx_cpu: Enable up_perf API

Signed-off-by: Xiang Xiao <[email protected]>

arch/risc-v: Align prototype of riscv_exception with xcpt_t

Thus we can attach it to irq handler without any cast.

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Attach exception handler in common place

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Move epc adjustment to riscv_doirq

Signed-off-by: Huang Qi <[email protected]>

checkpatch.sh: add -m option to enable/disable Change-Id check

Defaultly disable Change-Id check in commit message.

Signed-off-by: liuhaitao <[email protected]>

.github/workflows/check.yml: Enable Change-ID check explicitly

Signed-off-by: Xiang Xiao <[email protected]>

Make top Make.defs symlink to board Make.defs instead

Symlink to board Make.defs for top Make.defs, so top Make.defs
syncs in realtime.

Signed-off-by: liuhaitao <[email protected]>

riscv/riscv_exception_commin.S: Don't call riscv_hartid in single core
mode.

Signed-off-by: Abdelatif Guettouche <[email protected]>

riscv/riscv_exception_common.S: Allow chips to define the exception
section.

Signed-off-by: Abdelatif Guettouche <[email protected]>

riscv/esp32c3: Use the common exception handler.

Signed-off-by: Abdelatif Guettouche <[email protected]>

riscv/bl602/chip.h: Add assembly guards for standard includes.

tools/mkdeps: Extend MAX_SHQUOTE to 3072

Signed-off-by: nietingting <[email protected]>

audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize

audio: Don't register audio device if name isn't given in audio_comp_initialize

Signed-off-by: Xiang Xiao <[email protected]>

Fixes some issues with the implementation of the balance
functionality. In function "wm8904_hw_reset" the priv->balance
is initialized with b16HALF, indicating a range from
0 to b16ONE. In function "wm8904_setvolume" the assumed
range for priv->balance is between 0 and 1000. The changes
now make this consistent for 0 to b16ONE-1. Furthermore,
in wm8904_configure the change of balance was not implemented.

Minor fix, function name was wm8994_setvolume instead of
wm8904_setvolume.

Fixed source code format errors.

Revert "mm_heap: heapsize align with MM_MIN_CHUNK."

This reverts commit 69e69740b5f578e035befc762538b282d91ed1ba.

mm_initialize: malloc() return aligend pointer.

malloc() should return aligned (with MM_MIN_CHUNK) pointer, but
pr #5906 destroy that, this pr find a better method to solve
these questions.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
and
Signed-off-by: wangbowen6 <[email protected]>

arch/riscv: Add mtimer driver

Signed-off-by: Xiang Xiao <[email protected]>

sched/note: include-able from C++ files

Signed-off-by: chao.an <[email protected]>

drivers/sensors: Add new driver for scd41 sensor module

Add Sensirion's SCD41 CO2, temperature and humidity sensor driver.

drivers/sensors/scd30: Fix invalid parameter check

Fix invalid parameter check and redundant conditions.

drivers/sensors/sgp30: Fix redundant parameter check

Fix redundant conditions.

littelfs: deal with block devices w/o ioctl

Note: Some block devices has ioctl == NULL. eg. drivers/loop

netdb/lib_dnsaddserver.c: Do not insert the duplicate DNS address

Signed-off-by: songlinzhang <[email protected]>

graphics/nxterm: Avoid accessing freed memory

Fix accessing freed priv data.

drivers/syslog: update description if Kconfig

Signed-off-by: Petro Karashchenko <[email protected]>

libc/lib_localtime:fix deadcode

isdst always is false

Signed-off-by: anjiahao <[email protected]>

RISC-V: Combine 3 variables that depend on CPU amount into one

IRQ_NSTACKS, ARCH_CPU_COUNT, CONFIG_SMP_NCPUS all relate to each
other. However, a bit of clean up can be done and everything can
be merged into SMP_NCPUS.

The MPFS bootloader case works also as it requires only 1 IRQ stack
for the hart that executes as bootloader.

RISC-V: Remove riscv_cpuindex.c from platforms that don't need it

riscv_mhartid is no longer called by exception_common, so can remove
this file from platforms that don't need it.

Also fixes make warning:
Makefile:123: target 'riscv_cpuindex.o' given more than once in the same rule

RISC-V: Add setintstack for k210 and qemu

This fixes CI issue, and I think the old implementation with SMP
shared 1 IRQ stack for multiple CPUs.

sched/init: drivers_initialize() should be late than up_initialize()

up_initialize
|
 ->up_serialinit
   |
    ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

drivers_initialize
|
 ->syslog_console_init
   |
    ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: chao.an <[email protected]>

arch: cxd56xx: update loader and gnssfw version

Update loader and gnssfw to version 2.2.20585

cxd56xx/cxd56_emmc.c: Fix compile warning

Add necessary include header named debug.h for using ferr and
finfo.

arch: cxd56xx: Fix critical section in scu driver

Add critical section to scu one-shot sequencer.

boards: cxd56xx: Fix an issue i2c tool not working

It caused i2c tool not to work due to i2c uninitializing processing.
Since this process is not necessary in the normal case, we will
move it to the error case.

boards: cxd56xx: Make board_late_initialize a weak function

Add a weak_function to the board_late_initialize function so that
it can be replaced by another file, such as a user application.

board/spresense: Add pin selection of ILI934x

Add Kconfig choice for selecting RST and DC pins on ILI934x LCD.

boards: cxd56xx: Add board function for scd41 sensor driver

Add board function for SCD41 CO2, temperature and humidity sensor driver.

cxd56/spresense: Add callback mechanism to notice SDCard injection

Add a mechanism to callback to an application to notice the SDCard
status is changed (inserted or ejected).

.github/gcc.json: Fix space/tab inconsistency

sim: bt: Add specific bluetooth HCI number id

Add option for attached the local bluetooth device use
specific bluetooth HCI number id.

Signed-off-by: Lingao Meng <[email protected]>

lib_localtime:fix unsigned compare with zero

Signed-off-by: anjiahao <[email protected]>

arch/risc-v: Apply common mtime driver to mtime based chps

Signed-off-by: Huang Qi <[email protected]>

risc-v/c906: fix build break

chip/c906_timerisr.c: In function 'up_timer_initialize':
Error: chip/c906_timerisr.c:71:3: error: implicit declaration of function 'DEBUGASSERT' [-Werror=implicit-function-declaration]
   DEBUGASSERT(lower);
   ^~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: chao.an <[email protected]>

libc/lib_glob:use strlcpy instead of memcpy

Signed-off-by: anjiahao <[email protected]>

libc/net:use strlcpy instead of strncpy

Signed-off-by: anjiahao <[email protected]>

arch/risc-v: Add missing DMB to mtimer / setmtimecmp

The memory mapped mtimecmp lives in I/O space so must add barrier
to make sure the value sticks. Otherwise a new IRQ might fire
at once.

arch/risc-v: Apply misaligned access handler for k210/bl602

Signed-off-by: Huang Qi <[email protected]>

arch/riscv: Move toolchain config to arch/risc-v/Kconfig like xtensa

Signed-off-by: Xiang Xiao <[email protected]>

riscv/riscv_schedulesigaction.c: Remove the duplicate state saving.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch/arm: Move FPU initialization to common place

Signed-off-by: Xiang Xiao <[email protected]>

arch/stack_color: correct the end address of stack color

The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], #16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <[email protected]>

arm/armv8-m: indicating no low-overhead-loop predication by default

Fix usage fault on clang version 13.0.0 (-Ofast):
------------------------------------------------------------------
| arm_hardfault: Hard Fault escalation:
| arm_usagefault: PANIC!!! Usage Fault:
| arm_usagefault:  IRQ: 3 regs: 0x3c58c510
| arm_usagefault:  BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000004
| arm_usagefault:  CFSR: 00020000 HFSR: 40000000 DFSR: 00000000 BFAR: 01608050 AFSR: 00000000
| arm_usagefault: Usage Fault Reason:
| arm_usagefault:  Invalid state
| up_assert: Assertion failed at file:armv8-m/arm_usagefault.c line: 113 task: lpwork
| backtrace:
| [ 2] [<0x2c58124a>] up_backtrace+0xa/0x2e2
| [ 2] [<0x2c56f7cc>] sched_dumpstack+0x28/0x66
| [ 2] [<0x2c580cd0>] up_assert+0x62/0x254
| [ 2] [<0x2c56ab8a>] _assert+0/0xa
| [ 2] [<0x2c55575a>] nxsched_add_prioritized+0x38/0xa2
| [ 2] [<0x2c555894>] nxsched_add_blocked+0x2e/0x44
| [ 2] [<0x2c580748>] up_block_task+0x2a/0x96
| [ 2] [<0x2c5569ea>] nxsem_wait+0x64/0xb4
| [ 2] [<0x2c556a40>] nxsem_wait_uninterruptible+0x6/0x10
| [ 2] [<0x2c559b9a>] work_thread+0x1c/0x48
-------------------------------------------------------------------

usage fault on 0x2c55575a:

------------------------------------
|2c555722 <nxsched_add_prioritized>:
|; {
|2c555722: 80 b5         push  {r7, lr}
|...
|2c55575a: 2f f0 17 c0   le  0x2c555732 <nxsched_add_prioritized+0x10> @ imm = #-44
|...
------------------------------------

Arm v8-M Architecture Reference Manual:

C2.4.103 LE, LETP

B3.28 Low overhead loops:

An INVSTATE UsageFault is raised if a LE instruction is executed and FPSCR.LTPSIZE does not read as four.
When a new floating-point context is created and FPCCR.ASPEN is set to zero it is the responsibility of software
to correctly initialize FPSCR.LTPSIZE.

Signed-off-by: chao.an <[email protected]>

fs/vfs/fs_truncate.c: Use ioctl to truncate on non-mountpoint inode

Signed-off-by: Jukka Laitinen <[email protected]>

libc/time: add strptime porting support

lib_strptime.c copies from android bionic/libc/tzcode.

Signed-off-by: liuhaitao <[email protected]>
Signed-off-by: anjiahao <[email protected]>

libc/strptime:_conv_num skip space

Signed-off-by: anjiahao <[email protected]>

libc/strptime: fix warning unused-value

warning: value computed is not used [-Wunused-value]
Signed-off-by: Xiang Xiao <[email protected]>
Signed-off-by: anjiahao <[email protected]>

libc/lib_strptime:change code format & add notes

Signed-off-by: anjiahao <[email protected]>

RISC-V: Move mhartid to own assembly macro+function

Hartid and cpuindex are not the same thing. Hartid is needed regardless
of SMP, for external interrupt handling etc.

SMP needs cpuindex which might not be index == hartid, so both are
needed. IMO it is clearer to provide separate API for both.

Currently the implementation of up_cpu_index is done a bit lazily,
because it assumes hartid == cpu index, but this is not 100% accurate,
so it is still missing some logic.

arch/risc-v/riscv_misaligned: Correct sw source register

If source register of sw instruction is x0, we must point it to a constant zero
since in NuttX's context,
value of index 0 is EPC.

Signed-off-by: Huang Qi <[email protected]>

arch/risc-v: Correct format of 32-bit insn in misaligned handler

FIx:
Format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int')

Signed-off-by: Huang Qi <[email protected]>

power/governor: Remove the duplicated function prototype

since they are declared include/nuttx/power/pm.h by:
commit 5ce181e6b702cedbd79790fbe40aab7d29dae7c0
Author: zhuyanlin <[email protected]>
Date:   Mon Feb 14 15:32:40 2022 +0800

    power:govorner: add govorner to per domain.

    For mult domains scene,,
    activity and greety can be used at same time.
    Let user to select domain governor.

    Signed-off-by: zhuyanlin <[email protected]>

and add static const to g_pmgovernor

Signed-off-by: zhuyanlin <[email protected]>

drivers/power: Remove activity_governor.h and greedy_governor.h

since they aren't really used anymore

Signed-off-by: Xiang Xiao <[email protected]>

MPFS: Fix mtimecmp address

MTIMECMP0 was incorrect

MPFS: Use riscv_exception_attach like the others do

Exception / fault handling goes to unexpected ISR, fix by setting the
common ISR handlers like all other RISC-V platforms do.

arch: Fix compile error when enabling CONFIG_DUMP_ON_EXIT

"error: incompatible types when assigning to type 'struct filelist *' from type 'struct filelist'
   filelist = tcb->group->tg_filelist;"

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch: Move the DUMP_ON_EXIT logic after nxtask_exit.

Otherwise we will try to dump the state of the current task, however the
exit handler has already started doing some cleanup and invalidated its
group.  Accessing the group from dumponexit will crash.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch/Kconfig: Move the DUMP_ON_EXIT option out of the Bring-up group.

Signed-off-by: Abdelatif Guettouche <[email protected]>

sched/pthread_create:fix bug,delete data_sem

if a pthread set attr is detach,and when call pthread_create,
new thread exit quikly,new thread's tcb be free,then pthread_create
use new thread's tcb will crash.
Signed-off-by: anjiahao <[email protected]>

rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2

Signed-off-by: zhanghongyu <[email protected]>

fix: usrsock iovec_do skip empty iov

Signed-off-by: zhanghongyu <[email protected]>

sched/environ: Ensure tg_envp terminated by double '\0'

so we can compute the whole environ string length from it

Signed-off-by: Xiang Xiao <[email protected]>

RISC-V: Add SBI glue logic

Currently only stubs for mtime handling added, with a gentle reminder
that the actual implementation is still missing.

RISC-V: mtimer register via SBI when S-mode is in use

Cannot access the memory mapped registers directly when the kernel
runs in S-mode, must forward the access to SBI.

arch/[arm|sparc]: replace INT32_ALIGN_* to STACK_ALIGN_*

Signed-off-by: chao.an <[email protected]>

arch/stack_color: correct the stack top of running task

This PR to ensure the stack pointer is locate to the stack top

Signed-off-by: chao.an <[email protected]>

arm/rtl8720c: Remove up_getsp which is already implemented in arch/arm/arch.h

Signed-off-by: Xiang Xiao <[email protected]>

MPFS: Set correct interrupt per mode (M-/S-mode) for mtimer

libc/string: Use Byte-Shift algorithm for very long needles

Reference here:
https://github.com/taleinat/byteshift_strstr

Signed-off-by: chao.an <[email protected]>
Signed-off-by: anjiahao <[email protected]>

libc/string:delete small to big endian marco

avoid byte alignment
Signed-off-by: haopengxiang <[email protected]>
Signed-off-by: anjiahao <[email protected]>

libc/string:add LICENSE info

Signed-off-by: anjiahao <[email protected]>

Add SPIRAM to ESP32-S2

driver/mmcsdio: do not hold the semaphore on interrupt context

so we can do the full dump to mmc/sd card in the panic case

Signed-off-by: chao.an <[email protected]>

driver/mmcsdio: do not hold the semaphore in idle thread too

Signed-off-by: Xiang Xiao <[email protected]>

fs/fcntl: add O_APPEND flag judge in fcntl

Signed-off-by: liuhaitao <[email protected]>

vfs/fcntl: Minor style fix

Signed-off-by: Xiang Xiao <[email protected]>

arm/armv7-[a|r]: move fpu save/restore to assembly handler

Save/Restore FPU registers in C environment is dangerous practive,
which cannot guarantee the compiler won't generate the assembly code
with float point registers, especially in interrupt handling

Signed-off-by: chao.an <[email protected]>

arch/arm/src/sam34/sam_hsmci.c: delay required after sending command

arch/arm/src/sam34/sam_hsmci.c: DMA setup before write is required

arch/arm/src/sam34/sam_hsmci: DMA also present on SAM3X chips

arch/arm/src/sam34/sam_hsmci.c: SAM3X GPIO setup

arch/arm/src/sam34/Kconfig: fix typo in device name

boards/arm/a1x: Remove the check CONFIG_ARCH_FPU around arm_fpuconfig

forget in below change:
commit df5a8a53ae92606e2d65149c6b5159b82dfc5d76
Author: Xiang Xiao <[email protected]>
Date:   Tue Apr 12 03:18:46 2022 +0800

    arch/arm: Move FPU initialization to common place

    Signed-off-by: Xiang Xiao <[email protected]>

Signed-off-by: Xiang Xiao <[email protected]>

boards/esp32_twai: Remove arm_arch.h from comment

Signed-off-by: Xiang Xiao <[email protected]>

drivers: remove unimplemented open/close/ioctl interfaces

Signed-off-by: Petro Karashchenko <[email protected]>

arch/risc-v: Use fs status definition from csr.h

Signed-off-by: Huang Qi <[email protected]>

arch/riscv/esp32c3: esp32c3_twai.h TWAI (CAN) controller registers provided by Espressif.

File provided by Abdelatif Guettouche

Signed-off-by: Jan Charvat <[email protected]>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller driver.

Signed-off-by: Jan Charvat <[email protected]>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller included into Kconfig.

Signed-off-by: Jan Charvat <[email protected]>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller bringup for DevKitM-1.

Signed-off-by: Jan Charvat <[email protected]>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller config for DevKitM-1.

Signed-off-by: Jan Charvat <[email protected]>

Fixed a compile error, presumably caused by C&P error.

arch/armv[7|8]m: enhance the clang support

Signed-off-by: chao.an <[email protected]>

arch/Toolchain.defs: replace all ${/$} with $(/$)

Signed-off-by: chao.an <[email protected]>

semaphore: fix usage of NXSEM_INITIALIZER

Signed-off-by: Petro Karashchenko <[email protected]>

arch/xtensa: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/ceva: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/sim: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/x86_64: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/or1k: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/misoc: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/mips: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/sparc: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <[email protected]>

arm/arch: using __builtin_frame_address(0) implement up_getsp().

Signed-off-by: wangbowen6 <[email protected]>

arch/arm: Move arm_signal_dispatch.c to common folder

Signed-off-by: Xiang Xiao <[email protected]>

Remove the unneeded worker_t cast

Signed-off-by: Xiang Xiao <[email protected]>

Remove the unneeded void cast

Signed-off-by: Xiang Xiao <[email protected]>

arm/a1x: fix compile break

Signed-off-by: chao.an <[email protected]>

wireless/80211: update the 80211 header

Upstream from:
https://github.com/freebsd/freebsd-src/blob/main/sys/net80211/ieee80211.h

Signed-off-by: chao.an <[email protected]>

sched/environ: Refine the environment variables storage layout

to confirm the standard and then implement get_environ_ptr correctly

Signed-off-by: Xiang Xiao <[email protected]>

libc: Don't duplicate string in chdir and lib_restoredir

since the new layout doesn't reallocate the unchanged environ variable anymore

Signed-off-by: Xiang Xiao <[email protected]>

tools/cibuild.sh: Migrate risc-v toolchian from 8.3.0 to 10.2.0

Signed-off-by: Xiang Xiao <[email protected]>

tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate

untils SiFive update their certification

Signed-off-by: Xiang Xiao <[email protected]>

arch/arm: export arm_saveusercontext()

rename arm_saveusercontext() -> up_arm_saveusercontext()

Signed-off-by: chao.an <[email protected]>

boards/ostest: remove board ostest implement

Signed-off-by: chao.an <[email protected]>

board/arch_fpu*: move arch_[get|cmp]fpu to common arch

rename the arch api:
arch_getfpu  -> up_saveusercontext
arch_cmpfpu  -> up_cmpfpu

Signed-off-by: chao.an <[email protected]>

arch/mips: Remove unneeded group_addrenv call which handled by mips_doirq

Signed-off-by: Xiang Xiao <[email protected]>

arch/misoc: Remove unneeded group_addrenv call which handled by [lm32|minerva]_doirq

Signed-off-by: Xiang Xiao <[email protected]>

arch/xtensa: Remove unneeded group_addrenv call which handled by xtensa_irq_dispatch

Signed-off-by: Xiang Xiao <[email protected]>

arch/sparc: Remove unneeded group_addrenv call which handled by up_doirq

Signed-off-by: Xiang Xiao <[email protected]>

libc/blockstream: add block out stream backend

Signed-off-by: chao.an <[email protected]>

libc/blkoutstream: Minor style fix

Signed-off-by: Xiang Xiao <[email protected]>

arch/arm: Remove unneeded group_addrenv call which handled by arm_doirq

Signed-off-by: Xiang Xiao <[email protected]>

arch/risc-v: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <[email protected]>

arch/arm: Remove FAR and CODE from common/ and arm*/ folder

Signed-off-by: Xiang Xiao <[email protected]>

Revert "tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate"

This reverts commit 3b97e37b525d50d8a78765f85276f900129dade5.

arch/arm: Remove all lazy fpu related code

since it is broken and inefficient, and then removed by:
commit dc961baaea17107109d94575e9bb5d9fb725b801
Author: chao.an <[email protected]>
Date:   Thu Apr 14 18:07:14 2022 +0800

    arm/armv7-[a|r]: move fpu save/restore to assembly handler

    Save/Restore FPU registers in C environment is dangerous practive,
    which cannot guarantee the compiler won't generate the assembly code
    with float point registers, especially in interrupt handling

    Signed-off-by: chao.an <[email protected]>

commit 8d66dbc0680cb81f91674ace814b2b8a94c49cd2
Author: chao.an <[email protected]>
Date:   Thu Apr 7 13:48:04 2022 +0800

    arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

    Signed-off-by: chao.an <[email protected]>

Signed-off-by: Xiang Xiao <[email protected]>

arch/armv[7|8]-m: Compare all FPU registers in up_fpucmp

Signed-off-by: Xiang Xiao <[email protected]>

arch/armv7-[a|r]: correct the handing of group env switch

This PR resolved 2 issues:
1. CURRENT_REGS is not set correctly on swint handling
2. group env is not changed properly

Signed-off-by: chao.an <[email protected]>

fs:oflag need consistent with psock

if don't consistent with psock,call fcntl will have differet flag
Signed-off-by: anjiahao <[email protected]>

arm/arm_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

risc-v/riscv_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

fs:fs_getfilep changes fd judgment method

if a fd was closed,need return EBADF
Signed-off-by: anjiahao <[email protected]>

arch/armv8-m: Unify the toolchain definition of eabi/clang for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/armv7-m: Unify the toolchain definition of eabi/clang/iar for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/arm/armv6-m: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/armv7-a/r: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/risc-v: Unify the toolchain definition of RVG for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/misoc: Unify the toolchain definition of GNU for linux and windows

Signed-off-by: chao.an <[email protected]>

arch/z80: Unify the toolchain definition of SDCC for linux and windows

Signed-off-by: chao.an <[email protected]>

armv7/r:cp15_cache_all: fix error in LineSize 'r5' mask

r5 = r3 & r1

Signed-off-by: zhuyanlin <[email protected]>

arch/sparc,xtensa: Control output by $(Q) as other arch

Signed-off-by: Huang Qi <[email protected]>

LICENSE: document missing armv7-x files

add missing armv7-a/armv7-r files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing lpc files

add missing lpc files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing samdxxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing am335x files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: cxd56xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: imxrt: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: lpc43xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: phy62xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: stm32l4: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing tiva files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: mor1kx: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing mor1k files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: sama5: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

arch: arm: stm32: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

boards: sim: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

drivers: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing mtd files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

drivers: mtd: gd5f: migrate the license to Apache

Xiaomi has submitted the SGA
as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <[email protected]>

drivers: sensors: mlx90614: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing bcm43xxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing nfs files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

include: himem: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <[email protected]>

include: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing uIP files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing bluetooth files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

include: wireless: bluetooth: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing sixlowpan files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing igmp files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing wireless files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

LICENSE: document missing libc files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <[email protected]>

arch/risc-v: Change riscv_savefpu/riscv_loadfpu to macro

Signed-off-by: Huang Qi <[email protected]>

arch/armv6-m: add support of LLVM Clang

Signed-off-by: chao.an <[email protected]>

arch/clang: add support for Clang LTO

add support of Clang's Link Time Optimization (LTO) on NuttX build system

Reference:
https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
https://llvm.org/docs/LinkTimeOptimization.html

Signed-off-by: chao.an <[email protected]>

arch/xtensa: Use syscall interface for xtensa_save/restore_context.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch.h: Fix up_exit prototype.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch/xtensa: Move xtensa_save_context to up_saveusercontext for
consistency with other archs.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arm/armv[7|8]m: compare of hardware fp registers should skip REG_FP_RESERVED

Fix fpu test break

Signed-off-by: chao.an <[email protected]>

arch/risc-v: Don't clear reserved bits in fcsr in riscv_fpuconfig

Signed-off-by: Huang Qi <[email protected]>

pipe: Increase buffer size by one byte to ompensate the full indicator

Signed-off-by: Xiang Xiao <[email protected]>

boards/sim: support rc.sysinit

Follow: http://glennastory.net/boot/sysinit.html

This is first script that init runs is rc.sysinit. This
script does serval initialization tasks about basic service.

The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(Peripherals driver, core driver, ...)->
	run rcS script(mount fs, run service) ->
	    board_appinitialize->

After this patch:
The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(core driver,...)->
	run rc.sysinit script(mount fs, run core service) ->
	    board_appinitialize(Peripherals driver)->
		run rcS script(run other service)->

So, Peripheral drivers can do more with the file system and
core services.

Signed-off-by: Jiuzhu Dong <[email protected]>

arch/arm: Switch the context of save and restore from assembler to c

Signed-off-by: Xiang Xiao <[email protected]>

arch/arm: Move the duplicated assembly code to common folder

Signed-off-by: Xiang Xiao <[email protected]>

binfmt_execmodule: add errout_with_args exit point

Ensures that when errout_xx is taken, args are freed

env_dup: Fix copying of env between address environments

If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.

syscall: Add call gate for get_environ_ptr

Now that the environment strings are stored as an array of strings,
they can be passed from the application via char **environ, which
is really defined as a function call to get_environ_ptr().

This works as is for flat build, but protected mode and kernel mode
require a call gate, which is added here.

binfmt_execmodule: If incoming envp is NULL get parent envp

This keeps backwards compatibility with apps that do not provide
envp. The old implementation passes NULL always and this change fixes
any regression caused by it.

assert: static_assert is not support in c standard C89,C99.

Signed-off-by: wangbowen6 <[email protected]>

arch/xtensa: Color the other CPUs task when they are created.

Signed-off-by: Abdelatif Guettouche <[email protected]>

compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS

Enable this option to optimization the unused input sections with the
linker by compiling with " -ffunction-sections -fdata-sections ", and
linking with " --gc-sections ".

Signed-off-by: chao.an <[email protected]>

compile/opt: add config DEBUG_LINK_MAP

Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld
when linking NuttX ELF. That file can be useful for verifying
and debugging magic section games, and for seeing which
pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS.

Signed-off-by: chao.an <[email protected]>

arch/risc-v: Enable FPU for K210

K210 support rv64gc ISA, now we enable F/D extension for it.

Note: QEMU for K210 don't support FPU now.

Signed-off-by: Huang Qi <[email protected]>

sched/task: Correct the comment about environment variable

Signed-off-by: Xiang Xiao <[email protected]>

sched/environ: Remove the unneeded cast in env_dup

Signed-off-by: Xiang Xiao <[email protected]>

sched/environ: Replace get_environ_ptr with environ

Signed-off-by: Xiang Xiao <[email protected]>

environ: Don't expose get_environ_ptr in csdlib

since it isn't defined in c/c++ standard

Signed-off-by: Xiang Xiao <[email protected]>

arch/risc-v/riscv_misaligned: Implement float load/store support

Signed-off-by: Huang Qi <[email protected]>

arch: risc-v: Do not enable FPU for K210 with QEMU

Summary:
- I noticed that maix-bit:smp does not work with QEMU.
- Actually, QEMU supports sifive_u (not K210) but it works
  if FPU is disabled.
- This commit fixes this issue.

Impact:
- K210 with QEMU only

Testing:
- Tested with qemu-5.2

Signed-off-by: Masayuki Ishikawa <[email protected]>

sched/task: Implement execle and execve

Signed-off-by: Xiang Xiao <[email protected]>

libc: Implement execvp, execlp and execvpe as macro

Signed-off-by: Xiang Xiao <[email protected]>

libc: Fix typo error in execle

Signed-off-by: Xiang Xiao <[email protected]>

syscall: Fix prototype of exec() to syscall.csv

pm: Move pm_initialize call from driver_initialize to xxx_pminitialize

since it's too late with the below commit:
ommit a594a5d7a8dcd756884ca7d3449f37ba77f96af3
Author: chao.an <[email protected]>
Date:   Mon Apr 11 19:44:26 2022 +0800

    sched/init: drivers_initialize() should be late than up_initialize()

    up_initialize
    |
     ->up_serialinit
       |
        ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

    drivers_initialize
    |
     ->syslog_console_init
       |
        ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: Xiang Xiao <[email protected]>

sched: remove DEBUGASSERT from nx_waitpid

Signed-off-by: Petro Karashchenko <[email protected]>

xtensa_user_handler.S: Use the `ps_setup` macro when dealing with an
exception.

Signed-off-by: Abdelatif Guettouche <[email protected]>

xtensa_user_handler.S: Fix backtrace.

Signed-off-by: Abdelatif Guettouche <[email protected]>

arch/xtensa: No need to save SP in EXCSAVE_1 when linking the interrupt
frame with the previous frame.  The SP is already saved in A12.

Signed-off-by: Abdelatif Guettouche <[email protected]>

boards/boardctl: correct boarctl return value

Summary:
- Correct boardctl function's return value
- In case of BOARDIOC_TESTSET, `ret' has 0 or 1 or an error,
  but `ret' is ignored except error.

Impact:
- boardctl return value except errors

Testing:
- custom Cortex-A9 board

Signed-off-by: Oki Minabe <[email protected]>

libc/string: strcmp/strncmp cast unsigned char

Summary:
- Cast to unsigned char for strcmp and strncmp
- strcmp and strncmp are described following by opengroup.org

  The sign of a non-zero return value shall be determined by the sign
  of the difference between the values of the first pair of bytes
  (both interpreted as type unsigned char) that differ in the strings
  being compared.

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html

Impact:
- strcmp and strncmp return value

Testing:
- ostest on sabre-6quad:smp w/ qemu

Signed-off-by: Oki Minabe <[email protected]>

compiler.h: optimization option is not supported before GCC 4.6

-fno-tree-loop-distribute-patterns is not supported before
GCC 4.6

Signed-off-by: wangbowen6 <[email protected]>

libs/libc/string: unify implementation across the functions

Signed-off-by: Petro Karashchenko <[email protected]>

tools:fix parsememdump.py match error

Signed-off-by: anjiahao <[email protected]>

libc/fixedmatch: Avoid "divide by zero" error

Signed-off-by: Xiang Xiao <xiaoxia…
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info() unifies
lib_stream_* with life cycle of task info to avoid this issue.

|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info() unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Jan 10, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Mar 8, 2023
tg_info is still in use after task_uninit_info(), unifies
lib_stream_* with life cycle of task info to avoid this issue.

| ==1940861==ERROR: AddressSanitizer: heap-use-after-free on address 0xf47032e0 at pc 0x5676dc4f bp 0xf2f38c68 sp 0xf2f38c58
|
|apache#10 0xf7abec89 in __asan::__asan_report_load2 (addr=4100993760) at ../../../../src/libsanitizer/asan/asan_rtl.cpp:119
|apache#11 0x5677356a in nxsem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:73
|apache#12 0x56773695 in sem_destroy (sem=0xf47032e0) at semaphore/sem_destroy.c:120
|apache#13 0x5676faa2 in nxmutex_destroy (mutex=0xf47032e0) at include/nuttx/mutex.h:126
|apache#14 0x567a3430 in lib_stream_release (group=0xf4901ba0) at stdio/lib_libstream.c:98
|apache#15 0x5676da75 in group_release (group=0xf4901ba0) at group/group_leave.c:162
|apache#16 0x5676e51c in group_leave (tcb=0xf5377740) at group/group_leave.c:360
|apache#17 0x569fe79b in nxtask_exithook (tcb=0xf5377740, status=0) at task/task_exithook.c:455
|apache#18 0x569f90b9 in _exit (status=0) at task/exit.c:82
|apache#19 0x56742680 in exit (status=0) at stdlib/lib_exit.c:61
|apache#20 0x56a69c78 in iperf_showusage (progname=0xf2f28838 "iperf", exitcode=0) at iperf_main.c:91
|apache#21 0x56a6a6ec in iperf_main (argc=1, argv=0xf2f28830) at iperf_main.c:140
|apache#22 0x5679c148 in nxtask_startup (entrypt=0x56a69c78 <iperf_main>, argc=1, argv=0xf2f28830) at sched/task_startup.c:70
|apache#23 0x56767f58 in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Aug 1, 2023
- add  pwm driver
Signed-off-by: Runcheng Lu <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Nov 6, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Change-Id: I6996b4f7891e9e4452f3182f42360b66bdbc2d4c
Signed-off-by: chao an <[email protected]>
anchao added a commit to anchao/nuttx that referenced this pull request Nov 6, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Nov 7, 2023
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| #7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| #8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| #9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| #10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| #11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| #12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| #13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| #14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| #15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| #16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| #17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
freakishness pushed a commit to freakishness/incubator-nuttx that referenced this pull request Feb 18, 2024
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| #1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| #2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| #3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| #4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| #5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| #6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
chenzhihong007 pushed a commit to hpmicro/nuttx that referenced this pull request Feb 23, 2024
- add  pwm driver
Signed-off-by: Runcheng Lu <[email protected]>
halyssonJr pushed a commit to halyssonJr/nuttx that referenced this pull request Apr 10, 2024
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| apache#1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| apache#2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| apache#3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| apache#4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| apache#5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| apache#6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
nealef pushed a commit to nealef/nuttx that referenced this pull request May 29, 2024
Race condition if the remote proc is stoped during initialization phase

| #0  0x0249f959 in rpmsg_destroy_ept (ept=0xffffffc0) at open-amp/lib/rpmsg/rpmsg.c:376
| apache#1  0x024a938c in rpmsg_deinit_vdev (rvdev=0xf2303a48) at open-amp/lib/rpmsg/rpmsg_virtio.c:971
| apache#2  0x02117e33 in rptun_dev_stop (rproc=0xf2303a04, stop_ns=true) at rptun/rptun.c:891
| apache#3  0x021181d8 in rptun_do_ioctl (priv=0xf2303a00, cmd=11010, arg=0) at rptun/rptun.c:922
| apache#4  0x02119722 in rptun_ioctl_foreach (cpuname=0x0, cmd=11010, value=0) at rptun/rptun.c:1086
| apache#5  0x0211b9df in rptun_poweroff (cpuname=0x0) at rptun/rptun.c:1378
| apache#6  0x02053aa6 in board_power_off (status=0) at sim/sim_head.c:206
| apache#7  0x0253d65c in boardctl (cmd=65283, arg=0) at boardctl.c:400
| apache#8  0x021eb497 in cmd_poweroff (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_syscmds.c:356
| apache#9  0x021cdb4d in nsh_command (vtbl=0xef606280, argc=1, argv=0xef9b73e0) at nsh_command.c:1164
| apache#10 0x021baa72 in nsh_execute (vtbl=0xef606280, argc=1, argv=0xef9b73e0, redirfile=0x0, oflags=0) at nsh_parse.c:845
| apache#11 0x021c6b0a in nsh_parse_command (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2744
| apache#12 0x021c7166 in nsh_parse (vtbl=0xef606280, cmdline=0xef606708 "poweroff") at nsh_parse.c:2828
| apache#13 0x0221fa2f in nsh_session (pstate=0xef606280, login=1, argc=1, argv=0xef7a7860) at nsh_session.c:245
| apache#14 0x021f8c04 in nsh_consolemain (argc=1, argv=0xef7a7860) at nsh_consolemain.c:75
| apache#15 0x021b77eb in nsh_main (argc=1, argv=0xef7a7860) at nsh_main.c:74
| apache#16 0x02166ddf in nxtask_startup (entrypt=0x21b76ca <nsh_main>, argc=1, argv=0xef7a7860) at sched/task_startup.c:70
| apache#17 0x020b363c in nxtask_start () at task/task_start.c:134

Signed-off-by: chao an <[email protected]>
jasonbu pushed a commit to jasonbu/nuttx that referenced this pull request Sep 27, 2024
ap> cat pm
=================================================================
==30235==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf436edd9 at pc 0x03338a48 bp 0x9d1b6ca8 sp 0x9d1b6c98
READ of size 1 at 0xf436edd9 thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    apache#1 0x371af87 in pm_get_file_index power/pm/pm_procfs.c:174
    apache#2 0x371b066 in pm_open power/pm/pm_procfs.c:207
    apache#3 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    apache#4 0x359bce2 in file_vopen vfs/fs_open.c:240
    apache#5 0x359c431 in nx_vopen vfs/fs_open.c:312
    apache#6 0x359cb53 in open vfs/fs_open.c:465
    apache#7 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    apache#8 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    apache#9 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    apache#10 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    apache#11 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    apache#12 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    apache#13 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    apache#14 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    apache#15 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    apache#16 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    apache#17 0x323ec3f in nxtask_start task/task_start.c:134
    apache#18 0x33636ea in pre_start sim/sim_initialstate.c:52

ap> cat net
=================================================================
==30303==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4479a5a at pc 0x03338a48 bp 0x9d2b6ce8 sp 0x9d2b6cd8
READ of size 1 at 0xf4479a5a thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    apache#1 0x5395d62 in netprocfs_open procfs/net_procfs.c:215
    apache#2 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    apache#3 0x359bce2 in file_vopen vfs/fs_open.c:240
    apache#4 0x359c431 in nx_vopen vfs/fs_open.c:312
    apache#5 0x359cb53 in open vfs/fs_open.c:465
    apache#6 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    apache#7 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    apache#8 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    apache#9 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    apache#10 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    apache#11 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    apache#12 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    apache#13 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    apache#14 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    apache#15 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    apache#16 0x323ec3f in nxtask_start task/task_start.c:134
    apache#17 0x33636ea in pre_start sim/sim_initialstate.c:52

Signed-off-by: dulibo1 <[email protected]>
Signed-off-by: buxiasen <[email protected]>
extinguish added a commit to extinguish/nuttx that referenced this pull request Sep 27, 2024
: && cxarm cr arch/libarch_interface.a  arch/CMakeFiles/arch_interface.dir/arm/src/common/gnu/arm_signal_handler.S.obj  && echo arch/libarch_interface.a && :
[elxr] (error apache#16) cannot find file cr

Signed-off-by: guoshichao <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Sep 27, 2024
ap> cat pm
=================================================================
==30235==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf436edd9 at pc 0x03338a48 bp 0x9d1b6ca8 sp 0x9d1b6c98
READ of size 1 at 0xf436edd9 thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x371af87 in pm_get_file_index power/pm/pm_procfs.c:174
    #2 0x371b066 in pm_open power/pm/pm_procfs.c:207
    #3 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    #4 0x359bce2 in file_vopen vfs/fs_open.c:240
    #5 0x359c431 in nx_vopen vfs/fs_open.c:312
    #6 0x359cb53 in open vfs/fs_open.c:465
    #7 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    #8 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    #9 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    #10 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    #11 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    #12 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    #13 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    #14 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    #15 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    #16 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    #17 0x323ec3f in nxtask_start task/task_start.c:134
    #18 0x33636ea in pre_start sim/sim_initialstate.c:52

ap> cat net
=================================================================
==30303==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4479a5a at pc 0x03338a48 bp 0x9d2b6ce8 sp 0x9d2b6cd8
READ of size 1 at 0xf4479a5a thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x5395d62 in netprocfs_open procfs/net_procfs.c:215
    #2 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    #3 0x359bce2 in file_vopen vfs/fs_open.c:240
    #4 0x359c431 in nx_vopen vfs/fs_open.c:312
    #5 0x359cb53 in open vfs/fs_open.c:465
    #6 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    #7 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    #8 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    #9 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    #10 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    #11 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    #12 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    #13 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    #14 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    #15 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    #16 0x323ec3f in nxtask_start task/task_start.c:134
    #17 0x33636ea in pre_start sim/sim_initialstate.c:52

Signed-off-by: dulibo1 <[email protected]>
Signed-off-by: buxiasen <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Sep 27, 2024
: && cxarm cr arch/libarch_interface.a  arch/CMakeFiles/arch_interface.dir/arm/src/common/gnu/arm_signal_handler.S.obj  && echo arch/libarch_interface.a && :
[elxr] (error #16) cannot find file cr

Signed-off-by: guoshichao <[email protected]>
kywwilson11 pushed a commit to kywwilson11/nuttx that referenced this pull request Sep 30, 2024
ap> cat pm
=================================================================
==30235==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf436edd9 at pc 0x03338a48 bp 0x9d1b6ca8 sp 0x9d1b6c98
READ of size 1 at 0xf436edd9 thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x371af87 in pm_get_file_index power/pm/pm_procfs.c:174
    apache#2 0x371b066 in pm_open power/pm/pm_procfs.c:207
    apache#3 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    apache#4 0x359bce2 in file_vopen vfs/fs_open.c:240
    apache#5 0x359c431 in nx_vopen vfs/fs_open.c:312
    apache#6 0x359cb53 in open vfs/fs_open.c:465
    apache#7 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    apache#8 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    apache#9 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    apache#10 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    apache#11 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    apache#12 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    apache#13 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    apache#14 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    apache#15 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    apache#16 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    apache#17 0x323ec3f in nxtask_start task/task_start.c:134
    apache#18 0x33636ea in pre_start sim/sim_initialstate.c:52

ap> cat net
=================================================================
==30303==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4479a5a at pc 0x03338a48 bp 0x9d2b6ce8 sp 0x9d2b6cd8
READ of size 1 at 0xf4479a5a thread T0
    #0 0x3338a47 in strncmp string/lib_strncmp.c:42
    #1 0x5395d62 in netprocfs_open procfs/net_procfs.c:215
    apache#2 0x3640d20 in procfs_open procfs/fs_procfs.c:419
    apache#3 0x359bce2 in file_vopen vfs/fs_open.c:240
    apache#4 0x359c431 in nx_vopen vfs/fs_open.c:312
    apache#5 0x359cb53 in open vfs/fs_open.c:465
    apache#6 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140
    apache#7 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556
    apache#8 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164
    apache#9 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845
    apache#10 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744
    apache#11 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828
    apache#12 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245
    apache#13 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75
    apache#14 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74
    apache#15 0x332b6e6 in nxtask_startup sched/task_startup.c:70
    apache#16 0x323ec3f in nxtask_start task/task_start.c:134
    apache#17 0x33636ea in pre_start sim/sim_initialstate.c:52

Signed-off-by: dulibo1 <[email protected]>
Signed-off-by: buxiasen <[email protected]>
kywwilson11 pushed a commit to kywwilson11/nuttx that referenced this pull request Sep 30, 2024
: && cxarm cr arch/libarch_interface.a  arch/CMakeFiles/arch_interface.dir/arm/src/common/gnu/arm_signal_handler.S.obj  && echo arch/libarch_interface.a && :
[elxr] (error apache#16) cannot find file cr

Signed-off-by: guoshichao <[email protected]>
pwnall pushed a commit to pwnall/nuttx that referenced this pull request Oct 23, 2024
Deadlock during recursive access if unionfs overlays procfs,
check the critical segment only and remove the useless protection part.

|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
...
|apache#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026

original call stack:
(gdb) bt
|#0  unionfs_statfs (mountpt=0xf3df4540, buf=0xf3de2f0c) at unionfs/fs_unionfs.c:2136
|apache#1  0x08071629 in mountpoint_filter (node=0xf3df4540, dirpath=0xf3df4a28 "/proc", arg=0xf3de2fc4) at mount/fs_foreachmountpoint.c:119
|apache#2  0x0807171b in foreach_inodelevel (node=0xf3df4540, info=0xf3df4a20) at inode/fs_foreachinode.c:90
|apache#3  0x08071898 in foreach_inode (handler=0x8071530 <mountpoint_filter>, arg=0xf3de2fc4) at inode/fs_foreachinode.c:193
|apache#4  0x080716c1 in foreach_mountpoint (handler=0x8070e2f <blocks_entry>, arg=0xf3de300c) at mount/fs_foreachmountpoint.c:169
|apache#5  0x08071399 in mount_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at mount/fs_procfs_mount.c:537
|apache#6  0x08069429 in procfs_read (filep=0xf3df4574, buffer=0xf3df4610 "...", buflen=1024) at procfs/fs_procfs.c:412
|apache#7  0x0806c339 in unionfs_read (filep=0xf3de219c, buffer=0xf3df4610 "...", buflen=1024) at unionfs/fs_unionfs.c:1026
|apache#8  0x080657a2 in file_read (filep=0xf3de219c, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:110
|apache#9  0x0806581a in nx_read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:175
|apache#10 0x08065847 in read (fd=3, buf=0xf3df4610, nbytes=1024) at vfs/fs_read.c:206
|apache#11 0x0805a242 in nsh_catfile (vtbl=0xf3df3f10, cmd=0xf3df4378 "df", filepath=0x808d5ed "/proc/fs/blocks") at nsh_fsutils.c:116
|apache#12 0x0805b1de in cmd_df (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_mntcmds.c:73
|apache#13 0x08056370 in nsh_command (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0) at nsh_command.c:1061
|apache#14 0x08053b16 in nsh_execute (vtbl=0xf3df3f10, argc=1, argv=0xf3de32c0, redirfile=0x0, oflags=0) at nsh_parse.c:741
|apache#15 0x08055998 in nsh_parse_command (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2578
|apache#16 0x08055a7b in nsh_parse (vtbl=0xf3df3f10, cmdline=0xf3df4378 "df") at nsh_parse.c:2662
|apache#17 0x0805d691 in nsh_session (pstate=0xf3df3f10, login=1 '\001', argc=1, argv=0xf3de34b0) at nsh_session.c:191
|apache#18 0x0805b542 in nsh_consolemain (argc=1, argv=0xf3de34b0) at nsh_consolemain.c:115
|apache#19 0x0805346c in nsh_main (argc=1, argv=0xf3de34b0) at nsh_main.c:168
|apache#20 0x0805075a in nxtask_startup (entrypt=0x805340a <nsh_main>, argc=1, argv=0xf3de34b0) at sched/task_startup.c:165
|apache#21 0x08049713 in nxtask_start () at task/task_start.c:144
|apache#22 0x00000000 in ?? ()

Change-Id: Ic4c7aff0ea50388a371c525745e817a787dabcca
Signed-off-by: chao.an <[email protected]>
zhhyu7 added a commit to zhhyu7/incubator-nuttx that referenced this pull request Oct 29, 2024
current sizeof(struct sockaddr_in) is 66

arp/arp_table.c:241:28: runtime error: member access within misaligned address 0xe5f134e6 for type 'struct sockaddr_in', which requires 4 byte alignment
0xe5f134e6: note: pointer points here
 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00
             ^
    #0 0x543287c1 in arp_get_arpreq arp/arp_table.c:241
    #1 0x5432a11f in arp_snapshot arp/arp_table.c:574
    #2 0x5435f0be in netlink_fill_arptable netlink/netlink_route.c:547
    apache#3 0x5435ffca in netlink_get_neighbor netlink/netlink_route.c:715
    apache#4 0x54360116 in netlink_get_neighborlist netlink/netlink_route.c:743
    apache#5 0x54363b20 in netlink_route_sendto netlink/netlink_route.c:1382
    apache#6 0x542ef1b1 in netlink_sendmsg netlink/netlink_sockif.c:625
    apache#7 0x542be94d in psock_sendmsg socket/sendmsg.c:96
    apache#8 0x542bc94b in psock_sendto socket/sendto.c:134
    apache#9 0x542bcb28 in sendto socket/sendto.c:247
    apache#10 0x542bc5ea in send socket/send.c:163
    apache#11 0x542aa715 in netlib_get_arptable /home/mi/gaofengzhi/code/dev1025/apps/netutils/netlib/netlib_getarptab.c:152
    apache#12 0x54279109 in cmd_arp /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_netcmds.c:1197
    apache#13 0x54257faf in nsh_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_command.c:1263
    apache#14 0x54231982 in nsh_execute /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:718
    apache#15 0x5423da42 in nsh_parse_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2619
    apache#16 0x5423e12a in nsh_parse /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2706
    apache#17 0x5424088f in nsh_session /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_session.c:245
    apache#18 0x5422efc9 in nsh_consolemain /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_consolemain.c:75
    apache#19 0x5419e89f in nsh_main /home/mi/gaofengzhi/code/dev1025/apps/system/nsh/nsh_main.c:74
    apache#20 0x54067ee1 in nxtask_startup sched/task_startup.c:70
    apache#21 0x53f366c6 in nxtask_start task/task_start.c:116
    apache#22 0x5409e1a4 in pre_start sim/sim_initialstate.c:52

Signed-off-by: zhanghongyu <[email protected]>
zhhyu7 added a commit to zhhyu7/incubator-nuttx that referenced this pull request Oct 29, 2024
current sizeof(struct sockaddr_in) is 66

arp/arp_table.c:241:28: runtime error: member access within misaligned address 0xe5f134e6 for type 'struct sockaddr_in', which requires 4 byte alignment
0xe5f134e6: note: pointer points here
 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00
             ^
    #0 0x543287c1 in arp_get_arpreq arp/arp_table.c:241
    #1 0x5432a11f in arp_snapshot arp/arp_table.c:574
    #2 0x5435f0be in netlink_fill_arptable netlink/netlink_route.c:547
    apache#3 0x5435ffca in netlink_get_neighbor netlink/netlink_route.c:715
    apache#4 0x54360116 in netlink_get_neighborlist netlink/netlink_route.c:743
    apache#5 0x54363b20 in netlink_route_sendto netlink/netlink_route.c:1382
    apache#6 0x542ef1b1 in netlink_sendmsg netlink/netlink_sockif.c:625
    apache#7 0x542be94d in psock_sendmsg socket/sendmsg.c:96
    apache#8 0x542bc94b in psock_sendto socket/sendto.c:134
    apache#9 0x542bcb28 in sendto socket/sendto.c:247
    apache#10 0x542bc5ea in send socket/send.c:163
    apache#11 0x542aa715 in netlib_get_arptable /home/mi/gaofengzhi/code/dev1025/apps/netutils/netlib/netlib_getarptab.c:152
    apache#12 0x54279109 in cmd_arp /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_netcmds.c:1197
    apache#13 0x54257faf in nsh_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_command.c:1263
    apache#14 0x54231982 in nsh_execute /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:718
    apache#15 0x5423da42 in nsh_parse_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2619
    apache#16 0x5423e12a in nsh_parse /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2706
    apache#17 0x5424088f in nsh_session /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_session.c:245
    apache#18 0x5422efc9 in nsh_consolemain /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_consolemain.c:75
    apache#19 0x5419e89f in nsh_main /home/mi/gaofengzhi/code/dev1025/apps/system/nsh/nsh_main.c:74
    apache#20 0x54067ee1 in nxtask_startup sched/task_startup.c:70
    apache#21 0x53f366c6 in nxtask_start task/task_start.c:116
    apache#22 0x5409e1a4 in pre_start sim/sim_initialstate.c:52

Signed-off-by: zhanghongyu <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Oct 29, 2024
current sizeof(struct sockaddr_in) is 66

arp/arp_table.c:241:28: runtime error: member access within misaligned address 0xe5f134e6 for type 'struct sockaddr_in', which requires 4 byte alignment
0xe5f134e6: note: pointer points here
 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00
             ^
    #0 0x543287c1 in arp_get_arpreq arp/arp_table.c:241
    #1 0x5432a11f in arp_snapshot arp/arp_table.c:574
    #2 0x5435f0be in netlink_fill_arptable netlink/netlink_route.c:547
    #3 0x5435ffca in netlink_get_neighbor netlink/netlink_route.c:715
    #4 0x54360116 in netlink_get_neighborlist netlink/netlink_route.c:743
    #5 0x54363b20 in netlink_route_sendto netlink/netlink_route.c:1382
    #6 0x542ef1b1 in netlink_sendmsg netlink/netlink_sockif.c:625
    #7 0x542be94d in psock_sendmsg socket/sendmsg.c:96
    #8 0x542bc94b in psock_sendto socket/sendto.c:134
    #9 0x542bcb28 in sendto socket/sendto.c:247
    #10 0x542bc5ea in send socket/send.c:163
    #11 0x542aa715 in netlib_get_arptable /home/mi/gaofengzhi/code/dev1025/apps/netutils/netlib/netlib_getarptab.c:152
    #12 0x54279109 in cmd_arp /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_netcmds.c:1197
    #13 0x54257faf in nsh_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_command.c:1263
    #14 0x54231982 in nsh_execute /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:718
    #15 0x5423da42 in nsh_parse_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2619
    #16 0x5423e12a in nsh_parse /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2706
    #17 0x5424088f in nsh_session /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_session.c:245
    #18 0x5422efc9 in nsh_consolemain /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_consolemain.c:75
    #19 0x5419e89f in nsh_main /home/mi/gaofengzhi/code/dev1025/apps/system/nsh/nsh_main.c:74
    #20 0x54067ee1 in nxtask_startup sched/task_startup.c:70
    #21 0x53f366c6 in nxtask_start task/task_start.c:116
    #22 0x5409e1a4 in pre_start sim/sim_initialstate.c:52

Signed-off-by: zhanghongyu <[email protected]>
JaeheeKwon pushed a commit to JaeheeKwon/nuttx that referenced this pull request Nov 28, 2024
current sizeof(struct sockaddr_in) is 66

arp/arp_table.c:241:28: runtime error: member access within misaligned address 0xe5f134e6 for type 'struct sockaddr_in', which requires 4 byte alignment
0xe5f134e6: note: pointer points here
 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00
             ^
    #0 0x543287c1 in arp_get_arpreq arp/arp_table.c:241
    apache#1 0x5432a11f in arp_snapshot arp/arp_table.c:574
    apache#2 0x5435f0be in netlink_fill_arptable netlink/netlink_route.c:547
    apache#3 0x5435ffca in netlink_get_neighbor netlink/netlink_route.c:715
    apache#4 0x54360116 in netlink_get_neighborlist netlink/netlink_route.c:743
    apache#5 0x54363b20 in netlink_route_sendto netlink/netlink_route.c:1382
    apache#6 0x542ef1b1 in netlink_sendmsg netlink/netlink_sockif.c:625
    apache#7 0x542be94d in psock_sendmsg socket/sendmsg.c:96
    apache#8 0x542bc94b in psock_sendto socket/sendto.c:134
    apache#9 0x542bcb28 in sendto socket/sendto.c:247
    apache#10 0x542bc5ea in send socket/send.c:163
    apache#11 0x542aa715 in netlib_get_arptable /home/mi/gaofengzhi/code/dev1025/apps/netutils/netlib/netlib_getarptab.c:152
    apache#12 0x54279109 in cmd_arp /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_netcmds.c:1197
    apache#13 0x54257faf in nsh_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_command.c:1263
    apache#14 0x54231982 in nsh_execute /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:718
    apache#15 0x5423da42 in nsh_parse_command /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2619
    apache#16 0x5423e12a in nsh_parse /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_parse.c:2706
    apache#17 0x5424088f in nsh_session /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_session.c:245
    apache#18 0x5422efc9 in nsh_consolemain /home/mi/gaofengzhi/code/dev1025/apps/nshlib/nsh_consolemain.c:75
    apache#19 0x5419e89f in nsh_main /home/mi/gaofengzhi/code/dev1025/apps/system/nsh/nsh_main.c:74
    apache#20 0x54067ee1 in nxtask_startup sched/task_startup.c:70
    apache#21 0x53f366c6 in nxtask_start task/task_start.c:116
    apache#22 0x5409e1a4 in pre_start sim/sim_initialstate.c:52

Signed-off-by: zhanghongyu <[email protected]>
anjiahao1 added a commit to anjiahao1/nuttx that referenced this pull request Dec 16, 2024
test code hello_main

int main(int argc, FAR char *argv[])
{
  uint32_t *p = 0xdeedbeff;
  *p = 0xffffff;

  printf("%p\n %x\n", p, *p);
  return 0;
}

qemu mps3-an547 hello_main :
Triggering an exception, and gdb backtrace is:

before:
(gdb) bt
/#0  0x0001168a in systick_getstatus (lower_=0x100010c <g_systick_lower>, status=0x1000a30 <g_intstackalloc+1600>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:142
/#1  0x000122f4 in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/#2  0x0001234c in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/apache#3  0x000124bc in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/apache#4  0x0001249e in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/apache#5  0x0000920c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:830
/apache#6  0x0000937c in _assert (filename=0x393f8 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x393f0 "panic", regs=0x1008500)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:940
/apache#7  0x00000e2c in arm_busfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/apache#8  0x000012d2 in arm_hardfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/apache#9  0x00008b20 in irq_dispatch (irq=3, context=0x1008500) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/apache#10 0x0000041a in arm_doirq (irq=3, regs=0x1008500) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:103
/apache#11 0x0000034e in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:224

after:
(gdb) bt
/#0  systick_is_running () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:106
/#1  0x000125c0 in systick_getstatus (lower_=0x1000114 <g_systick_lower>, status=0x1007a20)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:141
/#2  0x0001323c in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/apache#3  0x00013294 in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/apache#4  0x00013404 in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/apache#5  0x000133e6 in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/apache#6  0x00008c5c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#7  0x00008e88 in _assert (filename=0x39408 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x39400 "panic", regs=0x1007cf0)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#8  0x00000ce4 in arm_busfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/apache#9  0x0000118a in arm_hardfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/apache#10 0x000086cc in irq_dispatch (irq=3, context=0x1007cf0) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/apache#11 0x0000041e in arm_doirq (irq=3, regs=0x1007cf0) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:99
/apache#12 0x00000360 in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:230
/apache#13 0x00027a8c in hello_main (argc=1, argv=0x1006e20) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:39
/apache#14 0x00014968 in nxtask_startup (entrypt=0x27a7d <hello_main>, argc=1, argv=0x1006e20)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/apache#15 0x0000f450 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/apache#16 0x00000000 in ?? ()
(gdb)

qemu armv7a nsh, hello_main:

before:
(gdb) bt
/#0  udelay_coarse (microseconds=156000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c630 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/apache#3  0x0060c644 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/apache#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#6  0x0060bd74 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/apache#7  0x0060bc04 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:438
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

after:
(gdb) bt
/#0  udelay_coarse (microseconds=192000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c650 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/apache#3  0x0060c664 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/apache#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#6  0x0060bd94 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/apache#7  0x0060bc08 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:453
/apache#8  0x00620cd4 in hello_main (argc=4999, argv=0x0) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:41
/apache#9  0x0060d320 in nxtask_startup (entrypt=0x620cc4 <hello_main>, argc=1, argv=0x4020a088)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/apache#10 0x00609b50 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/apache#11 0x00000000 in ?? ()

qemu risc-v nsh

before:

(gdb) bt
/#0  udelay_coarse (microseconds=228000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/apache#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/apache#4  0x80011f1c in reset_board () at misc/assert.c:813
/apache#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/apache#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/apache#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/apache#8  0x80000164 in exception_common () at common/riscv_exception_common.S:210
Backtrace stopped: frame did not save the PC
(gdb)

after

(gdb) bt
/#0  0x80003922 in udelay_coarse (microseconds=90000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/apache#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/apache#4  0x80011f2a in reset_board () at misc/assert.c:816
/apache#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/apache#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/apache#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/apache#8  0x80000166 in exception_common () at common/riscv_exception_common.S:215
/apache#9  0x8001792a in hello_main (argc=<optimized out>, argv=<optimized out>) at hello_main.c:41
/apache#10 0x80004b52 in nxtask_startup (entrypt=0x80030704, argc=1, argv=0x800300e8) at sched/task_startup.c:72
/apache#11 0x80001e72 in nxtask_start () at task/task_start.c:116
/apache#12 0x00000000 in ?? ()
Backtrace stopped: frame did not save the PC
(gdb)

Signed-off-by: anjiahao <[email protected]>
anjiahao1 added a commit to anjiahao1/nuttx that referenced this pull request Dec 17, 2024
test code hello_main

int main(int argc, FAR char *argv[])
{
  uint32_t *p = 0xdeedbeff;
  *p = 0xffffff;

  printf("%p\n %x\n", p, *p);
  return 0;
}

qemu mps3-an547 hello_main :
Triggering an exception, and gdb backtrace is:

before:
(gdb) bt
/#0  0x0001168a in systick_getstatus (lower_=0x100010c <g_systick_lower>, status=0x1000a30 <g_intstackalloc+1600>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:142
/#1  0x000122f4 in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/#2  0x0001234c in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/apache#3  0x000124bc in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/apache#4  0x0001249e in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/apache#5  0x0000920c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:830
/apache#6  0x0000937c in _assert (filename=0x393f8 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x393f0 "panic", regs=0x1008500)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:940
/apache#7  0x00000e2c in arm_busfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/apache#8  0x000012d2 in arm_hardfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/apache#9  0x00008b20 in irq_dispatch (irq=3, context=0x1008500) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/apache#10 0x0000041a in arm_doirq (irq=3, regs=0x1008500) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:103
/apache#11 0x0000034e in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:224

after:
(gdb) bt
/#0  systick_is_running () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:106
/#1  0x000125c0 in systick_getstatus (lower_=0x1000114 <g_systick_lower>, status=0x1007a20)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:141
/#2  0x0001323c in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/apache#3  0x00013294 in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/apache#4  0x00013404 in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/apache#5  0x000133e6 in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/apache#6  0x00008c5c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#7  0x00008e88 in _assert (filename=0x39408 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x39400 "panic", regs=0x1007cf0)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#8  0x00000ce4 in arm_busfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/apache#9  0x0000118a in arm_hardfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/apache#10 0x000086cc in irq_dispatch (irq=3, context=0x1007cf0) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/apache#11 0x0000041e in arm_doirq (irq=3, regs=0x1007cf0) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:99
/apache#12 0x00000360 in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:230
/apache#13 0x00027a8c in hello_main (argc=1, argv=0x1006e20) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:39
/apache#14 0x00014968 in nxtask_startup (entrypt=0x27a7d <hello_main>, argc=1, argv=0x1006e20)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/apache#15 0x0000f450 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/apache#16 0x00000000 in ?? ()
(gdb)

qemu armv7a nsh, hello_main:

before:
(gdb) bt
/#0  udelay_coarse (microseconds=156000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c630 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/apache#3  0x0060c644 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/apache#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#6  0x0060bd74 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/apache#7  0x0060bc04 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:438
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

after:
(gdb) bt
/#0  udelay_coarse (microseconds=192000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c650 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/apache#3  0x0060c664 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/apache#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/apache#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/apache#6  0x0060bd94 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/apache#7  0x0060bc08 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:453
/apache#8  0x00620cd4 in hello_main (argc=4999, argv=0x0) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:41
/apache#9  0x0060d320 in nxtask_startup (entrypt=0x620cc4 <hello_main>, argc=1, argv=0x4020a088)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/apache#10 0x00609b50 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/apache#11 0x00000000 in ?? ()

qemu risc-v nsh

before:

(gdb) bt
/#0  udelay_coarse (microseconds=228000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/apache#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/apache#4  0x80011f1c in reset_board () at misc/assert.c:813
/apache#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/apache#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/apache#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/apache#8  0x80000164 in exception_common () at common/riscv_exception_common.S:210
Backtrace stopped: frame did not save the PC
(gdb)

after

(gdb) bt
/#0  0x80003922 in udelay_coarse (microseconds=90000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/apache#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/apache#4  0x80011f2a in reset_board () at misc/assert.c:816
/apache#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/apache#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/apache#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/apache#8  0x80000166 in exception_common () at common/riscv_exception_common.S:215
/apache#9  0x8001792a in hello_main (argc=<optimized out>, argv=<optimized out>) at hello_main.c:41
/apache#10 0x80004b52 in nxtask_startup (entrypt=0x80030704, argc=1, argv=0x800300e8) at sched/task_startup.c:72
/apache#11 0x80001e72 in nxtask_start () at task/task_start.c:116
/apache#12 0x00000000 in ?? ()
Backtrace stopped: frame did not save the PC
(gdb)

Signed-off-by: anjiahao <[email protected]>
xiaoxiang781216 pushed a commit that referenced this pull request Dec 17, 2024
test code hello_main

int main(int argc, FAR char *argv[])
{
  uint32_t *p = 0xdeedbeff;
  *p = 0xffffff;

  printf("%p\n %x\n", p, *p);
  return 0;
}

qemu mps3-an547 hello_main :
Triggering an exception, and gdb backtrace is:

before:
(gdb) bt
/#0  0x0001168a in systick_getstatus (lower_=0x100010c <g_systick_lower>, status=0x1000a30 <g_intstackalloc+1600>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:142
/#1  0x000122f4 in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/#2  0x0001234c in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/#3  0x000124bc in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/#4  0x0001249e in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/#5  0x0000920c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:830
/#6  0x0000937c in _assert (filename=0x393f8 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x393f0 "panic", regs=0x1008500)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:940
/#7  0x00000e2c in arm_busfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/#8  0x000012d2 in arm_hardfault (irq=3, context=0x1008500, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/#9  0x00008b20 in irq_dispatch (irq=3, context=0x1008500) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/#10 0x0000041a in arm_doirq (irq=3, regs=0x1008500) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:103
/#11 0x0000034e in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:224

after:
(gdb) bt
/#0  systick_is_running () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:106
/#1  0x000125c0 in systick_getstatus (lower_=0x1000114 <g_systick_lower>, status=0x1007a20)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_systick.c:141
/#2  0x0001323c in current_usec () at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:105
/#3  0x00013294 in udelay_accurate (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:115
/#4  0x00013404 in up_udelay (microseconds=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:463
/#5  0x000133e6 in up_mdelay (milliseconds=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_timer.c:446
/#6  0x00008c5c in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/#7  0x00008e88 in _assert (filename=0x39408 "/arch/arm/src/armv8-m/arm_busfault.c", linenum=113, msg=0x39400 "panic", regs=0x1007cf0)
    at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/#8  0x00000ce4 in arm_busfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_busfault.c:113
/#9  0x0000118a in arm_hardfault (irq=3, context=0x1007cf0, arg=0x0 <up_ndelay>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_hardfault.c:142
/#10 0x000086cc in irq_dispatch (irq=3, context=0x1007cf0) at /home/ajh/work/vela_system/nuttx/sched/irq/irq_dispatch.c:145
/#11 0x0000041e in arm_doirq (irq=3, regs=0x1007cf0) at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_doirq.c:99
/#12 0x00000360 in exception_common () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv8-m/arm_exception.S:230
/#13 0x00027a8c in hello_main (argc=1, argv=0x1006e20) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:39
/#14 0x00014968 in nxtask_startup (entrypt=0x27a7d <hello_main>, argc=1, argv=0x1006e20)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/#15 0x0000f450 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/#16 0x00000000 in ?? ()
(gdb)

qemu armv7a nsh, hello_main:

before:
(gdb) bt
/#0  udelay_coarse (microseconds=156000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c630 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/#3  0x0060c644 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/#6  0x0060bd74 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/#7  0x0060bc04 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:438
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

after:
(gdb) bt
/#0  udelay_coarse (microseconds=192000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:431
/#2  0x0060c650 in up_udelay (microseconds=microseconds@entry=250000) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:416
/#3  0x0060c664 in up_mdelay (milliseconds=milliseconds@entry=250) at /home/ajh/work/vela_system/nuttx/drivers/timers/arch_alarm.c:401
/#4  0x006056bc in reset_board () at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:816
/#5  _assert (filename=filename@entry=0x63047f "/arch/arm/src/armv7-a/arm_dataabort.c", linenum=linenum@entry=157, msg=msg@entry=0x62f56d "panic",
    regs=<optimized out>, regs@entry=0x4020af10) at /home/ajh/work/vela_system/nuttx/sched/misc/assert.c:915
/#6  0x0060bd94 in arm_dataabort (regs=0x4020af10, dfar=<optimized out>, dfsr=<optimized out>)
    at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_dataabort.c:157
/#7  0x0060bc08 in arm_vectordata () at /home/ajh/work/vela_system/nuttx/arch/arm/src/armv7-a/arm_vectors.S:453
/#8  0x00620cd4 in hello_main (argc=4999, argv=0x0) at /home/ajh/work/vela_system/apps/examples/hello/hello_main.c:41
/#9  0x0060d320 in nxtask_startup (entrypt=0x620cc4 <hello_main>, argc=1, argv=0x4020a088)
    at /home/ajh/work/vela_system/nuttx/libs/libc/sched/task_startup.c:72
/#10 0x00609b50 in nxtask_start () at /home/ajh/work/vela_system/nuttx/sched/task/task_start.c:116
/#11 0x00000000 in ?? ()

qemu risc-v nsh

before:

(gdb) bt
/#0  udelay_coarse (microseconds=228000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/#4  0x80011f1c in reset_board () at misc/assert.c:813
/#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/#8  0x80000164 in exception_common () at common/riscv_exception_common.S:210
Backtrace stopped: frame did not save the PC
(gdb)

after

(gdb) bt
/#0  0x80003922 in udelay_coarse (microseconds=90000, microseconds@entry=891896832) at timers/arch_alarm.c:67
/#1  up_ndelay (nanoseconds=nanoseconds@entry=250000000) at timers/arch_alarm.c:431
/#2  0x8000397e in up_udelay (microseconds=microseconds@entry=250000) at timers/arch_alarm.c:416
/#3  0x80003988 in up_mdelay (milliseconds=milliseconds@entry=250) at timers/arch_alarm.c:401
/#4  0x80011f2a in reset_board () at misc/assert.c:816
/#5  0x80011f7a in _assert (filename=filename@entry=0x0, linenum=linenum@entry=0, msg=msg@entry=0x8002114c "panic", regs=<optimized out>,
    regs@entry=0x80030704) at misc/assert.c:915
/#6  0x80006ad6 in riscv_exception (mcause=<optimized out>, regs=0x80030704, args=<optimized out>) at common/riscv_exception.c:129
/#7  0x80000d9e in riscv_doirq (irq=7, regs=<optimized out>) at common/riscv_doirq.c:99
/#8  0x80000166 in exception_common () at common/riscv_exception_common.S:215
/#9  0x8001792a in hello_main (argc=<optimized out>, argv=<optimized out>) at hello_main.c:41
/#10 0x80004b52 in nxtask_startup (entrypt=0x80030704, argc=1, argv=0x800300e8) at sched/task_startup.c:72
/#11 0x80001e72 in nxtask_start () at task/task_start.c:116
/#12 0x00000000 in ?? ()
Backtrace stopped: frame did not save the PC
(gdb)

Signed-off-by: anjiahao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants