STM32F4 hangs on _spi_wait_s

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F4 hangs on _spi_wait_s

Post by Giovanni »

You could try this instead: https://launchpad.net/gcc-arm-embedded

Giovanni
[email protected]
Posts: 33
Joined: Sat Aug 25, 2012 9:53 pm
Been thanked: 1 time

Re: STM32F4 hangs on _spi_wait_s

Post by [email protected] »

Hi Giovanni!

The GNU Toolchain works for me.
Can debug w/o problems.

Code: Select all

$ arm-none-eabi-g++ -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/opt/toolchains/gcc-arm-none-eabi-4_6-2012q2/bin/../libexec/gcc/arm-none-eabi/4.6.2/lto-wrapper
Target: arm-none-eabi
Configured with: /home/build/work/jenkins-daily-build/src/gcc/configure --build=i686-linux-gnu --host=i686-linux-gnu --target=arm-none-eabi --prefix=/home/build/work/jenkins-daily-build/install-linux --enable-languages=c,c++ --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-lto --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --with-sysroot=/home/build/work/jenkins-daily-build/install-linux/arm-none-eabi --with-gmp=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-mpfr=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-mpc=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-ppl=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-cloog=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-libelf=/home/build/work/jenkins-daily-build/build-linux/host-libs/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='GNU Tools for ARM Embedded Processors' --with-extra-multilibs=armv6-m,armv7-m,armv7e-m,armv7-r
Thread model: single
gcc version 4.6.2 20120613 (release) [ARM/embedded-4_6-branch revision 188521] (GNU Tools for ARM Embedded Processors)


Greetings
Piotr Klimczak
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F4 hangs on _spi_wait_s

Post by Giovanni »

Great.

Giovanni
stormracer
Posts: 14
Joined: Mon Jun 11, 2012 9:50 pm

Re: STM32F4 hangs on _spi_wait_s

Post by stormracer »

Hello,

installing the GNU Toolchain doesn't work for me. I get the same version output from

Code: Select all

arm-none-eabi-gcc -v
. But the problem still exist. The program stops during the return of "void dbg_trace(Thread *otp)". At this point eclipse doesn't react. Only if i push the reset button from the stm discovery the debugger jumps to the reset handler. Therefor i doesn't get any hint of a fault or a message. The debugging options in chconf.h are enabled.

Christian
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F4 hangs on _spi_wait_s

Post by Giovanni »

In the weekend I will try to duplicate the problem, it would be useful to know what in that assertion fails, which is the condition that makes the program go in port_halt().

Question, if you flash the device and then detach it from the debugger, does it still hang after reset?

Giovanni
stormracer
Posts: 14
Joined: Mon Jun 11, 2012 9:50 pm

Re: STM32F4 hangs on _spi_wait_s

Post by stormracer »

Hi,
i have attached my test code. Do you find a failure in the code?

The error exist also when i flash it from the cosole with st-flash write build/ch.bin 0x8000000.
Tomorrow i try it without the stlink. Then i power it from an extern source.

Christian


Code: Select all

#include "ch.h"
#include "hal.h"
#include "test.h"

static const SPIConfig spicfg = {
  NULL,
  GPIOA,
  15,
  SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_CPOL | SPI_CR1_CPHA
};

int main(void) {
   halInit();
   chSysInit();

   spiStart(&SPID3, &spicfg);          /* Setup transfer parameters.       */
   palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);       /* New SCK.     */
   palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);       /* New MISO.    */
   palSetPadMode(GPIOC, 12, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST);       /* New MOSI.    */
   palSetPadMode(GPIOA, 15, PAL_MODE_OUTPUT_PUSHPULL |   PAL_STM32_OSPEED_HIGHEST);    /* New CS.      */
   palSetPad(GPIOA, 15);

   uint8_t tx[2];

   tx[0] = 12;
   tx[1] = 34;

   spiStart(&SPID3, &spicfg);                       /* Setup transfer parameters.       */

   while (TRUE) {
      palSetPad(GPIOD, GPIOD_LED5);               /* Orange.  */
      chThdSleepMilliseconds(50);
      palClearPad(GPIOD, GPIOD_LED5);           /* Orange.  */
      chThdSleepMilliseconds(50);

      //spiSelect(&SPID3);                          /* Slave Select assertion.          */
      spiSend(&SPID3, 2, tx);
      //spiUnselect(&SPID3);                        /* Slave Select de-assertion.       */
   }
}

stormracer
Posts: 14
Joined: Mon Jun 11, 2012 9:50 pm

Re: STM32F4 hangs on _spi_wait_s

Post by stormracer »

Hello,

i don't know what is wrong. My Program hangs at different positions. I've started with a clean demo project an added my SPI code. That was running. Later the program hangs at a chprintf() call. Now at a chThdSleepMilliseconds(). I don't know how i can debug this. Eclipse stops at the line and doesn't do anything. I don't get a message or a hint for the stop. The status of eclipse is "stepping" but nothing happen for minutes. The only chance to stop the debugger is with the reset button from the stm board.

Thank for your help
Christian
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F4 hangs on _spi_wait_s

Post by Giovanni »

The code looks normal, you just call spiStart() twice but this is allowed.

I begin to think that you have one of:
1) HW problem.
2) Issues with the debugger.

What are you using for debug (please versions and details).

Giovanni
stormracer
Posts: 14
Joined: Mon Jun 11, 2012 9:50 pm

Re: STM32F4 hangs on _spi_wait_s

Post by stormracer »

Hello,

i think i have a memory problem maybe with the stack and threads.

When i call the spi functions from a empty main, it works. But when i call it from a thread i get the same problem. I think i have to check my codes again...

I use Eclipse Juno for debugging. But for testing i flash the stm from console too.

I use the arm gcc version: gcc version 4.6.2 20120613 (release) [ARM/embedded-4_6-branch revision 188521] (GNU Tools for ARM Embedded Processors)
GDB: GNU gdb (GNU Tools for ARM Embedded Processors) 7.3.1.20120613-cvs
ChibiOS Version 2.5.0

Christian
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F4 hangs on _spi_wait_s

Post by Giovanni »

Hi,

The test application under ./testhal/STM32F4xx/SPI uses the SPI driver from two threads, you may use it as reference.Try increasing the stack size, often this kind of problems are caused by overflows.

Giovanni
Post Reply