Page 1 of 1

STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Tue Jun 17, 2014 2:47 pm
by forrestjon
Hello,

I am new to ARM development and very new to ChibiOs.
After working with the ChibiOS example project for the STM32F4Discovery board yesterday I noticed that the program would not boot up.
the firmware was stuck in a while loop waiting for the internal high speed oscillator (HSI) to become stable.

The lockup occurs in hal_lld.c around line 170.
/* HSI setup, it enforces the reset situation in order to handle possible
problems with JTAG probes and re-initializations.*/
RCC->CR |= RCC_CR_HSION; /* Make sure HSI is ON. */
while (!(RCC->CR & RCC_CR_HSIRDY)) // <---- Startup Init Lockup is HERE.
; /* Wait until HSI is stable. */


To fix the lockup I found it necessary to set STM32_NO_INIT to TRUE in mcuconf.h
//#define STM32_NO_INIT FALSE
#define STM32_NO_INIT TRUE // Resolves HSI startup lock.

The above modification allows the board to boot and run the example project.

I also noticed that the External clock frequency was wrong for matching my Discovery board.
I have an 8MHz oscillator installed. This was the factory setting.

This is found in stm32f4xx.h (Line 122)
#if !defined (HSE_VALUE)
// 06/16/2014 FJD modified to match our 8MHz external crystal oscillator.
#define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */

#endif /* HSE_VALUE */

I hope this helps anyone else who is working at getting ChibiOS up and running on the STM32F4DISCOVERY board.

Cheers,

Forrest

Re: STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Tue Jun 17, 2014 2:54 pm
by Giovanni
You simply disabled the clock initialization, the HAL device drivers will not work. In ChibiOS the HSE frequency is defined in board.h, the values in ST headers are not used.

I am not sure why your application stops in that loop, it is working in all demos.

Giovanni

Re: STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Tue Jun 17, 2014 4:33 pm
by forrestjon
Hi,
Thanks for pointing that out.
That explains why there is no serial port activity and the interupts do not fire as expected.
I'll dig a little deeper...

Re: STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Wed Jun 18, 2014 1:33 pm
by forrestjon
Hi,

I resolved my issue yesterday.
It turned out to be a complex mixture of IAR compiler settings and a modification to the
PORT_IDLE_THREAD_STACK_SIZE (changed size from 16 to 32)

Very strange behavior indeed.

The two modifications which seemed to make the most difference were to increase the optimization level to the highest (for speed)
and increasing the RTOS stack size as noted above.

Sorry for the initial confusion.

Thanks,

Forrest

Re: STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Wed Jun 18, 2014 3:05 pm
by Giovanni
Hi,

If you use the IAR compiler please use the example projects as references, there are important settings to do.

Giovanni

Re: STM32F4 DISCOVERY Start up HSI Stability Lockup Resolved

Posted: Wed Jun 18, 2014 4:53 pm
by forrestjon
Hi,

I was using the IAR example project.

Thanks,

Forrest