It would be nice to have a few more CH_CFG_*_HOOK
The one I found missing for my needs are:
* CH_CFG_IRQ_PROLOGUE_HOOK, CH_CFG_IRQ_EPILOGUE_HOOK
* CH_CFG_SCHED_THREAD_READY_HOOK(tp), CH_CFG_SCHED_THREAD_SLEEP_HOOK(tp, newstate)
This would allow to easily interface with SystemView from Segger
( https://www.segger.com/systemview.html )
[FEATURE REQUEST] More hooks
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: [FEATURE REQUEST] More hooks
Hi,
I will try to include this in RT4 and NIL2, both are currently under development.
BTW RT4 already supports an enhanced trace buffer that keeps track of all state changes and also ISR prologue/epilogue, you can see also ISR preempting other ISRs. Would be possible to use the information stored there? it is possible that hooks are not even required.
Read this thread: viewtopic.php?f=3&t=3094#p23986
Edit: CH_CFG_CONTEXT_SWITCH_HOOK should always allow to hook transitions to ready and to sleep, just check the states of the threads being switched in/out.
Giovanni
I will try to include this in RT4 and NIL2, both are currently under development.
BTW RT4 already supports an enhanced trace buffer that keeps track of all state changes and also ISR prologue/epilogue, you can see also ISR preempting other ISRs. Would be possible to use the information stored there? it is possible that hooks are not even required.
Read this thread: viewtopic.php?f=3&t=3094#p23986
Edit: CH_CFG_CONTEXT_SWITCH_HOOK should always allow to hook transitions to ready and to sleep, just check the states of the threads being switched in/out.
Giovanni
Re: [FEATURE REQUEST] More hooks
Great.
I'm already using the context switch hook, but SystemView seems to also make a distinction between "ready" ("Record a Task Start Ready event.") and "start" ("The Task Start event corresponds to when a task has started to execute rather than when it is ready to execute.").* Which I interpreted as the chReady and chSysSwich.
Don't know if the trace buffer could be enough to interface with SystemView (the difficult part to use a closed source program, any alternative is welcomed), but it would surely be very nice to also have a hook in the trace buffer itself (in chDbgWriteTraceI?)
I just read the thread about the trace buffer. I'm wondering how the information is transfered from the board to the eclipse view. Is it by reading memory directly from the board using a jtag/swd?
I'm already using the context switch hook, but SystemView seems to also make a distinction between "ready" ("Record a Task Start Ready event.") and "start" ("The Task Start event corresponds to when a task has started to execute rather than when it is ready to execute.").* Which I interpreted as the chReady and chSysSwich.
Don't know if the trace buffer could be enough to interface with SystemView (the difficult part to use a closed source program, any alternative is welcomed), but it would surely be very nice to also have a hook in the trace buffer itself (in chDbgWriteTraceI?)
I just read the thread about the trace buffer. I'm wondering how the information is transfered from the board to the eclipse view. Is it by reading memory directly from the board using a jtag/swd?
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: [FEATURE REQUEST] More hooks
Correct, it is done using the debugger interface.
Good idea about the trace hook, I will add that tomorrow.
Note you know when the thread starts executing, it is when it goes CH_STATE_CURRENT after being created, you have both info.
Giovanni
Good idea about the trace hook, I will add that tomorrow.
Note you know when the thread starts executing, it is when it goes CH_STATE_CURRENT after being created, you have both info.
Code: Select all
#define CH_STATE_READY (tstate_t)0 /**< @brief Waiting on the
ready list. */
#define CH_STATE_CURRENT (tstate_t)1 /**< @brief Currently running. */
#define CH_STATE_WTSTART (tstate_t)2 /**< @brief Just created. */
#define CH_STATE_SUSPENDED (tstate_t)3 /**< @brief Suspended state. */
#define CH_STATE_QUEUED (tstate_t)4 /**< @brief On an I/O queue. */
#define CH_STATE_WTSEM (tstate_t)5 /**< @brief On a semaphore. */
#define CH_STATE_WTMTX (tstate_t)6 /**< @brief On a mutex. */
#define CH_STATE_WTCOND (tstate_t)7 /**< @brief On a cond.variable.*/
#define CH_STATE_SLEEPING (tstate_t)8 /**< @brief Sleeping. */
#define CH_STATE_WTEXIT (tstate_t)9 /**< @brief Waiting a thread. */
#define CH_STATE_WTOREVT (tstate_t)10 /**< @brief One event. */
#define CH_STATE_WTANDEVT (tstate_t)11 /**< @brief Several events. */
#define CH_STATE_SNDMSGQ (tstate_t)12 /**< @brief Sending a message,
in queue. */
#define CH_STATE_SNDMSG (tstate_t)13 /**< @brief Sent a message,
waiting answer. */
#define CH_STATE_WTMSG (tstate_t)14 /**< @brief Waiting for a
message. */
#define CH_STATE_FINAL (tstate_t)15 /**< @brief Thread terminated. */
Giovanni
Re: [FEATURE REQUEST] More hooks
I just found this thread because I try to add Segger SystemView support to my project which is based on ChibiOS 3.1 at the moment.
I tried to use the context switch hook but I ran into locking errors. The SystemView integration sources don't have anything like the I-class API.
I tried to use the context switch hook but I ran into locking errors. The SystemView integration sources don't have anything like the I-class API.
Code: Select all
#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
SEGGER_SYSVIEW_OnTaskStopExec(); \
SEGGER_SYSVIEW_OnTaskStartExec((unsigned)ntp); \
}
Re: [FEATURE REQUEST] More hooks
Thank you. That works. I have to do the locking outside the kernel on my own with this solution, but that should be no problem.
Now I ran in a stack overflow issue. I have the feeling that I have to make all stacks bigger or I didn't find the offending stack yet.
Now I ran in a stack overflow issue. I have the feeling that I have to make all stacks bigger or I didn't find the offending stack yet.
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: [FEATURE REQUEST] More hooks
Note that there are hooks for thread creation and exit.
In RT4 (now in trunk) there are all the required hook for that tool to work.
Giovanni
In RT4 (now in trunk) there are all the required hook for that tool to work.
Giovanni
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Who is online
Users browsing this forum: No registered users and 37 guests