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) :
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
Hii
Thanks to your suggestion, I solved the HardFault in the `__decompress0` function, as it's no longer used. Now, there is a new HardFault, but in `__scatterload_copy`. I can't read `__main` source code, but from what I undestand, `__scatterload_copy` is supposed to be call after `__decompress0` (if used.) Thus, this HardFault is a "good thing" : I interprete it as "stuff isn't at the right place in memory". So I'ill indeed have to check again my scatter file, as you recommended.
But it lets me perplex. The chip I'm working on is not a commercial one, is designed by my company to be used in a specific product, still under development. Currently, this product uses FreeRTOS 10.5, and it works. So I just copy-pasted the scatter file. I thought it was OK. Maybe I must learn how to write a scatter file, and rewrite it from scratch by myself, as I did for CMake ??
-- Nota : Why I'm not updating from FreeRTOS 10.5 to 11.1 ? 10.5 is not integrated correctly, and is merged with a former RTOS developed internally. It adds a huge abstraction layer. Thus, I get asked to install 11.1 from scratch.