Failed to flash spe-fw with my firmware

Hi,

I got the timer-app.c demo code working, but when I tried to write my own firmware and flash it to the SPE, I always got stuck on this line:

[   6.7983 ] tegrarcm_v2 --isapplet

Here is the code that I’m trying to run. What I’m trying to do is to start a timer inside the timer callback, so that I can get the timer to trigger on a desired time.

17 void PPS_timer_callback_1(void *data) {                                          
 16                                                                                  
 15     uint32_t usec, osc, tsc_hi, tsc_lo;                                          
 14                                                                                  
 13     usec = tegra_tke_get_usec();                                                 
 12     osc = tegra_tke_get_osc();                                                   
 11     tegra_tke_get_tsc(&tsc_hi, &tsc_lo);                                         
 10                                                                                  
  9     uint32_t next_stamp = get_next_stamp(usec, STEP);                            
  8                                                                                  
  7     printf_isr("Timer2 irq triggered, usec = %lu, osc = %lu "                    
  6                "tsc_hi = %lu, tsc_lo = %lu, next_stamp = %lu\r\n",               
  5                usec, osc, tsc_hi, tsc_lo, next_stamp);                           
  4                                                                                  
  3     // calculate new timer duration and setup the timer                          
  2     uint32_t timer_last = next_stamp - usec;                                     
  1     tegra_tke_set_up_timer(&tegra_tke_id_timer2, TEGRA_TKE_CLK_SRC_USECCNT,      
64                     false, timer_last, PPS_timer_callback_2, 0);                  
  1 }                                                                                
  2                                                                                  
  3 void sensor_trigger_init(void) {                                                 
  4     tegra_tke_set_up_timer(&tegra_tke_id_timer1, TEGRA_TKE_CLK_SRC_USECCNT,      
  5                    false, PPS_INIT, PPS_timer_callback_1, 0);                    
  6 }

The code compiled just fine but can’t get flashed into the Xavier. Any idea why would cause that? Thanks!

Hello, hengruiz:
I think it’s better not to call tegra_tke_set_up_timer in ISR context, i.e. PPS_timer_callback_1.
Please use periodic timer interrupt instead.
For one-shot timer, you may need another task to re-initialize the timer.

br
Chenjian