Hardfault because of decompression when using FreeRTOS

Hello there !

I'm working on a dual core MCU based on M7 architecture. The chip is not sell on its own, as its designed and used for specific product developed by my company. In the context of my internship topic, I must use FreeRTOS 11.1 on it. While a baremetal app works great, Trying to use FreeRTOS leads to hard faults, according to the debugger :

> The target stopped in HardFault exception state.

> Reason: Vector table read error on exception at 0x100004B8.

Even if my internship is not about such low level stuff, I've to handle this if I wanna progress ! so I need some help. 

It happens when I add a line in the `main()` function `xTaskCreateStatic()`. I Tried my best to investigate. While trying different ideas, I figured out the issues is not caused by FreeRTOS itself, it occurs before entering the `main()` function. Thus, It's because I do something wrong while adding it to my project.

As it's easy to add or remove this line, I did it several times to compare. Here is what I found :

When the line with `xTaskCreateStatic()` is not present :

 - The disassembly at 0x100004B8 is `LSLS R2, R2, #29

 - The function actually "running" - according to Ozone disassembly - is `__scatterload_zeroinit`

 - The disassembly does not mention the function `__decompress`

 - The linker output file mention the function `__decompress` 6 times, but there is any address

When the line with `xTaskCreateStatic()` is present :

 - The disassembly at 0x100004B8 is `SUBS R4, R4, #1`

 - The function actually "running" - according to Ozone disassembly - is `__decompress`

 - The linker output file mention the function `__decompress` 14 times, at the address 0x1000048d

 - The function `__scatterload_zeroinit` is still present, but at 0x100004F2 in the disassembly

Here is the call stack in the case of the HardFault (can't add a screenshot) :

Function Stack Frame Source PC Return Address Stack Used
==> <HardFault Exception> ... ... ... ... ...
_decompress0 ... ... ... ... ...
_scatterload_rt2 ... ... ... ... ...

From what I understand, these two functions are a part of the "scatter loading process" ? But what I don't understand is why adding FreeRTOS code moves these functions ? Isn't their position in memory proprietary, compared to FreeRTOS stuff ? With what I think I know, my hard fault is caused by the shifting of functions in memory. Is my interpretation pertinent ? How can I solve this ? 

Thanks

Parents Reply Children
No data