Re: [DEV] RP2040 support
Posted: Sun Apr 04, 2021 4:33 pm
Well this should not happen, threads should stay in their own instance, let me check.
Giovanni
Giovanni
Code: Select all
chDbgAssert(port_get_core_id() == __sch_get_currthread(currcore)->owner->core_id, "");
Code: Select all
ChibiOS/RT Shell
RP2040> ^D
logout
*** Trace resumed by user or command ***
[ 791.008][INFO ][ main.c 0099][ main] MAIN > Main (C0) running on core 0
======== Trace output was stalled here until I typed a key to get the shell ===========
[ 792.000][INFO ][ c1_main.c 0118][ main] MAIN > Main (C1) running on core 1
[ 794.008][INFO ][ main.c 0099][ main] MAIN > Main (C0) running on core 0
[ 801.691][INFO ][ console.c 0241][ console] CON > Enter command mode on console channel
*** Trace suspended - type ^D or use the 'exit' command to resume trace ***
ChibiOS/RT Shell
RP2040>
Code: Select all
/**
* @brief The trace macro
*/
#define CTRACE(lvl, id, format, args...) \
do { \
if (current_trace_level > TL_OFF) { \
trace_print(lvl, id, __FILE__, __LINE__, format, ##args); \
} \
} while (0)
Code: Select all
/**
* @brief Output trace message.
*
* @param[in] lvl Trace level for this trace message
* @param[in] id Trace source identifier
* @param[in] path File path origin of trace message
* @param[in] line Line number in source file
* @param[in] format Output format string
* @param[in] ... Variable arguments list
*
*/
void trace_print(trace_level_t lvl, trace_source_t id,
char* path, uint32_t line, char* format, ...) {
#if (CH_CFG_USE_TIMESTAMP == TRUE)
systimestamp_t timestamp = chVTGetTimeStamp();
time_secs_t secs = chTimeTS2S(timestamp);
time_msecs_t msecs = chTSSecMS(timestamp);
#else
systime_t timestamp = chVTGetSystemTime();
time_secs_t secs = TIME_I2S(timestamp % 1000);
time_msecs_t msecs = TIME_I2MS(timestamp % 1000);
#endif
if (console != NULL && lvl <= current_trace_level) {
if (sysIsTraceOutputAvailable()) {
/* Wait for trace output stream to be available. */
chBSemWait(&trace_sem);
/* Handle differing trace sources. */
switch (id) {
default:
/* Output time stamp. */
if (TRACE_SHOW_TIME) {
chprintf((BaseSequentialStream*)console, TRACE_OPEN_FIELD);
chprintf((BaseSequentialStream*)console, TRACE_TIME_FORMAT,
(time_secs_t)secs, msecs);
chprintf((BaseSequentialStream*)console, TRACE_CLOSE_FIELD);
}
/* Next print the trace level string. */
chprintf((BaseSequentialStream*)console, TRACE_OPEN_FIELD);
trace_render_level_name(lvl, (BaseSequentialStream*)console,
TRACE_LEVEL_FORMAT);
chprintf((BaseSequentialStream*)console, TRACE_CLOSE_FIELD);
/* Then the file name. */
if (TRACE_SHOW_FILE) {
/* Get the file name only from the path. */
chprintf((BaseSequentialStream*)console, TRACE_OPEN_FIELD);
char* file = ((strrchr(path, '/') != NULL) ?
strrchr(path, '/') + 1 : path);
chprintf((BaseSequentialStream*)console, TRACE_FILE_FORMAT, file,
line);
chprintf((BaseSequentialStream*)console, TRACE_CLOSE_FIELD);
}
/* Next is thread. */
if (TRACE_SHOW_THREAD) {
chprintf((BaseSequentialStream*)console, TRACE_OPEN_FIELD);
chprintf((BaseSequentialStream*)console, TRACE_THREAD_FORMAT,
chThdGetSelfX()->name);
chprintf((BaseSequentialStream*)console, TRACE_CLOSE_FIELD);
}
/* And finally the trace source data. */
chprintf((BaseSequentialStream*)console, TRACE_SOURCE_FORMAT,
trace_get_source_name(id));
break;
case _INDENT: {
/* Indent skips all the identifiers in a line to enable
multi-line output as a table of data. */
chprintf((BaseSequentialStream*)console, "%s", TRACE_TAB);
break;
}
} /* End switch (...) */
/* Render the arguments. */
va_list args;
va_start(args, format);
chvprintf((BaseSequentialStream*)console, format, args);
va_end(args);
chprintf((BaseSequentialStream*)console, "\r\n");
/* Release access to the trace output stream. */
chBSemSignal(&trace_sem);
}
}
/* Capture any error message in the errors store. Get exclusive access
before writing. */
if (lvl == TL_ERR) {
chBSemWait(&trace_sem);
uint8_t strcnt = chsnprintf(error_list[error_counter],
ERROR_LIST_LENGTH, TRACE_TIME_FORMAT" ", (time_secs_t)secs, msecs);
va_list args;
va_start(args, format);
chvsnprintf(&error_list[error_counter][strcnt],
ERROR_LIST_LENGTH - strcnt, format, args);
va_end(args);
error_counter = (error_counter + 1) % ERROR_LIST_SIZE;
chBSemSignal(&trace_sem);
}
}