Wednesday, February 21st 2018, 12:32am UTC+1

You are not logged in.

  • Login
  • Register

ubudum

Beginner

Date of registration: Feb 5th 2018

Posts: 1

1

Saturday, February 10th 2018, 3:43am

Stm32CubeMX USB Import Causes Hard Fault

Hello,

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.

SEGGER - Nino

Super Moderator

Date of registration: Jan 2nd 2017

Posts: 707

2

Monday, February 12th 2018, 10:26am

Hello,

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.
https://wiki.segger.com/How_to_port_proj…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,
Nino

Evgeniy

Beginner

Date of registration: Jul 4th 2017

Posts: 2

Location: Russia

3

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