Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Forte on STM32F7 throws Hard Fault when creating ForteInstance
Forte on STM32F7 throws Hard Fault when creating ForteInstance [message #1838235] Fri, 19 February 2021 08:08 Go to next message
Tobias P is currently offline Tobias PFriend
Messages: 2
Registered: February 2021
Junior Member
Hello,

I hope this is the correct forum for my problem.
I compiled forte as a static library for FreeRTOS+LwIP according to https://www.eclipse.org/4diac/en_help.php?helppage=html/installation/freeRTOSLwIP.html

I have my main Project in CubeIDE as a C++ Project, added the libforte-static.a and added the thread to start forte.
static void forte_thread(void *pvParameters)
{
  forteGlobalInitialize();
  TForteInstance forteInstance = 0;
  int resultForte = forteStartInstanceGeneric(0, 0, &forteInstance);
  if(FORTE_OK == resultForte){
    forteJoinInstance(forteInstance);
  }else{
	  printf("Error %d: Couldn't start forte\n", resultForte);
  }
  forteGlobalDeinitialize();
  vTaskDelete(NULL);
}

However, every time in forteStartInstanceGeneric() the MCU goes into Hard Fault. Reading the CFSR I can see the cause is INVSTATE:
Quote:
INVSTATE Indicates the processor has tried to execute an instruction with an invalid Execution Program Status Register (EPSR) value. Among other things the ESPR tracks whether or not the processor is in thumb mode state. Instructions which use "interworking addresses"2 (bx & blx or ldr & ldm when loading a pc-relative value) must set bit[0] of the instruction to 1 as this is used to update ESPR.T. If this rule is violated, a INVSTATE exception will be generated. When writing C code, the compiler will take care of this automatically, but this is a common bug which can arise when hand-writing assembly.


I debugged the Disassembly, Hard Fault doesn't trigger on a specific instruction but always somewhere in the creation of Queue or Semaphore when it jumps to the heap in RAM. There are 2 undefined Instructions in my heap but I'm not sure where they are coming from
0x20001940:    ;<UNDEFINED> instruction: 0xffffffff 

same a couple of bytes later. (see attached screenshot)

Reading the explanation for INVSTATE I thought maybe I didn't compile in Thumb mode. However, these are my settings in CMake for CXX Compiler:
-mcpu=cortex-m7 --specs=nano.specs -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group

I also tried --specs=nosys.specs

I configured CMake to use 64-Bit Datatypes which is the standard Setting, if I change it it doesn't compile at all tho

Does anyone have an Idea what the problem could be?
Any help is greatly appreciated

Greetings
Re: Forte on STM32F7 throws Hard Fault when creating ForteInstance [message #1838262 is a reply to message #1838235] Fri, 19 February 2021 18:33 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1209
Registered: January 2014
Senior Member
Puh, this seems a hard to debug thing. As it is happening in heap code have you checked the compiler flags for freeRTOS compiling? All the code you are mentioning makeing troubles is freeRTOS code.
Re: Forte on STM32F7 throws Hard Fault when creating ForteInstance [message #1838363 is a reply to message #1838262] Tue, 23 February 2021 08:44 Go to previous messageGo to next message
Tobias P is currently offline Tobias PFriend
Messages: 2
Registered: February 2021
Junior Member
Update: I used syscalls and sysmem from an example for my board from the official STM32Cube_FW package, but apparently there was an issue (symbols for heap end where different for example). I replaced both with ones created by cubeMX now the Hard Fault is gone :/
Re: Forte on STM32F7 throws Hard Fault when creating ForteInstance [message #1838450 is a reply to message #1838363] Thu, 25 February 2021 10:09 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1209
Registered: January 2014
Senior Member
I'm always amazed how big the troubles you get when using the official STM software.

[Updated on: Thu, 25 February 2021 10:09]

Report message to a moderator

Previous Topic:How do I associate header files with other folders
Next Topic:Discussion about integrate FB in ECC
Goto Forum:
  


Current Time: Sun May 09 05:40:39 GMT 2021

Powered by FUDForum. Page generated in 0.02285 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top