0
\$\begingroup\$

I've a problem on the STM32F412 with flash writing and USB Host initialized. When USB Host is active and I attempt to write to flash, the software execution blocking at FLASH_FlushCaches function, on the line:

if (READ_BIT(FLASH->ACR, FLASH_ACR_ICEN) != RESET)

If I remove the MX_USB_HOST_Init function, the flash writing works fine, but if I call the function in any position on the code (even after flash writing calls), the code always stop at the same point.

I don't have ideas about this problem. Do you have any suggestions? Thanks!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Are you sure the flash is readable for code while you write it? When USB interrupt comes in, it must be possible to run it or it will fail. \$\endgroup\$
    – Justme
    Commented May 9 at 14:02
  • \$\begingroup\$ Sorry, I didn't quite understand what you meant... Are you talking about the OTG_FS_IRQHandler interrupt? \$\endgroup\$
    – Stefano
    Commented May 9 at 15:15
  • \$\begingroup\$ @Justme: The solution to that would be to (a) put all ISRs into a separate section (make sure to compile with -fPIC so they are relocatable), (b) create a shadow copy of ISR code in RAM, (c) update the interrupt vector table to point to the RAM copy. I think there's a way in the linker config to tell it a certain section will execute from a different address than where the linker stores it; that way relocatable code is not needed and the correct addresses would be in the interrupt table already. \$\endgroup\$
    – Ben Voigt
    Commented May 9 at 15:55
  • \$\begingroup\$ I solved it; it was enough to update the libraries. Indeed, I was working on a project created a few years ago for another STM microcontroller. \$\endgroup\$
    – Stefano
    Commented Jul 11 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.