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

Hard fault after a while, 2 UART #9148

Closed
clem844 opened this issue May 17, 2018 · 6 comments
Closed

Hard fault after a while, 2 UART #9148

clem844 opened this issue May 17, 2018 · 6 comments
Assignees
Labels
Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@clem844
Copy link

clem844 commented May 17, 2018

Hi,

I have a problem when using 2 USART on STM32f407. I receive some data from both USART which triggers each its callback function. I tested two possibilities in the cb, either it's sending each received character by IPC to a Thread or it's saving the full message in an array before sending it to the Thread. Either way, a hard fault error triggers after a while. When sending each character individually, it's lasting longer before crashing. Here is the trace:

2018-05-17 15:15:06,852 - INFO # 
2018-05-17 15:15:06,852 - INFO # Context before hardfault:
2018-05-17 15:15:06,852 - INFO #    r0: 0x22d8ca84
2018-05-17 15:15:06,852 - INFO #    r1: 0x200016bc
2018-05-17 15:15:06,867 - INFO #    r2: 0x20000820
2018-05-17 15:15:06,867 - INFO #    r3: 0x0002c2c0
2018-05-17 15:15:06,867 - INFO #   r12: 0x200015b3
2018-05-17 15:15:06,867 - INFO #    lr: 0x08000247
2018-05-17 15:15:06,868 - INFO #    pc: 0x0800025c
2018-05-17 15:15:06,868 - INFO #   psr: 0x0100000e
2018-05-17 15:15:06,868 - INFO # 
2018-05-17 15:15:06,868 - INFO # FSR/FAR:
2018-05-17 15:15:06,868 - INFO #  CFSR: 0x00008200
2018-05-17 15:15:06,868 - INFO #  HFSR: 0x40000000
2018-05-17 15:15:06,869 - INFO #  DFSR: 0x00000008
2018-05-17 15:15:06,869 - INFO #  AFSR: 0x00000000
2018-05-17 15:15:06,883 - INFO #  BFAR: 0x2002c8d0
2018-05-17 15:15:06,883 - INFO # Misc
2018-05-17 15:15:06,883 - INFO # EXC_RET: 0xfffffff1
2018-05-17 15:15:06,884 - INFO # Attempting to reconstruct state for debugging...
2018-05-17 15:15:06,884 - INFO # In GDB:
2018-05-17 15:15:06,884 - INFO #   set $pc=0x800025c
2018-05-17 15:15:06,884 - INFO #   frame 0
2018-05-17 15:15:06,884 - INFO #   bt

And here is the debug result:

Remote debugging using :3333
hard_fault_handler (sp=0x2002c8d0, corrupted=536876580, exc_return=11, r4_to_r11_stack=0xa)
    at /home/clementc/Projects/Stage-2018/RIOT/cpu/cortexm_common/vectors_cortexm.c:330
330	    __BKPT(1);
(gdb) set $pc=0x800025c
(gdb) frame 0
#0  0x0800025c in sched_run () at /home/clementc/Projects/Stage-2018/RIOT/core/sched.c:120
120	        if (active_stat->laststart) {
(gdb) bt
#0  0x0800025c in sched_run () at /home/clementc/Projects/Stage-2018/RIOT/core/sched.c:120
#1  0x0800047c in isr_svc () at /home/clementc/Projects/Stage-2018/RIOT/cpu/cortexm_common/thread_arch.c:334
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) 

A similar issue was discussed here: #5001

Thank you for your help

@smlng smlng added the Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) label May 28, 2018
@smlng
Copy link
Member

smlng commented May 28, 2018

Hi @ClementChotard can you try compiling with DEVELHELP=0 make likely a timing issue with ISR and (too much) debug code

@clem844
Copy link
Author

clem844 commented May 28, 2018

Hi @smlng thanks for replying. I started to test and it seems to work now! I will run more tests and keep you updated.

@clem844
Copy link
Author

clem844 commented May 29, 2018

Unfortunately, the problem remains the same... There is about 10 minutes before it crashes. I also increased the msgQ size that sends messages from the cb to the Thread.

@aabadie
Copy link
Contributor

aabadie commented May 29, 2018

Can you try to share the same callback function in each uart_init and use arg to determine the UART source of each character ? Then you can use this information in the IPC message sent from the callback.
See here for an (old and maybe broken) example.

Maybe you could share you minimal version of your application so we can try on our side ?

@kYc0o
Copy link
Contributor

kYc0o commented May 29, 2018

@ClementChotard can you also try to print a ps(); from time to time? Or at the end of each of your tasks? Maybe you're running out of memory or have a stack overflow.

@clem844
Copy link
Author

clem844 commented May 29, 2018

I figured out, the problem comes from too much print as suggested by @smlng. I was printing every message that it received and eventually it ends up by crashing the system. Thanks, problem solved.

@clem844 clem844 closed this as completed May 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

No branches or pull requests

5 participants