I am working on Cortex M0+ controller. Following is issue i am facing in __main library function.
While executing library function __main (Keil compiler internal fucntion for initializatioin data and bss section) code is going in hardfault. If any one has solution for this please let me know.
Check the memory map passed to the linker, either via the IDE GUI or scatter file. Check also in the .MAP file, about the size of the created sections and against the specification of your particular part choice.
It is like the RAM is at the wrong address, or specified as being too large.
I have verified scatter file it has correct address for ROM and RAM. I have debugged further in __main and found that if I give RAM start address 0x20000000 its going in hardfault in decompression(There is wrong calcualtion of address). If I give RAM start address 0x20000100 to eliminate wrong calcualation in decompression, __main is not going in hardfault but then .data and .bss section initialization is wrong. Here is my scatter file...
LR_IROM1 0x00000000 { ; load region size_region ER_IROM1 0x00000000 0x00040000 { ; load address = execution address startup_ARMCM0plus.o (RESET, +First) * (InRoot$$Sections) .ANY (+RO) } RW_IRAM1 0x20000100 0x00008000 { ; RW data .ANY (+RW, +ZI) } }
Well I suspect if the decompression is breaking, something on the input side is wrong.
If you have a failing case, I'd suggest you send it to Keil Support for review. There's not enough information here to replicate the conditions.
You need to look closely at the .MAP file to see why the address might be going out of bounds and inducing the Hard Fault.