Wednesday, May 23rd 2018, 4:28pm UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.



Date of registration: Feb 5th 2018

Posts: 1


Saturday, February 10th 2018, 3:43am

[ABANDONED] Stm32CubeMX USB Import Causes Hard Fault


I have been working on a project for a while with Keil, and I recently decided to migrate to SES. I thought the import feature in SES would be enough for the transition, but apparently I am missing something since my project doesn't work on my board anymore. I was able to narrow down the scope of search by replicating the issue with a simple project. Basically, those are the steps I followed:
  1. In Stm32CubeMX V4.24.0 in created a project for STM32F407VG
  2. I added the RCC peripheral with configuration HSE crystal source and LSE crystal source
  3. I added the USB_OTG_FS peripheral with mode Device_Only
  4. I added the USB_DEVICE middleware with class for FS IP to be MAss Storage Class
  5. I set the clock HCLK to 168Mhz
  6. I generated the code for MDK-ARM V5 toolchain with increased heap size of 0x2000 and stack size of 0x4000
  7. In SES V3.34 I ported the project and successfully built it using the internal build configuration
  8. I loaded the project on my custom board and entered debug mode

Every time I run the code, I get a hard fault when it tries to initialize the USB peripheral. This issue happens specifically after I enable the global interrupt for USB (USB_EnableGlobalInt function). After returning from that function, the hard fault occurs. Oddly enough, there is no hard fault when I step thought the code line by line which makes me believe that stepping line by line disables the interrupts. The issues still remains though, and when looking at the call stack, I didn't see anything corrupted on the stack or any function having an address out of range.

Note: The same project, builds and works with no issue when I build it using the external configuration based on Keil.

Is there any debugging steps that any of you can recommend? Is there a setting in SES that I am missing?
For now I don't have a clue to what is happening, so any help would be appreciated.
Thank you.


Super Moderator

Date of registration: Jan 2nd 2017

Posts: 1,051


Monday, February 12th 2018, 10:26am


Thank you for your inquiry.
Generally porting simple structured projects from Keil to ES should work without any issues.
But with more complex projects that come with HALs, compiler specific assembler files etc. additional steps are required for a successful port.
Currently we don't have a specific guide for Keil but there is one when porting from IAR and the base concept stays the same.…Embedded_Studio
Especially the section troubleshooting will give information about the most common steps that need to be done when porting more complex projects.

Best regards,
Please read the forum rules before posting: Forum Rules

Keep in mind, this is not a support forum. Its main purpose is user to user interaction.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support contact us per e-mail.
The following contact form can be used for this:



Date of registration: Jul 4th 2017

Posts: 2

Location: Russia


Tuesday, February 13th 2018, 2:13pm

I've got same problem. But interrupt type doesn't matter. Imported project from Keil compile and works before any interrupt. After interrupt - hard faul