2023-06-23 04:04 PM - edited 2023-06-24 05:18 AM
I'm using a BSEC static library for BME688 sensor. My application project builds fine. As soon as I reach the first BSEC function (which is provided by the "libalgobsec.a" static library), program goes to hard fault interrupt handler.
My best guess would be that stack/heap size is insufficient. I have tried increasing both from 0x200 (heap) and 0x400 (stack) to 0x1000 (both) then also 0x8000 (both) through my linker file. However I see no difference - program hits the hard fault handler as soon as program enters the "bme68x_bsec_update_subscription" function.
It's also worth noting that I used proper "libalgobsec.a" static library - the one under Cortex-M7 folder (since my MCU uses this core).
Maybe there are other reasons I should consider in this case?
Under BSEC examples, I have found one Readme (in the appendix) file which states the algorithm inclusion process. I didn't follow the exact rules because (I think) they are meant for Arduino platform (and I'm using STM32 with PlatformIO in VS Code). However there are some flags that might be important and could affect this case. The only thing I did about compiler/linker flags is the inclusion of library libalgobsec.a" and provided flags for hardware floating point arithmetic.
I'm using STM32F756xx microcontroller in combination with CubeMX code generator (generates linker file where I can set stack/heap size).
EDIT:
By inspecting CFSR register I found out that hard fault is being caused by "Invalid instruction set" event. However, if I use Thumb instruction set (using either `-mthumb` or `-mthumb-interwork` option for compiler, linker, and assembler) my application code compiles but BSEC function call causes hard fault. If I try to use ARM instruction set instead (using `-marm` option), application code won't compile, saying CPU doesn't support this instruction set.
2024-03-28 07:02 PM
I know this post is a bit old, but did you ever determine the fix for your problem? I'll admit I am neither using the BME lib nor am I using an STM32 MCU, but I am running into a very similar sounding problem. I'm building a static library that I have the source for and I am compiling and then linking it into my ARM-M3 based application. However, the first call into the static library immediately dumps me into the Hard Fault handler. I've yet to inspect the registers to give more info but this post had me curious about the final resolution.
TYIA!
-Stephen
2024-03-29 02:52 AM
From the description in the original post, I'd say that @lgacnik97 used a precompiled library, which was for some reason incorrectly compiled with non-Thumb settings.
This does not appear to be your case.
Please start a new thread stating which hardware, software, compiler are you using, with what settings, and what is the fault footprint (i.e. fault registers content, processor registers content, mixed source+disasm of the area before the place where the fault occurs, etc.)
JW