Debug access without reset?
Moderator: RoccoMarco
Debug access without reset?
Hi,
I have been hunting a bug that is extremely strange on my STM32F405 using ChibiStudio and a ST-Link V2.
The program works fine as long as the debugger is connected, but if I start the system without the debugger connected it hangs very quickly (within 0-5 seconds).
So I want to let the system hang and then insert the debugger to see if it is in the SysHalt (and see the reason) or where it has stopped.
Is this possible? Because in ChibiStuidio I must flash to access with the debugger (?).
Or is the some other good procedure to debug this kind of problem? I have never had this type of problem before, so I am not sure how to address it.
Thanks in advance!
I have been hunting a bug that is extremely strange on my STM32F405 using ChibiStudio and a ST-Link V2.
The program works fine as long as the debugger is connected, but if I start the system without the debugger connected it hangs very quickly (within 0-5 seconds).
So I want to let the system hang and then insert the debugger to see if it is in the SysHalt (and see the reason) or where it has stopped.
Is this possible? Because in ChibiStuidio I must flash to access with the debugger (?).
Or is the some other good procedure to debug this kind of problem? I have never had this type of problem before, so I am not sure how to address it.
Thanks in advance!
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Debug access without reset?
This is very strange, are you running/debugging with debug options enabled?
Giovanni
Giovanni
Re: Debug access without reset?
Okey, after some hacking I found how to access it without a reset (
) and it hangs here (in the assert):
So apparently I am not using chSchResceduleS() somewhere.
Here is the call that makes this assert go wrong:
Does this need a call to chSchResceduleS()?
Best Regards
Emil
Code: Select all
/**
* @brief Leaves the kernel lock mode.
*
* @special
*/
static inline void chSysUnlock(void) {
_dbg_check_unlock();
_stats_stop_measure_crit_thd();
/* The following condition can be triggered by the use of i-class functions
in a critical section not followed by a chSchResceduleS(), this means
that the current thread has a lower priority than the next thread in
the ready list.*/
chDbgAssert(ch.rlist.r_current->p_prio >= ch.rlist.r_queue.p_next->p_prio,
"priority violation, missing reschedule");
port_unlock();
}So apparently I am not using chSchResceduleS() somewhere.
Here is the call that makes this assert go wrong:
Code: Select all
osalSysLock();
if (chEvtIsListeningI(&estimation_events_es))
chEvtBroadcastFlagsI(&estimation_events_es, ESTIMATION_NEW_ESTIMATION_EVENTMASK);
osalSysUnlock();Does this need a call to chSchResceduleS()?
Best Regards
Emil
Re: Debug access without reset?
Of course the answer was yes (which was also in the documentation).
Just one question though, I have a
inside a ISR (with osalSysLockFromISR() ). But chSchResceduleS() is only allowed inside thread context.
And I am anuable to find the ISR version of that function.
What is the correct procedure then?
Just one question though, I have a
Code: Select all
if (chEvtIsListeningI(&......))
chEvtBroadcastFlagsI(&....., ......);inside a ISR (with osalSysLockFromISR() ). But chSchResceduleS() is only allowed inside thread context.
And I am anuable to find the ISR version of that function.
What is the correct procedure then?
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Debug access without reset?
You cannot context switch directly in a ISR or callback, so only i-class functions there. The reschedule is performed automatically on ISR/callback exit so there is no equivalent for chSchResceduleS().
When an assertion fails you should retrieve the message pointed by dbg_panic_msg, it specifies the nature of the error (see the error codes table in the debug section of the kernel documentation).
Giovanni
When an assertion fails you should retrieve the message pointed by dbg_panic_msg, it specifies the nature of the error (see the error codes table in the debug section of the kernel documentation).
Giovanni
Re: Debug access without reset?
Ah thank you for the explanation!
I was digging in the ISR exit codes and found exactly what you are telling me.
Yeah, the dbg_panic_msg I got was "chSysUnlock" but the Link Register was pointing to the call in my previous post, that's how I found it.
The string "priority violation, missing reschedule" did not show, since chDbgAssert is defined as
so to get the extra information I will have to define my own assert (this I have done now to get more exact errors).
But after this I feel like I have a much better feel for ChibiOS and how to catch bugs.
Thanks for the help Giovanni!
I was digging in the ISR exit codes and found exactly what you are telling me.
Yeah, the dbg_panic_msg I got was "chSysUnlock" but the Link Register was pointing to the call in my previous post, that's how I found it.
The string "priority violation, missing reschedule" did not show, since chDbgAssert is defined as
Code: Select all
#if !defined(chDbgAssert)
#define chDbgAssert(c, r) do { \
if (NIL_CFG_ENABLE_ASSERTS && !(c)) \
chSysHalt(__func__); \
} while (0)
#endif /* !defined(chDbgAssert) */But after this I feel like I have a much better feel for ChibiOS and how to catch bugs.
Thanks for the help Giovanni!
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Debug access without reset?
The string is not used by default because footprint, it is there for extended assertions implementations, that is basically what you did.
Giovanni
Giovanni
Re: Debug access without reset?
Ah yes, I remember when we discussed this the last time.
However, I must ask, what is the standard procedure to define a new chDbgAssert?
I would assume to put it in chconf.h, but the chdebug.h file does not include any file so I am a bit unsure of how to best override the standard assert.
However, I must ask, what is the standard procedure to define a new chDbgAssert?
I would assume to put it in chconf.h, but the chdebug.h file does not include any file so I am a bit unsure of how to best override the standard assert.
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times