Page 3 of 4

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 4:08 pm
by Giovanni
You could try this instead: https://launchpad.net/gcc-arm-embedded

Giovanni

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 5:36 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 5:46 pm
by Giovanni
Great.

Giovanni

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 6:42 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 7:15 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Wed Aug 29, 2012 8:52 pm
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.       */
   }
}


Re: STM32F4 hangs on _spi_wait_s

Posted: Thu Aug 30, 2012 5:36 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Thu Aug 30, 2012 6:44 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Fri Aug 31, 2012 9:21 pm
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

Re: STM32F4 hangs on _spi_wait_s

Posted: Fri Aug 31, 2012 9:32 pm
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