This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
RE: Adding CYGINT_PROFILE_HAL_TIMER to my platform
- From: "Christophe Coutand" <ccoutand at stmi dot com>
- To: "Elad Yosef" <elad dot yosef at gmail dot com>, <ecos-discuss at ecos dot sourceware dot org>
- Date: Mon, 7 Feb 2011 06:27:31 -0800
- Subject: RE: [ECOS] Adding CYGINT_PROFILE_HAL_TIMER to my platform
- References: <AANLkTikUHi3aQb2ZiidPVaPZWunAnXA-Rs0ZkqYzR7s_@mail.gmail.com>
Documentation is here:
http://ecos.sourceware.org/docs-latest/ref/gprof.html
The CDL for your variant/platform must implement the profiling timer,
for example check
\hal\cortexm\stm32\var\current\cdl\hal_cortexm_stm32.cdl (from anoncvs)
implements CYGINT_PROFILE_HAL_TIMER
The STM32 variant implements the timer in
hal\cortexm\stm32\var\current\src\stm32_misc.c. You basically need to
fill the init function ( hal_enable_profile_timer(int resolution) ) that
starts the timer and then from the timer ISR, call __profile_hit(). This
is the basic profiling support, for call graph you need some addition
code. You can start the profiling from your main() function as described
here :
http://ecos.sourceware.org/docs-latest/ref/gprof.html#GPROF-PROCESS
stm32_misc.c:
//======================================================================
====
// Profiling timer
//
// Implementation of profiling support using general-purpose timer TIM2.
#ifdef CYGFUN_HAL_CORTEXM_STM32_PROFILE_TIMER
// Use TIM2 for profiling
#define STM32_TIMER_PROFILE CYGHWR_HAL_STM32_TIM2
#define HAL_INTERRUPT_PROFILE CYGNUM_HAL_INTERRUPT_TIM2
// Profiling timer ISR
static cyg_uint32 profile_isr(CYG_ADDRWORD vector, CYG_ADDRWORD data)
{
extern HAL_SavedRegisters *hal_saved_interrupt_state;
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_SR, 0); //
clear interrupt pending flag
HAL_INTERRUPT_ACKNOWLEDGE(HAL_INTERRUPT_PROFILE);
__profile_hit(hal_saved_interrupt_state->u.interrupt.pc);
return CYG_ISR_HANDLED;
}
// Profiling timer setup
int hal_enable_profile_timer(int resolution)
{
CYG_ASSERT(resolution < 0x10000, "Invalid profile timer
resolution"); // 16 bits only
// Attach ISR
HAL_INTERRUPT_ATTACH(HAL_INTERRUPT_PROFILE, &profile_isr, 0x1111,
0);
HAL_INTERRUPT_UNMASK(HAL_INTERRUPT_PROFILE);
// Setup timer
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_PSC,
(hal_stm32_timer_clock(STM32_TIMER_PROFILE) / 1000000) - 1); //
prescale to microseconds
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_CR2, 0);
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_DIER,
CYGHWR_HAL_STM32_TIM_DIER_UIE);
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_ARR,
resolution);
HAL_WRITE_UINT32(STM32_TIMER_PROFILE+CYGHWR_HAL_STM32_TIM_CR1,
CYGHWR_HAL_STM32_TIM_CR1_CEN);
return resolution;
}
#endif // CYGFUN_HAL_CORTEXM_STM32_PROFILE_TIMER
-----Original Message-----
From: ecos-discuss-owner@ecos.sourceware.org
[mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Elad Yosef
Sent: 7. februar 2011 15:10
To: ecos-discuss@ecos.sourceware.org
Subject: [ECOS] Adding CYGINT_PROFILE_HAL_TIMER to my platform
Hi,
I want to add profiling to my platform but CYGINT_PROFILE_HAL_TIMER is
not defined in any of my cdl files.
From reading in reference I understand that I need some external HW
timer, I have such one.
My problem is how to attach this HW timer ticks to the gprof?
I didn't really understand the reference
You can point to any implementation in other platform
Thanks
Elad
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss