Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


gprof gnu profiling tools ?

Hi everyone,

Beeing designing an industrial project based upon stm32f407VGT MCU I am interested in creating a poor man’s profiling function counting the frequency of calls to selected functions.

But before re-inventing the wheel told myself  : ” maybe someone allready did that for stm32workbench ?”

Is there any way, using stm32workbench, to be profiling function calls on target ?

I found that on the web :

http://mcuoneclipse.com/2015/08/11/sneak-preview-profiling-bare-metal-microcontroller-applications-with-gnu-gprof/Question

Is there an allready integrated to stm32workbench method for profiling ?

Thank you all :-)

for what i now on grof it si untrusive profiling mean you must frist build with prodfiling option
then you run that code
while runing a “large file” with timing get created
That is what gprof then analyee
that is commonly not suported by mcu toolset soem maye by putign the info in ram on the target
I can’t say for gcc that is used with ac6 and bare metal arm embededd
Actulaay i’m curious to know if it is suported how to get it working

if you look for a single functionratehr fix timing then simply instrument the code
rename the original function create a wraper func than will record timer before and after call in a small cicurlar buffer
for instance
org_foo(.....)
{...}

uint32_t t8;
int n=0;
foo(...){
uint32_t t0,tf;
t0 = DWT->CYCCNT;
org_foo(....)
tf = DWT->CYCCNT;
tn=tf-t0;
n=(n+1)%8;
}

If you place cycle counter record in the function itself then you will not get cycles related to argument passing , function prolog /epilog , call and return cost.

Without instrumenting set a break point befor the call and check the DWT->CYCCNT; step over check again and diff
compare to instrumented code you may get some minor difference due to debuggerr .


Thank you diabolo38,

I will try your method, and share with everyone if I find another way to set profiling


i have folowed the “mcu on eclipse” instruction and with a few minor change i get it to work

basicaly what i did and changed
get all proiling subfolder from github source
in gmon.c


change the symbol used to “bound” the code “text” section

if (!already_setup) {
    extern char _etext; /* end of text/code symbol, defined by linker */
    //MS the __etext is _etext on st ld file
    already_setup = 1;
    //MS 0x410 is not suitale for stm32f4 let use Reset_Handler that is just after isr table and low level init
    extern char Reset_Handler;
    monstartup((uint32_t)&Reset_Handler, (uint32_t)&_etext);
  }


in profile.c use a specific timer at 1KHz for prolining instead os systick (systick cant be cusotmized in cubemx project)
not ethat this timer get setup and started in main not best thing :-(

void TIM7_IRQHandler(void) {
  //void OSA_SysTick_Handler(void);
  static size_t pc, idx;

  //OSA_SysTick_Handler(); /* call normal Kinetis SDK SysTick handler */
  if (prof.state==PROFILE_ON) {
    pc = ((uint32_t*)(__builtin_frame_address(0)))[14]; /* get SP and use it to get the return address from stack */
    if (pc >= prof.lowpc && pc < prof.highpc) {
      idx = PROFIDX (pc, prof.lowpc, prof.scale);
      prof.counter[idx]++;
    }
  }
  //MS re-arm the specific profiler timer
  __HAL_TIM_CLEAR_IT(&htim7, TIM_IT_UPDATE);
}


customize the system_stm32f4xx.c to init the profiling
best option would be to add “prof init” as part of the “lib init array” so that no files changes would be required

void SystemInit(void)
{
	void _monInit(void);
	_monInit();
// ...


bad point is that semithosting “relative path” wan’t let create a file in the project
So rigth now i had to force “gmon.out” to obsolute path where write is ok but’s that very user specific :-(

void _mcleanup(void) {
	static const char gmon_out[] = "c:\\tmp\\gmon.out";


you can folow http://www.openstm32.org/forumthread164Question to get semihosting working and news on the file path


 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs