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

stm32: Shell module sample doesn't work on nucleo_l152re #22078

Closed
takumiando opened this issue Jan 22, 2020 · 22 comments
Closed

stm32: Shell module sample doesn't work on nucleo_l152re #22078

takumiando opened this issue Jan 22, 2020 · 22 comments
Assignees
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32 priority: low Low impact/importance bug

Comments

@takumiando
Copy link
Contributor

takumiando commented Jan 22, 2020

Shell module sample doesn't work on nucleo_l152re with latest Zephyr.

$ west build -p auto -b nucleo_l152re zephyr/samples/subsys/shell/shell_module
$ west flash
[00:00:00.000,000] <err> os: ***** MPU FAULT *****
[00:00:00.000,000] <err> os:   Instruction Access Violation
[00:00:00.000,000] <err> os: r0/a1:  0x00000000  r1/a2:  0x20000580  r2/a3:  0x00000000
[00:00:00.000,000] <err> os: r3/a4:  0x00000000 r12/ip:  0xaaaaaaaa r14/lr:  0xfffffffd
[00:00:00.000,000] <err> os:  xpsr:  0x61000036
[00:00:00.000,000] <err> os: Faulting instruction address (r15/pc): 0xe7ecfc56
[00:00:00.001,000] <err> os: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.001,000] <err> os: Fault during interrupt handling

[00:00:00.001,000] <err> os: Current thread: 0x200005d0 (idle)
[00:00:00.070,000] <err> os: Halting system

Environment

  • OS: Debian GNU/Linux 10 amd64
  • Toolchain: zephyr-sdk 0.10.3
  • Commit SHA: 68a2359
@takumiando takumiando added the bug The issue is a bug, or the PR is fixing a bug label Jan 22, 2020
@takumiando takumiando changed the title stm32: Shell module sample doesn stm32: Shell module sample doesn't work on nucleo_l152re Jan 22, 2020
@takumiando
Copy link
Contributor Author

The integration sample also doesn't work.
Does this bug depends on board specific implementations?

*** Booting Zephyr OS build zephyr-v2.1.0-1246-g68a235932f93  ***
Running test suite framework_tests
===================================================================
starting test - test_assert
PASS - test_assert
===================================================================
Test suite framework_tests succeeded
===================================================================
PROJECT EXECUTION SUCCESSFUL
E: ***** MPU FAULT *****
E:   Instruction Access Violation
E: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x20000184
E: r3/a4:  0x00000000 r12/ip:  0x00000000 r14/lr:  0xfffffffd
E:  xpsr:  0x6100000f
E: Faulting instruction address (r15/pc): 0xbf0306da
E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Fault during interrupt handling

E: Current thread: 0x20000184 (idle)
E: Halting system

@takumiando
Copy link
Contributor Author

At f144e39, it also doesn't work.
Of course I added CONFIG_EEPROM_SHELL=y to prj.conf like this commit message...

@erwango
Copy link
Member

erwango commented Jan 22, 2020

@takumiando, I suspect an issue with the clock_control driver.
Can you try using following clock settings:
CONFIG_CLOCK_STM32_SYSCLK_SRC_HSI=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=16000000

@maxschuh
Copy link

@takumiando, I suspect an issue with the clock_control driver.
Can you try using following clock settings:
CONFIG_CLOCK_STM32_SYSCLK_SRC_HSI=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=16000000

yes, this seems to solve the problem on my side. Both 'samples/synchronization' and 'samples/philosophers' work with these settings

@erwango
Copy link
Member

erwango commented Jan 22, 2020

Further testing shows that we're facing the same issue on nucleo_l053r8.
Issue seems linked to setting SYSCLK to 32MHz (whatever the clock source PLL HSE/HSI or direct HSI).

@frantony
Copy link
Contributor

@takumiando

E: >>> ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
E: Fault during interrupt handling

E: Current thread: 0x20000184 (idle)
E: Halting system

Please try to turn the board power off and then on just after burning zephyr image.
The sample should run successfully after power cycle.

@erwango
Copy link
Member

erwango commented Jan 22, 2020

Please try to turn the board power off and then on just after burning zephyr image.
The sample should run successfully after power cycle.

@frantony thanks for the hint but this is not how it is supposed to work.
Any idea on the possible root cause for this ?

@takumiando
Copy link
Contributor Author

@erwango, thanks for your idea of workaround!
It works successfully.

@erwango
Copy link
Member

erwango commented Jan 23, 2020

@takumiando, I've replaced zephyr code with code from STM32Cube using LL API to set up the clock and faced the same issue.
So, while it looks correlated with a clock control issue it is not an issue in zephyr clock control driver. Either this is a SoC issue, either this is linked with another part of zephyr code.
This will require deeper investigation.

@jhedberg jhedberg added the priority: low Low impact/importance bug label Jan 28, 2020
erwango added a commit to erwango/zephyr that referenced this issue Feb 4, 2020
A bug under investigation (issue zephyrproject-rtos#22078) limits board operations
to 16MHz. When running at 32MHz, some applications may crash.

In order to enable use of nucleo_l152re with mot of applications,
limit frequency to 16MHz until bug is fixed.


Signed-off-by: Erwan Gouriou <[email protected]>
MaureenHelm pushed a commit that referenced this issue Feb 4, 2020
A bug under investigation (issue #22078) limits board operations
to 16MHz. When running at 32MHz, some applications may crash.

In order to enable use of nucleo_l152re with mot of applications,
limit frequency to 16MHz until bug is fixed.


Signed-off-by: Erwan Gouriou <[email protected]>
@tagunil
Copy link
Collaborator

tagunil commented Feb 14, 2020

These 32MHz faults go away after commenting out WFI instruction in arch_cpu_idle(), so I guess it is some weird kind of interaction between sleep mode and debugging. Looks similar to unanswered question here: https://community.st.com/s/question/0D50X00009XkXgd/stm32l1-hardfault-when-returning-from-wfi-only-when-debugger-attached

@tagunil
Copy link
Collaborator

tagunil commented Feb 14, 2020

Replacing WFI instruction with CPSID i; WFI; CPSIE i sequence also helps somehow, but I have no idea why it is so.

@tagunil
Copy link
Collaborator

tagunil commented Feb 15, 2020

Looks like FreeRTOS Cortex-M ports actually mask interrupts before going to sleep (e.g. https:/FreeRTOS/FreeRTOS-Kernel/blob/master/portable/GCC/ARM_CM3/port.c#L476). Maybe that should be discussed with ARM maintainers.

@erwango
Copy link
Member

erwango commented Mar 11, 2020

Looks like FreeRTOS Cortex-M ports actually mask interrupts before going to sleep (e.g. https:/FreeRTOS/FreeRTOS-Kernel/blob/master/portable/GCC/ARM_CM3/port.c#L476). Maybe that should be discussed with ARM maintainers.

@ioannisg any opinion on this ?

@ioannisg
Copy link
Member

@tagunil (FYI @erwango)
The interrupt masking you proposed above has the following effect: the system wakes up before the ISR is executed. This is needed, in general, if we wish to execute code after the system is woken up by the interrupt, but before the ISR interrupt is executed. In the case of Zephyr ARM's arch_cpu_idle() there is nothing executed after wfi (the function simply returns) so I don't think this would play any significant role in your case.

What is indeed missing here is a __DSB() instruction before calling WFI - I wonder if you can try that an report your findings.

@tagunil
Copy link
Collaborator

tagunil commented Mar 13, 2020

@ioannisg
I've tested your barriers-related commit from #23436. Unfortunately, that didn't fix the problem.

@stephanosio
Copy link
Member

@tagunil Could you check if #23511 fixes the problem?

@tagunil
Copy link
Collaborator

tagunil commented Mar 17, 2020

@stephanosio Yeah, #23511 works, although I still can't understand why.

@ioannisg
Copy link
Member

@takumiando can you check, now, if this can be closed? #23511 is merged.

@takumiando
Copy link
Contributor Author

@ioannisg It works correctly on my nucleo_l152re ;)

@erwango
Copy link
Member

erwango commented Mar 25, 2020

@takumiando could you create an issue to get nucleo_l152re working at full speed now? (reverting #22308)

@takumiando
Copy link
Contributor Author

@erwango Okay #23762

@LQchengdu
Copy link

For me, disable debug-mode by LL is also work fine.

    LL_DBGMCU_DisableDBGSleepMode();
    LL_DBGMCU_DisableDBGStandbyMode();
    LL_DBGMCU_DisableDBGStopMode();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug, or the PR is fixing a bug platform: STM32 ST Micro STM32 priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

9 participants