How to solve strange hard fault issue
Building a custom board, which can accept either an STM32F205 or an STM32F405. Have boards with both MCU built. System running FreeRTOS 10, with three tasks total.
Embedded software has shared application code between the two builds, only the stuff generated by CubeMX is different. I'm using the USB_OTG_FS and CAN1 peripherals, TIM1 as the system timebase, TIM2 as a timestamp for CAN messages, and the CRC unit. Nothing fancy.
It seems that when I try and write my config file to flash (it's in a sector by itself) I get an oddball IRQ from the Timer Tick, and then a hard fault.
The kicker, which is really confusing me, is if I load the code compiled for the STM32F205 onto the STM32F405, everything works as expected. No crashes, config saved and CRCd correctly.
I've got limited experience with debugging hard faults, but looking at the registers in CubeIDE, it seems it's a forced hard fault (HFSR bit 30 is set). CFSR bit 16 is set (UNDEFINSTR) but not sure whether that's relevant or not.
I've tried using the FreeRTOS taskDISABLE_INTERRUPTS() function, the __enable_irq function, suspending the other two tasks on the system, but I can't see what's going wrong. Tried the hard fault code on the FreeRTOS Site (not allowed to post links...) but it never seems to actually run it - It just gets stuck on the hard fault entry. Looking back up the stack, the only hint of code addresses are the Timer 1 IRQ Handler, xPortStartScheduler, prvPortStartFirstTask.
I guess I'm asking is there something inherently wrong with the way this version of CubeMX / FreeRTOS work on an M4, or is it fixable, or should I just resign to using the M3 code compiled for the '205?
Any assistance gratefully received,
Matt.