Page 2 of 4
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 12:25 pm
I have made additional simplification of my code and now i am getting SV#3 dbg_panic_msg.
I haven't found useful information which could point what the problem is.
Please note, that some time ago because of getting this errors:
abort.c:(.text+0xa): undefined reference to `_exit'
/opt/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/../lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/lib/thumb2/libc.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text+0x14): undefined reference to `_kill'
/opt/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/../lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/lib/thumb2/libc.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text+0x28): undefined reference to `_getpid'
i have implemented empty stubs:
Code: Select all
void _exit(int status) {
while (1) {
;
}
}
int _kill(int pid, int sig) {
errno = EINVAL;
return (-1);
}
int _getpid() {
return 1;
}
Maybe this is the reason why i am having problems with threads?
When i was implementing those stubs, i found one solution. Unfortunately link to working stubs was dead.
WDYF?
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 1:19 pm
by Giovanni
Hi,
The SV# error codes are documented into the kernel reference manual under modules->debug.
The meaning is "SV#3, misplaced chSysEnable()". You perform a chSysEnable() when interrupts are already enabled, note that chSysInit() calls chSysEnable() internally. Do you call something before chSysInit()?
I suggest that you start from a clean sheet main() taken from a demo then start adding your own addition in small steps.
Giovanni
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 3:00 pm
With this options enabled in chconf.h:
Code: Select all
/**
* @brief Debug option, system state check.
* @details If enabled the correct call protocol for system APIs is checked
* at runtime.
*
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_SYSTEM_STATE_CHECK TRUE
#endif
/**
* @brief Debug option, parameters checks.
* @details If enabled then the checks on the API functions input
* parameters are activated.
*
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_CHECKS TRUE
#endif
/**
* @brief Debug option, consistency checks.
* @details If enabled then all the assertions in the kernel code are
* activated. This includes consistency checks inside the kernel,
* runtime anomalies and port-defined checks.
*
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS TRUE
#endif
/**
* @brief Debug option, trace buffer.
* @details If enabled then the context switch circular trace buffer is
* activated.
*
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE TRUE
#endif
/**
* @brief Debug option, stack checks.
* @details If enabled then a runtime stack check is performed.
*
* @note The default is @p FALSE.
* @note The stack check is performed in a architecture/port dependent way.
* It may not be implemented or some ports.
* @note The default failure mode is to halt the system with the global
* @p panic_msg variable set to @p NULL.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK TRUE
#endif
/**
* @brief Debug option, stacks initialization.
* @details If enabled then the threads working area is filled with a byte
* value when a thread is created. This can be useful for the
* runtime measurement of the used stack.
*
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS TRUE
#endif
/**
* @brief Debug option, threads profiling.
* @details If enabled then a field is added to the @p Thread structure that
* counts the system ticks occurred while executing the thread.
*
* @note The default is @p TRUE.
* @note This debug option is defaulted to TRUE because it is required by
* some test cases into the test suite.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
#define CH_DBG_THREADS_PROFILING TRUE
#endif
I am getting SV#3 on every project including demo.
I have read comments, but none of them warns about causing such problem.
As I said i am a newbie in Chibios OS.
Thanks in advance.
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 3:14 pm
by Giovanni
CH_DBG_SYSTEM_STATE_CHECK enables the state checker, SV#3 is a state violation. I find hard to believe any demo can trigger this violation.
There must be something in your setup that triggers this problem, are you using arm-none-eabi-gcc? Codesourcery offers two ARM compilers, one is only for Linux targets, the other for bare metal.
Giovanni
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 8:19 pm
Let me thank you once again for your great help!
I've started once again from beginning on STM demo.
I've triple checked everything.
The only diff i've made to the project is:
Code: Select all
kokete@piotr ~/workspace_arm/_SMT32F4/3rd_party/chibios_2.4.2/demos/ARMCM4-STM32F407-DISCOVERY $ svn diff
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LANG is en_US.UTF-8
svn: warning: please check that your locale name is correct
Index: chconf.h
===================================================================
--- chconf.h (revision 4625)
+++ chconf.h (working copy)
@@ -368,7 +368,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
-#define CH_DBG_SYSTEM_STATE_CHECK FALSE
+#define CH_DBG_SYSTEM_STATE_CHECK TRUE
#endif
/**
@@ -379,7 +379,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_CHECKS FALSE
+#define CH_DBG_ENABLE_CHECKS TRUE
#endif
/**
@@ -391,7 +391,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_ASSERTS FALSE
+#define CH_DBG_ENABLE_ASSERTS TRUE
#endif
/**
@@ -402,7 +402,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_TRACE FALSE
+#define CH_DBG_ENABLE_TRACE TRUE
#endif
/**
@@ -416,7 +416,7 @@
* @p panic_msg variable set to @p NULL.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
-#define CH_DBG_ENABLE_STACK_CHECK FALSE
+#define CH_DBG_ENABLE_STACK_CHECK TRUE
#endif
/**
@@ -428,7 +428,7 @@
* @note The default is @p FALSE.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
-#define CH_DBG_FILL_THREADS FALSE
+#define CH_DBG_FILL_THREADS TRUE
#endif
/**
And I am still getting "SV#3".
I have changed nothing else.
Before i have started using Chibios OS, i have successfully implemented nRF24l01+ communication on pure ST libs using same GCC.
I have started to use Chibios because i wanted to make a software FIFO running in separated thread. So i need the multi- thread functionality. Everything else was already working.
My gcc:
Code: Select all
$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/opt/CodeSourcery/Sourcery_CodeBench_Lite_for_ARM_EABI/bin/../libexec/gcc/arm-none-eabi/4.6.3/lto-wrapper
Target: arm-none-eabi
Configured with: /scratch/nsidwell/arm/eabi/src/gcc-4.6-2012.03/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2012 -D__CS_SOURCERYGXX_MIN__=3 -D__CS_SOURCERYGXX_REV__=56 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-shared --enable-lto --with-newlib --with-pkgversion='Sourcery CodeBench Lite 2012.03-56' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/nsidwell/arm/eabi/install/arm-none-eabi --with-gmp=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --with-mpfr=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --with-mpc=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --with-ppl=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-cloog=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --with-libelf=/scratch/nsidwell/arm/eabi/obj/host-libs-2012.03-56-arm-none-eabi-i686-pc-linux-gnu/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/nsidwell/arm/eabi/install/arm-none-eabi/bin --with-build-time-tools=/scratch/nsidwell/arm/eabi/install/arm-none-eabi/bin
Thread model: single
gcc version 4.6.3 (Sourcery CodeBench Lite 2012.03-56)
WDYT?
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 8:45 pm
by Giovanni
That SV#3 makes no sense, the only thing I can try (tomorrow) is that Codesourcery 4.6.3, I haven't tested it yet. Last version was 4.5.3. I am using GCC 4.6.3 amd 4.7.1 YAGARTO without problems however.
It must be a difference in environment because the demos work here.
What are you using to flash the device? I tested openocd 0.6 RC1 under linux and windows and it works without problems. Could it be a device programming problem? it happened to another user in the past.
In order to rule out an environment problem, you could try to download "ChibiStudio" (from SF.net download area) and see if it works for you, this would confirm a toolchain problem somewhere. It is a preconfigured Eclipse toolchain with compiler and everything else.
You could also verify if the ChibiOS 2.5.0 taken from the repository makes any difference, there are two distinct STM32F4-Discovery demos that you can try (plus all the test applications under ./testhal).
Giovanni
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 9:53 pm
Hi Giovanni!
I do not know how to thank you for your help but saying thank you again.
You ware right. The problem is in Codesourcery gcc v. 4.6.3.
I have downloaded version 4.5.2 and problem disappears.
As with 4.5.2 problem disappeared i have turned back to 4.6.3 to double check if the problem occurs again. And it does. Getting back again to 4.5.2 once again solves the problem.
So now I am 100% sure that SV#3 panic was caused by 4.6.3 version.
As SV#3 dissappears I'm getting back to my earlier problem- the threads and stack.
Greetings
Piotr Klimczak
Re: STM32F4 hangs on _spi_wait_s
Posted: Sun Aug 26, 2012 10:00 pm
Good news.
Switching to 4.5.2 also solves the _spi_wait_s hanging problem- checked on chibios trunk (2.5.0 i believe).
So once again thank you for your help.
We can close this thread.
Hope that someone reading this thread will not spent whole 3 days debugging just like me.
Greetings,
Piotr Klimczak
Re: STM32F4 hangs on _spi_wait_s
Posted: Mon Aug 27, 2012 8:09 am
by Giovanni
Hi,
Thanks for all the testing, I hope to make some debug with CS 4.6.3, it would be good to report to CodeSourcery any problem that could be present in the product.
Giovanni
Re: STM32F4 hangs on _spi_wait_s
Posted: Wed Aug 29, 2012 4:06 pm
by stormracer
Hello,
I've the same problem. Where can i find the old version of codesourcery (4.5.2). I've installed Verion 4.6.1.
I am working on Linux x64.
Christian