Skip to content

Commit

Permalink
configUSE_TRACE_FACILITY must be enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrr committed May 18, 2023
1 parent 956af3a commit e5fafec
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
12 changes: 5 additions & 7 deletions include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,14 @@
#define configUSE_DAEMON_TASK_STARTUP_HOOK 0

/* Run time and task stats gathering related definitions. */
#define configUSE_TRACE_FACILITY 0 // switch on task status output
#define configGENERATE_RUN_TIME_STATS configUSE_TRACE_FACILITY
#define configGENERATE_RUN_TIME_STATS 0 // switch on task status output
#define configUSE_STATS_FORMATTING_FUNCTIONS 0

#if configUSE_TRACE_FACILITY
#if configGENERATE_RUN_TIME_STATS
#define TF_TIMER_BASE _u(0x40054000)
#define TF_TIMER_TIMERAWL_OFFSET _u(0x00000028)

#warning "configUSE_TRACE_FACILITY is set"
#warning "configGENERATE_RUN_TIME_STATS is set"
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() do {} while( 0 )
#define portALT_GET_RUN_TIME_COUNTER_VALUE( dest ) ( dest = *((uint32_t *)(TF_TIMER_BASE + TF_TIMER_TIMERAWL_OFFSET)) )
#endif
Expand Down Expand Up @@ -123,9 +122,8 @@
#define configRUN_MULTIPLE_PRIORITIES 1
#if configNUM_CORES != 1
#define configUSE_CORE_AFFINITY 1
#endif
#if !defined(configUSE_CORE_AFFINITY) || configUSE_CORE_AFFINITY == 0
#define xTaskCreateAffinitySet(FUN,NAM,STK,PAR,PRI,AFF,HND) xTaskCreate(FUN,NAM,STK,PAR,PRI,HND)
#undef configUSE_TRACE_FACILITY
#define configUSE_TRACE_FACILITY 1 // required for setup of core affinity
#endif

/* RP2040 specific */
Expand Down
8 changes: 4 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void dap_task(void *ptr)



#if configUSE_TRACE_FACILITY
#if configGENERATE_RUN_TIME_STATS
static uint32_t tusb_count;
static TimerHandle_t timer_task_stat;
static EventGroupHandle_t events_task_stat;
Expand Down Expand Up @@ -473,7 +473,7 @@ void print_task_stat(void *ptr)
prev_tick_us[task_ndx] = curr_tick;
}
printf("---------------------------------------\n");
printf(" %3lu %3lu\n", percent_sum, percent_total_sum);
printf(" %4lu %4lu\n", percent_sum, percent_total_sum);
}
printf("---------------------------------------\n");

Expand Down Expand Up @@ -542,7 +542,7 @@ void usb_thread(void *ptr)
xTaskCreate(dap_task, "CMSIS-DAP", configMINIMAL_STACK_SIZE, NULL, DAP_TASK_PRIO, &dap_taskhandle);
#endif

#if configUSE_TRACE_FACILITY
#if configGENERATE_RUN_TIME_STATS
{
TaskHandle_t task_stat_handle;
xTaskCreate(print_task_stat, "Print Task Stat", configMINIMAL_STACK_SIZE, NULL, 30, &task_stat_handle);
Expand Down Expand Up @@ -585,7 +585,7 @@ void usb_thread(void *ptr)

tusb_init();
for (;;) {
#if configUSE_TRACE_FACILITY
#if configGENERATE_RUN_TIME_STATS
++tusb_count;
#endif
tud_task(); // the FreeRTOS version goes into blocking state if its event queue is empty
Expand Down
13 changes: 6 additions & 7 deletions src/rtt_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static uint16_t ft_channel;
static uint32_t ft_rtt_cb;
static uint8_t ft_buf[256];
static uint32_t ft_cnt;
static bool ft_ok;

static void rtt_from_target_thread(void *)
/**
Expand All @@ -240,13 +241,11 @@ static void rtt_from_target_thread(void *)
*/
{
for (;;) {
bool ok;

xEventGroupWaitBits(events, EV_RTT_FROM_TARGET_STRT, pdTRUE, pdFALSE, portMAX_DELAY);

ok = swd_read_word(ft_rtt_cb + offsetof(SEGGER_RTT_CB, aUp[ft_channel].WrOff), (uint32_t *)&(ft_aUp->WrOff));
ft_ok = swd_read_word(ft_rtt_cb + offsetof(SEGGER_RTT_CB, aUp[ft_channel].WrOff), (uint32_t *)&(ft_aUp->WrOff));

if (ok && ft_aUp->WrOff != ft_aUp->RdOff) {
if (ft_ok && ft_aUp->WrOff != ft_aUp->RdOff) {
//
// fetch data from target
//
Expand All @@ -259,9 +258,9 @@ static void rtt_from_target_thread(void *)
ft_cnt = MIN(ft_cnt, sizeof(ft_buf));

memset(ft_buf, 0, sizeof(ft_buf));
ok = ok && swd_read_memory((uint32_t)ft_aUp->pBuffer + ft_aUp->RdOff, ft_buf, ft_cnt);
ft_ok = ft_ok && swd_read_memory((uint32_t)ft_aUp->pBuffer + ft_aUp->RdOff, ft_buf, ft_cnt);
ft_aUp->RdOff = (ft_aUp->RdOff + ft_cnt) % ft_aUp->SizeOfBuffer;
ok = ok && swd_write_word(ft_rtt_cb + offsetof(SEGGER_RTT_CB, aUp[ft_channel].RdOff), ft_aUp->RdOff);
ft_ok = ft_ok && swd_write_word(ft_rtt_cb + offsetof(SEGGER_RTT_CB, aUp[ft_channel].RdOff), ft_aUp->RdOff);
}
else {
ft_cnt = 0;
Expand Down Expand Up @@ -299,7 +298,7 @@ static bool rtt_from_target(uint32_t rtt_cb, uint16_t channel, SEGGER_RTT_BUFFER
*worked = true;
}
}
return true;
return ft_ok;
#else
bool ok = true;
uint8_t buf[256];
Expand Down

0 comments on commit e5fafec

Please sign in to comment.