The system halts (port_halt()) from a debug check called while waiting for characters on the serial port, in particular the chDbgCheck(n > 0, "chIQReadTimeout"); check called by shellGetLine(), which in turns calls chIQReadTimeout(). The strange fact is that if I inspect n with gdb, it is set to 1, as expected, but the debug check triggers anyway.
Looking at dbg_panic_msg, the content is not a string.
I suspect there is some overflow around (DMA writing outside the buffer?), but I can't find where and why. The eclipse plugins reports that thread stacks are almost empty.
The other strange thing is that compiling with -O3 apparently solve the problems, but with -O0 the system systematically hangs in this point.
Any hints on where to look to debug this?
My code is pretty simple and standard:
Code: Select all
/* Shell manager initialization. */
shellInit();
/* Start the serial driver. */
sdStart(&SERIAL_DRIVER, NULL);
/* Start the ADC driver. */
adcStart(&ADC_DRIVER, NULL);
/* Starts an ADC continuous conversion. */
adcStartConversion(&ADC_DRIVER, &adcgrpcfg, adc_samples, ADC_BUF_DEPTH);
for (;;) {
if (!shelltp)
shelltp = shellCreate(&shell_cfg, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
chThdSleepMilliseconds(500);
}
Here the configuration for the conversion group:
Code: Select all
#define ADC_NUM_CHANNELS 1
#define ADC_BUF_DEPTH 8
adcsample_t adc_samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
static const ADCConversionGroup adcgrpcfg = {
TRUE,
ADC_NUM_CHANNELS,
NULL,
NULL,
0, 0, /* CR1, CR2 */
0,
ADC_SMPR2_SMP_AN3(ADC_SAMPLE_239P5), /* SMPR2 */
ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS),
0, /* SQR2 */
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN3)
};