Skip to content

Conversation

@davids5
Copy link
Contributor

@davids5 davids5 commented Dec 21, 2019

In bringing up the NXP RDDRONE-FMURT6 these issues were discovered and fixed.

  • False detection
  • No Detection I2C
  • System lock up hang due to interrupt storm

Prior to this PR

NuttShell (NSH)
nsh>  i2cdetect -b 1
Scanning I2C bus: 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
nsh>  i2cdetect -b 2
Scanning I2C bus: 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d <HUNG>

Top Traces are the I2C IRQ, SPI IRQ and CPU IRQ,
Big Picture
image
Focus on Storm
image
The Storm rate.
image

With this PR

NuttShell (NSH)
nsh>  i2cdetect -b 1
Scanning I2C bus: 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 0e --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- 55 -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
nsh>  i2cdetect -b 2
Scanning I2C bus: 2
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

image

imxrt:gpio ran through nxstyle
   Reworked imxrt_lpi2c_reset to use GPIO because the IO
   can not be mapped from a peripheral to a GPIO with
   simple bit logic.
   After an error the STOP detect was overwriting the
   previous error status.
   The SDF was not acked if ther was an error
   on the last write.
@davids5 davids5 requested a review from patacongo December 21, 2019 11:42
@davids5 davids5 added the Type: Bug Something isn't working label Dec 21, 2019
@davids5 davids5 marked this pull request as ready for review December 21, 2019 11:47
@Apache9
Copy link

Apache9 commented Dec 21, 2019

So we will merge PR to master branch directly? No dev branch?

@davids5 davids5 requested review from Ouss4 and acassis and removed request for patacongo December 21, 2019 17:18
@davids5
Copy link
Contributor Author

davids5 commented Dec 21, 2019

So we will merge PR to master branch directly? No dev branch?

@Apache9
As it stands master has been dev. If we had release branches then master could still be dev. But all this is yet to be seen.

I will let this sit until the PPMC votes on work flow. I only needed it merged to backport to the PX4 stable version of nuttx 8.2. It was important because it cause the OS to hang.

I usually prefer to back-port after Greg has applied the patch or PR and then fixed things his subsequent commits. That way the back port == upstream.

But I can carry the commits without the [BACKPORT] marker in PX4 for now.

We should warn all the NXP IMXRT and I think NXP S32K users the code will hang the OS.

@patacongo
Copy link
Contributor

'master' has never been 'dev' in this repository. You are thinking of a different repository that was managed by a single person.

@davids5
Copy link
Contributor Author

davids5 commented Dec 22, 2019

'master' has never been 'dev' in this repository. You are thinking of a different repository that was managed by a single person.

Yes - I am so glad you are so exacting - I was referring to historically before NuttX joined ASF. Most recently in the repo hosted on bitbucket, with Greg as the sole committer.

@patacongo
Copy link
Contributor

With a single committer, you can greatly simplify things since it is the sole reponsibility of that single committed to go from the patch to PR to its clean incorporation. It requires more discipline to work as a group.
PS: I always hated the PRs to master in the Bitbucket repsitories. But I never hated all PRs as you said. I should have set up a 'dev' branch and made sure that all PRs were against the 'dev' branch. Although it does take a little effort to keep a dev branch up to date.

@btashton
Copy link
Contributor

@davids5 This touches some of the same IO stuff that I have been working on on the imxrt platform, some of the changes are style. Did you make these changes via one of the existing tools, or was this manual. I want to make sure my changes apply cleanly on top of this. For now I will carry this in my tree.

@jarivanewijk
Copy link
Contributor

jarivanewijk commented Dec 23, 2019

Thank you for your work, @davids5!

We should warn all the NXP IMXRT and I think NXP S32K users the code will hang the OS.

A lot of the peripheral code for S32K seems to be taken from i.MX RT, so it is likely affected by this is as well. There are probably not many S32K users yet, though. We are working at NXP to improve the support for the S32K1xx and their evaluation boards. The progress is slow but steady. After the holidays I will apply your fixes to S32K on our internal NuttX repository. We will open a PR here eventually. (January/February?)

@davids5
Copy link
Contributor Author

davids5 commented Dec 23, 2019

Thank you for your work, @davids5!

We should warn all the NXP IMXRT and I think NXP S32K users the code will hang the OS.

A lot of the peripheral code for S32K seems to be taken from i.MX RT, so it is likely affected by this is as well. There are probably not many S32K users yet, though. We are working at NXP to improve the support for the S32K1xx and their evaluation boards. The progress is slow but steady. After the holidays I will apply your fixes to S32K on our internal NuttX repository. We will open a PR here eventually. (January/February?)

@jarivanewijk - yes exactly. It was cloned by @patacongo before I had the RDDRONE-FMURT6 HW to validate it on. It may be marked EXPERIMENTAL , but I have not followed it's progress.

I will ask @igalloway for HW and I can cross check locally as well.

@davids5
Copy link
Contributor Author

davids5 commented Dec 23, 2019

@btashton

@davids5 This touches some of the same IO stuff that I have been working on on the imxrt platform, some of the changes are style. Did you make these changes via one of the existing tools, or was this manual. I want to make sure my changes apply cleanly on top of this. For now I will carry this in my tree.

yeah - we really should talk this through. I had a very detailed discussion on yahoo on what we had learned from the STM32 organically grown nightmare.

The gist of it is: There are clear patterns that should be use when there is a chip family.

@mubes make some great strides in this on the RT, but took some shortcuts when the imxrt20 came in. We should not follow that pattern.

All the gpio tables need to broken out and the included like the clockconfig does STM32 or the dasiy does n the imxrt.

#ifddef rash has to be avoided or kept to a minimum. It use to be before the 20 commit.
Scope has to be be maintained.

Let' plan a call then bring it back to the list.

@mubes
Copy link
Contributor

mubes commented Dec 23, 2019

Way back when DavidS and I talked about this at length and then there was a lot of work done in imxrt to split it into the different chips - 1050, 60 and 20 to form the various hardware/rt10xx directories.

At the moment the only place there is any family member selection (other than to pull in the correct chip specific subdir) is in imxrt_clockconfig.c, imxrt_gpio.c and imxrt_iomux.c. Those can (and probably should) be refactored into the same pattern as the other files which, I think, would keep the structure clean.

Does that satisfy your concern @btashton , or are you looking for a more fundamental restructure? (BTW, this structure is a nicer way of highlighting changes and having proper discussion about them to find the best way forward).

DAVE

@btashton
Copy link
Contributor

@mubes No complaints on my end (beyond the tedious task of transcribing datasheets to code). This family has been handled so much better by NXP than ST did with the STM32 family.

There are a few things I have tweaked across all of the devices, but that is mostly minor and usually just using a better define for example because not all have PADMUX_WAKEUP:

-  if (index >= IMXRT_PADMUX_WAKEUP_INDEX)
+  if (index >= IMXRT_PADMUX_SNVS_START_INDEX)

Also a couple typeo's like

-#define GPIO_LPSPI1_SDI_2              (GPIO_PERIPH | GPIO_ALT4 | GPIO_PADMUX(IMXRT_PADMUX_GPIO_SD_B0_05_INDEX))fb
+#define GPIO_LPSPI1_SDI_2              (GPIO_PERIPH | GPIO_ALT4 | GPIO_PADMUX(IMXRT_PADMUX_GPIO_SD_B0_05_INDEX))

There is also a GPIOMUX that they added to help with the lower pincount while still allowing high speed GPIO. Anyway I need to just get this stuff out for comment. Probably need a couple nights to get the core code done, not sure how long the board bit will take. The memory interfaces are a little different.

Anyway this is getting off topic for this PR. I'll put a DRAFT PR up before I get the board code done, either a here or on my fork.

@davids5 I have not forgotten about your offer, just will likely need to wait until the 1st with travel.

@mubes
Copy link
Contributor

mubes commented Dec 23, 2019

Yeah, lets move this onto another PR so we can fix up whatever needs to be done to solidify the filesystem structure for the rt's. Certainly I think moving the GPIOs, IOMUX and ClockConfig into the subdirectory will go a long way to fixing whats outstanding (well, that and fixing Mr. Hamfisteds' typos).

DAVE

@patacongo patacongo merged commit 10c4aff into master Dec 24, 2019
@patacongo patacongo deleted the master_imxrt branch December 24, 2019 01:08
anchao referenced this pull request in anchao/nuttx 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 <anchao@xiaomi.com>
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 <anchao@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Dec 25, 2024
CID 1578530: (#1 of 1): INTEGER_OVERFLOW

Signed-off-by: yangsen5 <yangsen5@xiaomi.com>
JianyuWang0623 added a commit to JianyuWang0623/nuttx that referenced this pull request Jan 7, 2025
CID 1309501: (apache#1 of 1): Overflow constant (INTEGER_OVERFLOW)
overflow_const: Expression upper->crefs, which is equal to 255, where enable ? 1 : -1 is known to be equal to -1, overflows the type that receives it, an unsigned integer 8 bits wide.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
JianyuWang0623 added a commit to JianyuWang0623/nuttx that referenced this pull request Jan 7, 2025
CID 1309501: (apache#1 of 1): Overflow constant (INTEGER_OVERFLOW)
overflow_const: Expression upper->crefs, which is equal to 255, where enable ? 1 : -1 is known to be equal to -1, overflows the type that receives it, an unsigned integer 8 bits wide.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Jan 7, 2025
CID 1309501: (#1 of 1): Overflow constant (INTEGER_OVERFLOW)
overflow_const: Expression upper->crefs, which is equal to 255, where enable ? 1 : -1 is known to be equal to -1, overflows the type that receives it, an unsigned integer 8 bits wide.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
linguini1 pushed a commit to linguini1/nuttx that referenced this pull request Jan 16, 2025
CID 1309501: (apache#1 of 1): Overflow constant (INTEGER_OVERFLOW)
overflow_const: Expression upper->crefs, which is equal to 255, where enable ? 1 : -1 is known to be equal to -1, overflows the type that receives it, an unsigned integer 8 bits wide.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
@linguini1 linguini1 mentioned this pull request May 14, 2025
1 task
W-M-R added a commit to W-M-R/nuttx that referenced this pull request Jul 10, 2025
…d -march=armv8.1-m.main+mve.fp+fp.dp

The above combination of compilation causes the compiler to crash:
 apache#1 0x0000000001fbe154 llvm::sys::CleanupOnSignal(unsigned long) (clang18/bin/clang-19+0x1fbe154)
 apache#2 0x0000000001f21203 llvm::CrashRecoveryContext::HandleExit(int) (clang18/bin/clang-19+0x1f21203)
 apache#3 0x0000000001fb7b7e llvm::sys::Process::Exit(int, bool) (clang18/bin/clang-19+0x1fb7b7e)
 apache#4 0x0000000000b25f0d (clang18/bin/clang-19+0xb25f0d)
................................................................................
................................................................................
This problem occurs in clang18 and above, and there are compilation instructions that are incompatible with GCC.
By following the recommended v8.1m corresponding fpu modification, no crash will occur
➜  NX git:(master) ✗ clang --target=arm-none-eabi -mfpu=help
clang: note: available multilibs are:
--target=aarch64-unknown-none-elf
--target=aarch64-unknown-none-elf -fno-exceptions -fno-rtti
--target=armv4t-unknown-none-eabi -mfpu=none
--target=armv4t-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=armv5e-unknown-none-eabi -mfpu=none
--target=armv5e-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv6m-unknown-none-eabi -mfpu=none
--target=thumbv6m-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=armv7-unknown-none-eabi -mfpu=none
--target=armv7-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=armv7-unknown-none-eabihf -mfpu=vfpv3-d16
--target=armv7-unknown-none-eabihf -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti
--target=armv7-unknown-none-eabi -mfpu=vfpv3-d16
--target=armv7-unknown-none-eabi -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti
--target=armv7r-unknown-none-eabi -mfpu=none
--target=armv7r-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=armv7r-unknown-none-eabihf -mfpu=vfpv3xd
--target=armv7r-unknown-none-eabihf -mfpu=vfpv3xd -fno-exceptions -fno-rtti
--target=armv7r-unknown-none-eabihf -mfpu=vfpv3-d16
--target=armv7r-unknown-none-eabihf -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti
--target=armv7r-unknown-none-eabi -mfpu=vfpv3-d16
--target=armv7r-unknown-none-eabi -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti
--target=thumbv7m-unknown-none-eabi -mfpu=fpv4-sp-d16
--target=thumbv7m-unknown-none-eabi -mfpu=fpv4-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv7m-unknown-none-eabihf -mfpu=fpv4-sp-d16
--target=thumbv7m-unknown-none-eabihf -mfpu=fpv4-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv7m-unknown-none-eabihf -mfpu=fpv5-d16
--target=thumbv7m-unknown-none-eabihf -mfpu=fpv5-d16 -fno-exceptions -fno-rtti
--target=thumbv7m-unknown-none-eabi -mfpu=none
--target=thumbv7m-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8m.main-unknown-none-eabi -mfpu=none
--target=thumbv8m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none -fno-exceptions -fno-rtti

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Jul 10, 2025
mcount.S: Assembler messages:
mcount.S:33: Error: cannot honor width suffix -- `bic r1,lr,#1'
mcount.S:35: Error: cannot honor width suffix -- `bic r0,r0,#1'
mcount.S:37: Error: cannot honor width suffix -- `pop {r0,r1,r2,r3,ip,lr}

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
W-M-R added a commit to W-M-R/nuttx that referenced this pull request Jul 11, 2025
…d -march=armv8.1-m.main+mve.fp+fp.dp

The above combination of compilation causes the compiler to crash:
 apache#1 0x0000000001fbe154 llvm::sys::CleanupOnSignal(unsigned long) (clang18/bin/clang-19+0x1fbe154)
 apache#2 0x0000000001f21203 llvm::CrashRecoveryContext::HandleExit(int) (clang18/bin/clang-19+0x1f21203)
 apache#3 0x0000000001fb7b7e llvm::sys::Process::Exit(int, bool) (clang18/bin/clang-19+0x1fb7b7e)
 apache#4 0x0000000000b25f0d (clang18/bin/clang-19+0xb25f0d)
................................................................................
................................................................................
This problem occurs in clang18 and above, and there are compilation instructions that are incompatible with GCC.
By following the recommended v8.1m corresponding fpu modification, no crash will occur
➜  NX git:(master) ✗ clang --target=arm-none-eabi -mfpu=help
clang: note: available multilibs are:
--target=thumbv8m.main-unknown-none-eabi -mfpu=none
--target=thumbv8m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none -fno-exceptions -fno-rtti

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Jul 11, 2025
…d -march=armv8.1-m.main+mve.fp+fp.dp

The above combination of compilation causes the compiler to crash:
 #1 0x0000000001fbe154 llvm::sys::CleanupOnSignal(unsigned long) (clang18/bin/clang-19+0x1fbe154)
 #2 0x0000000001f21203 llvm::CrashRecoveryContext::HandleExit(int) (clang18/bin/clang-19+0x1f21203)
 #3 0x0000000001fb7b7e llvm::sys::Process::Exit(int, bool) (clang18/bin/clang-19+0x1fb7b7e)
 #4 0x0000000000b25f0d (clang18/bin/clang-19+0xb25f0d)
................................................................................
................................................................................
This problem occurs in clang18 and above, and there are compilation instructions that are incompatible with GCC.
By following the recommended v8.1m corresponding fpu modification, no crash will occur
➜  NX git:(master) ✗ clang --target=arm-none-eabi -mfpu=help
clang: note: available multilibs are:
--target=thumbv8m.main-unknown-none-eabi -mfpu=none
--target=thumbv8m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16
--target=thumbv8m.main-unknown-none-eabihf -mfpu=fpv5-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabi -mfpu=none -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-sp-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+fp16 -mfpu=fp-armv8-fullfp16-d16 -fno-exceptions -fno-rtti
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none
--target=thumbv8.1m.main-unknown-none-eabihf -march=thumbv8.1m.main+mve -mfpu=none -fno-exceptions -fno-rtti

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
johncho04 pushed a commit to johncho04/nuttx that referenced this pull request Sep 5, 2025
How to setup coredump ?

1. Build config coredump:

  $ ./tools/configure.sh ./boards/arm/imx6/sabre-6quad/configs/coredump
  $ make

2. Run qemu and get the coredump snapshot:

  $ qemu-system-arm -semihosting -M sabrelite -m 1024 -smp 4 -nographic -kernel ./nuttx -s
  ABCDGHIJKNOPQ

  NuttShell (NSH) NuttX-10.4.0
  nsh> coredump
  [CPU0] [ 6] Start coredump:
  [CPU0] [ 6] 5A5601013D03FF077F454C4601010100C0000304002800C00D003420036000070400053400200008200A4000000420030034C024200001D8092004E00200601A
  [CPU0] [ 6] 060C0000E85D831040030018200E400300072003403C601F06100000F8518310400340574003E0041F00142003025683106003A000E0081F005A201B4003A000
  [CPU0] [ 6] E0071F03987F831040030060200E4003E0041F209003288A8310400300B820104003E0041F061C0000D09283104003609C2003C01F00202006007C2003000320
  [CPU0] [ 6] 0308435055302049444C45200BE02700E0333BE01B0040A70094200340CFE0576BE0070040730006200340000424A782101420030474A482102020074137400B
  [CPU0] [ 6] 0030200B4027422309F51880108E8A80107F0161AA600040BFE102670031E01FBF4053E00300E0233BE02B0040A7E10267E02C6B403BE05700436B019319A167
  [CPU0] [ 6] 200F20005A560100A703FF010000200000202003007C20030003200308435055322049444C45200BE0170000022003E00300E0233BE02B0040A7009420030001
  [CPU0] [ 6] 2003E02F6BE007B3E04C00025683102005E0080040BFE102670033E01FBF402FE00300E0233BE02B0040A7E10267E02C6BE007B3E04C00005AE1196706687077
  [CPU0] [ 6] 6F726B00E01CBF00042003E00300A03BE0500040A7C167A06BE01CA7E00300E007B3E0170042FF05BC748310785C213B00005A560100F303FF0A000074A48210
  [CPU0] [ 6] 38748310242007010100E00D0008987F8310998C8010A4200303FF000020201260004008007C200300032003076E73685F6D61696E200AE0180000052003E003
  [CPU0] [ 6] 00E0233BE02B0040A70094200340DFE02F6BE007B3E0170000022003078480831088998310200A0200F08E2007200FC1674003400004CC8A8310042007006420
  [CPU0] [ 6] 030028200BE1176707636F726564756D70200AE0180000062003E00300E0233BE02B0040A7C167E02F6BE007B3E017000BDC458310E0988310780A0000415B03
  [CPU0] [ 6] 6C9A8310416B408B4133408F01788F217BA000405F00B0202F02EB21816003035F0000602012E0EB000100005A5601002103FF0E000000005E831000A27C3F00
  [CPU0] [ 6] 005080200DE0FF00E0FF00E0FF00E0CA000100005A5601001203FF010000E0FF00E0FF00E0FF00E0DA000100005A5601005403FF01000020000838748310D037
  [CPU0] [ 6] 8310DF200B0487328010C8200B400F400720120000400B00AB2017005F200B04432B80101520030002200B0101012004E00600028137806033E0FF00E0FF00E0
  [CPU0] [ 6] FF00E083000100005A560100F203FF010000600007808310BC8F8310DF200A088732801084FFFFFFA0200F0006200F04848A83105F200704E92D8110F1200340
  [CPU0] [ 6] 1303108C8310202200FF200A0900988E8310FD248010F7A01B061BD3801054AC826033C0004023403304CDD2801001200FE00300030FA2801020061200C15080
  [CPU0] [ 6] 103081821089678010A18E8310B35CE0092B400F0333EC8010404F4003200EE0640040C34003407B0D08F781107F7B801071F28010A99480C340000291938060
  [CPU0] [ 6] 2340AB4003400B05A1928010F883E005AF01F99080DF40174003009DA00F00642003400F0071A00F013F692063200B018D37E00163E0FF00E0FF00E02E000100
  [CPU0] [ 6] 005A5601003A03FF010000600003589083102006E0080001F092801707636F726564756D70200A600003EFBEADDEE0FF03E0FF03E0FF03E01B032342E07A0001
  [CPU0] [ 6] 00005A560101C003FF010000E095000BF08E83100927801054AC8210400B201201005F2003400BE00717E0CB0040DBE007E7E00FFF40170055200F0043201720
  [CPU0] [ 6] 0A6023401F4017400006111D8010207183600F047D40831018200B4023E003470794818210D91A8010E0174701E43FE00173403306F49A8310DF4C8160170448
  [CPU0] [ 6] 99831041201704CE1F841002200704CD3F81100C2007049D34811040201B200A05002EF781106C200B008D200B001D201F05893E81107978806F000A200300D8
  [CPU0] [ 6] 204F01D57B800F00882027400300F1E0020F009F202B40434027C06B122F798010789B8310F803000008040000C89683600F04277A80108C200700BC2037202A
  [CPU0] [ 6] 01008F202B20060200D092200F000820082003006C20470730A7821000FCFFFF201160000533208110D0072008201F410340230020202301B12220BB200B2019
  [CPU0] [ 6] 010006200301992420DF0323000001200B01001C805740034037400340420000208F60000504000534002040166000046BE88110F0213F200A000040AB00FF20
  [CPU0] [ 6] 0000E120E7400B020B188160174000400F201A00FF402B048517811065200340FB201260B000FD203303F7528110408300A9A00700E84083E00200033F698010
  [CPU0] [ 6] 401B018D37814720005A5601000800090100006000010000
  [CPU0] [ 6] Finish coredump (Compression Enabled).

3. Copy the hex body and save to file:

  $ cat elf.dump
  [CPU0] [ 6] 5A5601013D03FF077F454C4601010100C0000304002800C00D003420036000070400053400200008200A4000000420030034C024200001D8092004E00200601A
  ...
  [CPU0] [ 6] 401B018D37814720005A5601000800090100006000010000

4. Run tools/coredump.py to convert hex dump to elf coredump:

  $ ./tools/coredump.py elf.dump
  Chunk apache#1 is compressed, 317 bytes (original size: 1023 bytes)
  ...
  Chunk apache#10 is compressed, 8 bytes (original size: 9 bytes)

  $ ls elf.core
  elf.core

5. Pass core(elf.core) and bin elf(nuttx) to gdb:
  !!(Toolchain(arm-none-eabi-gdb) version must be newer than 11.3) !!

  $ arm-none-eabi-gdb -c elf.core nuttx
  GNU gdb (Arm GNU Toolchain 11.3.Rel1) 12.1.90.20220802-git
  ...
  Reading symbols from nuttx...

  [New process 6]
  [New process 1]
  [New process 2]
  [New process 3]
  [New process 4]
  [New process 5]
  [New process 6]
  Core was generated by `'.
  #0  0x10808a8e in up_idle () at chip/imx_idle.c:61
  61	}
  [Current thread is 1 (process 6)]
  (gdb)
  (gdb) info thread
    Id   Target Id         Frame
  * 1    process 6         0x10808a8e in up_idle () at chip/imx_idle.c:61
    2    process 1         0x10808a8e in up_idle () at chip/imx_idle.c:61
    3    process 2         0x00000000 in ?? ()
    4    process 3         0x00000000 in ?? ()
    5    process 4         up_switch_context (tcb=0x1082a474 <g_idletcb>, rtcb=rtcb@entry=0x10837438) at common/arm_switchcontext.c:95
    6    process 5         up_switch_context (tcb=0x10838ef0, rtcb=rtcb@entry=0x10838000) at common/arm_switchcontext.c:95
    7    process 6         elf_emit_tcb_note (cinfo=0x10839a6c, tcb=0x10838ef0) at libelf/libelf_coredump.c:272
  (gdb) thread 6
  [Switching to thread 6 (process 5)]
  #0  up_switch_context (tcb=0x10838ef0, rtcb=rtcb@entry=0x10838000) at common/arm_switchcontext.c:95
  95	      arm_switchcontext(&rtcb->xcp.regs, tcb->xcp.regs);
  (gdb) bt
  #0  up_switch_context (tcb=0x10838ef0, rtcb=rtcb@entry=0x10838000) at common/arm_switchcontext.c:95
  apache#1  0x10803286 in nxsem_wait (sem=0x10838fbc) at semaphore/sem_wait.c:176
  apache#2  0x10812de8 in nxsched_waitpid (pid=pid@entry=6, stat_loc=stat_loc@entry=0x10838a84, options=options@entry=4) at sched/sched_waitpid.c:169
  apache#3  0x10812df6 in waitpid (pid=pid@entry=6, stat_loc=stat_loc@entry=0x10838a84, options=options@entry=4) at sched/sched_waitpid.c:639
  apache#4  0x1080d31a in nsh_builtin (vtbl=vtbl@entry=0x10838c10, cmd=0x10838e98 <error: Cannot access memory at address 0x10838e98>, argv=argv@entry=0x10838adc, redirfile=redirfile@entry=0x0, oflags=oflags@entry=0) at nsh_builtin.c:162
  apache#5  0x1080a20e in nsh_execute (oflags=0, redirfile=0x0, argv=0x10838adc, argc=1, vtbl=0x10838c10) at nsh_parse.c:641
  apache#6  nsh_parse_command (vtbl=vtbl@entry=0x10838c10, cmdline=<optimized out>) at nsh_parse.c:2742
  apache#7  0x1080a510 in nsh_parse (vtbl=vtbl@entry=0x10838c10, cmdline=cmdline@entry=0x10838e98 <error: Cannot access memory at address 0x10838e98>) at nsh_parse.c:2826
  apache#8  0x10809390 in nsh_session (pstate=0x10838c10, login=login@entry=1, argc=argc@entry=1, argv=argv@entry=0x108383f8) at nsh_session.c:245
  apache#9  0x108090f8 in nsh_consolemain (argc=argc@entry=1, argv=argv@entry=0x108383f8) at nsh_consolemain.c:71
  apache#10 0x1080909c in nsh_main (argc=1, argv=0x108383f8) at nsh_main.c:74
  apache#11 0x1080693e in nxtask_startup (entrypt=0x10809071 <nsh_main>, argc=1, argv=0x108383f8) at sched/task_startup.c:70
  apache#12 0x1080378c in nxtask_start () at task/task_start.c:134
  apache#13 0x00000000 in ?? ()
  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Signed-off-by: chao an <anchao@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants