I'm using ChibiStudio with OpenOCD 0.6.1 to compile and run a simple program on an STM32F0 Discovery board.
Debug enabled - specifically:
#define CH_DBG_SYSTEM_STATE_CHECK TRUE
In the call from chSysInit(), the program crashes with error SV#3 - 'misplaced chSysEnable()'.
(If debug is disabled, the program crashes with 'Unhandled exception')
If I simply load the program into flash, and run without the JTAG debugger, it runs as expected.
Program is as follows (essentially the standard LED flashing program):
Code: Select all
#include "ch.h"
#include "hal.h"
/*
* Blue LED blinker thread, times are in milliseconds.
*/
static WORKING_AREA(waThread1, 128);
__attribute__((noreturn)) static msg_t Thread1(void *arg)
{
(void)arg;
chRegSetThreadName("blinker1");
while (TRUE)
{
palClearPad(GPIOC, GPIOC_LED4);
chThdSleepMilliseconds(500);
palSetPad(GPIOC, GPIOC_LED4);
chThdSleepMilliseconds(500);
}
}
int main(void)
{
halInit();
chSysInit();
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
while (TRUE) {
chThdSleepMilliseconds(500);
}
}
Any suggestions as to the problem, or how to debug it?