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

Shell FS sample halts with a usage fault error #39340

Closed
danieldegrasse opened this issue Oct 11, 2021 · 4 comments · Fixed by #40270
Closed

Shell FS sample halts with a usage fault error #39340

danieldegrasse opened this issue Oct 11, 2021 · 4 comments · Fixed by #40270
Assignees
Labels
area: Shell Shell subsystem bug The issue is a bug, or the PR is fixing a bug platform: NXP NXP priority: low Low impact/importance bug

Comments

@danieldegrasse
Copy link
Collaborator

Describe the bug
After flashing the shell filesystem example (samples/subsys/shell/fs) on an MIMXRT1064 evk, the example halts and prints a usage fault error. This bug reproduces on the latest version of the main branch, but not on v2.7.0-rc4. The bug first appears at commit 0a50ebe.

To Reproduce
Steps to reproduce the behavior:

  1. mkdir build; cd build
  2. cmake -DBOARD=mimxrt1064_evk ../samples/subsys/shell/fs
  3. make
  4. See error

Expected behavior
The UART shell should start and display the uart:~$ prompt

Logs and console output
Here is what the console outputs after the usage fault:

*** Booting Zephyr OS build v2.7.99-84-g851cccb67efd  ***

[00:00:00.005,000] <err> os: ***** USAGE FAULT *****
[00:00:00.005,000] <err> os:   Illegal use of the EPSR 
[00:00:00.005,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x70012550  r2/a3:  0x00000003
[00:00:00.005,000] <err> os: r3/a4:  0x00000000 r12/ip:  0xaaaaaaaa r14/lr:  0x70006e3f
[00:00:00.005,000] <err> os:  xpsr:  0x20000024
[00:00:00.005,000] <err> os: Faulting instruction address (r15/pc): 0x00000000
[00:00:00.005,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.005,000] <err> os: Fault during interrupt handling
[00:00:00.005,000] <err> os: Current thread: 0x80000430 (shell_uart)
[00:00:00.047,000] <err> os: Halting system

Environment:

  • OS: Linux
  • Toolchain: Zephyr SDK
  • Commit 0a50ebe

Additional Context
The issue appears to only occur in the filesystem shell example. It does not occur in other shell examples, and enabling the shell in the "hello world" example did not trigger the bug.

@danieldegrasse danieldegrasse added bug The issue is a bug, or the PR is fixing a bug area: Shell Shell subsystem priority: low Low impact/importance bug labels Oct 11, 2021
@jakub-uC
Copy link
Contributor

I will take a look at it tomorrow. But I can only try to reproduce it on Nordic DKs because I do not have mimxrt1064_evk.

@danieldegrasse
Copy link
Collaborator Author

Thanks so much, if it only reproduces on NXP parts that would narrow down the bug

@jakub-uC
Copy link
Contributor

@danieldegrasse
I was doing my tests on commit: d66a745
Example started with no issues on:
qemu_x86, qemu_x86_64, qemu_cortex_m3, nrf52840dk_nrf52840, nrf52dk_nrf52832

Example did not compile on qemu_cortex_m0 due to not enough SRAM for the default configuration.

Are you able to debug this example in order to find out what is the root cause of the crash?

@danieldegrasse
Copy link
Collaborator Author

@jakub-uC It appears the bug was resolved by commit eb3375f. I debugged the issue further using commit 30cd046 and it appears to be something wrong with NXP's LPUART driver. The actual fault occurs on line 234 of isr_wrapper.S of Zephyr's software ISR wrapper.

The bug occurs directly after calling LPUART_EnableInterrupts, and the isr that Zephyr is trying to handle is the LPUART's interrupt. The issue is fixed by adding an __ISB() macro after the call to LPUART_EnableInterrupts in the LPUART driver.

When I narrowed down the issue, GDB was reporting that "program memory was no longer writable", and instructions were failing to execute correctly (for example, the call to ldm prior to blx r3 does not actually access the memory it should), hence why I tried adding the ISB macro.

@dleach02 dleach02 added platform: NXP NXP and removed priority: low Low impact/importance bug labels Oct 16, 2021
@nashif nashif added the priority: low Low impact/importance bug label Oct 19, 2021
danieldegrasse added a commit to nxp-zephyr/zephyr that referenced this issue Oct 19, 2021
This commit fixes a usage fault encountered on the MIMXRT1064 EVK
when using the shell fs sample. The ISB and DSB instructions prevent the
chip from entering a bad state when exiting an interrupt. See arm errata
838869 for additional details.

Fixes zephyrproject-rtos#39340

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Shell Shell subsystem bug The issue is a bug, or the PR is fixing a bug platform: NXP NXP priority: low Low impact/importance bug
Projects
None yet
4 participants