Page 2 of 3

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Fri Apr 13, 2012 2:02 pm
by DrunkenDonkey
//on a related note, if you move to Eclipse, you can use Giovanni's great plugin to monitor every thread stack usage to see problems like that, also tweak the stacks size to get the max out of the available memory.

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Mon Apr 16, 2012 4:50 am
by DeusExMachina
I changed all options to TRUE in chconf.h but and recompiled project. But this doesn't help. There were not any warnings or panic messages. chDbgCheckClassS() in debugger executes successfully.
Also I take original project ARMCM3-STM32F103 for IAR without any modifications (only select ST-link in options) - and there was the same problem (with enabled debugging options too). So, I think it's time to move to Eclipse :)

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 7:32 am
by DeusExMachina
After all i moved to eclipse cdt + code sourcery + atolic gdb + chibios plugin.
Demo STM32-Discovery works well. Debuggung is OK.
Unfortunatelly STM32F103 demo doesn't work. Even before execution debugger stops at

Code: Select all

2 __main_stack_base__()  0x20000004   
          __main_stack_base__:
20000000:   andcs r4, r0, r0
20000004:   andcs r0, r0, r5, lsr #2 << exectution cursor


more over, after this ST-LINK_gdbserver.exe crashes :(
changes i've made in project files:
1. in makefile changed STM32F103xB.ld to LDSCRIPT= $(PORTLD)/STM32F103xC.ld
2 in board.h i've changed STM32F10X_MD to STM32F10X_HD

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 7:46 am
by Giovanni
I think you forgot "jump ResetHandler" in the debug configuration:

http://www.chibios.org/dokuwiki/doku.ph ... figuration

Giovanni

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 7:52 am
by DeusExMachina
I configured Eclipse right according this article. Jump is in place :)

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 8:02 am
by Giovanni
No idea, it works for me.

Verify that STM32F103xC.ld does not contain any errors, it is not provided with the OS so I assume you added it.

Giovanni

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 12:09 pm
by DeusExMachina
Finally i got overflow in main thread:
Image
After all i can flash and debug MCU using stm32F100-Discovery demo. I changed MCU type to STM32F10X_HD in board.h
I have created ST32F103xC.ld using ST32F107xC.ld

Code: Select all

/*
 * ST32F103xC memory setup.
 */
__main_stack_size__     = 0x0400;
__process_stack_size__  = 0x0400;

MEMORY
{
    flash : org = 0x08000000, len = 256k
    ram : org = 0x20000000, len = 48k
}

Where I should enlarge stack size? In linker script?

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Tue Apr 17, 2012 12:22 pm
by Giovanni
The stack of the main() thread is defined by __process_stack_size__ but the default is 1KB, I don't think it can't overflow in the standard demo unless you added something in the main().

Giovanni

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Wed Apr 18, 2012 7:50 am
by DeusExMachina
contents of main() is stripped.
http://pastebin.ru/kzVYsEhg
I found that main stack overflows just after chSysInit() function call.

Even when i comment halInit() i got the same problem on chSysInit()

Re: stm32f103vct6 freeze after chThdSleepMilliseconds() - IA

Posted: Wed Apr 18, 2012 8:10 am
by Giovanni
It is possible it is an HW problem, is the STM32 configured to run from Flash? it looks like it jumps on RAM after reset.

Giovanni