Hi there!
I have a strange problem after relocating a portion of software to another part of the flash memory.
First of all a little description of my configuration. I have got two separate programs installed in the same controller (STM32F427ZGT6, i am using using Keil v5.20, Pro version).
First part is a kind of a bootloader which is positioned at 0x80000000, and the second part starts at 0x80010000. Of course bootloader after proper start relocates vector table to 0x80010000 and moves the PC to 0x80010000. And that's really fine. Everything works perfect in such a configuration.
But the problem appears when the address is not 0x80010000, but 0x80020000 and above. When i relocate the main portion of software to 0x80020000 program hangs and stops on HardFault.
As far as i see the program stops on rt_memcpy_w function. But sometimes the "caller" of HardFault points to 0x0 adress, not to rt_memcpy_w. I've tried other adresses - 0x80030000 and so on. But the situation is the same.
I have to move the second portion of the software because of additional functions in the bootloader part, so now it's code is more than 0x10000 bytes.
I've checked the reference manual about the memory map, but i haven't found any clue for such a behavior.
Thanks in advance for any help!
Ok, i've found the problem. The problem was with the HAL and it's "stack". I've used HAL library for USB stack. So in my code there is HAL_Init() instruction. But, when i've changed vtor and PC and SP i haven't stopped HAL (by using HAL_DeInit()). And that was the problem. I assume, that for example SysTick has been working still, but i've changed the vector table and everything collapsed. So, thanks for the discussion. It has helped me to track the bug.
Best regards!