[ABANDONED] Stm32CubeMX USB Import Causes Hard Fault

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [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.
  • 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.
    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: Contact Us