I just tried to put the demo for STM32F030 Nucleo board, but I found that usart_init() causes the controller to crash into Hard Fault.
It seems to crash on this line:
Code: Select all
/* serial_lld.c:96 */
u->BRR = (uint16_t)(sdp->clock / config->speed);
I tried initializing the USART directly:
Code: Select all
USART2->BRR = 1250Or somewhat indirectly:
Code: Select all
USART_TypeDef *u = USART2;
u->BRR = 1250;
And I tried -O0, -O2, -Os options, and on USART1 port (USART2 is already used by ST-Link, and I don't think I can get anything out there. I might be wrong) but it crashes only when I try to use sdStart(), not when I initialize directly. I suspect that it is a stack overflow, so I tried printing __main_stack_size__, and GDB prints something like this:
Code: Select all
(gdb) p __main_stack_size__
$1 = 98 'b'
If I try to increase from 0x400 to 0x500, I get:
Code: Select all
(gdb) p __main_stack_size__
$1 = -105 '\227'
I don't understand linker scripts, so I can't understand these. At least I suppose that a Demo should work out of the box... If I comment out everything serial, the LED blinks correctly.