Hi all,
Recently i have made a flash driver and export it as a hex file,i take hexadecimal data in the file into a global array 'g_flashDriverRAM' and change the array g_flashDriverRAM to a function pointer.
Later i excute the function pointer to do erase flash and write flash funtion,it can work well.The flash memory can be modified as i want.However,when i copy the data in g_flashDriverRAM to a new array 'g_flashDriverRAM1' and change it to function pointer to excute,it case a hardfault. I have check that the data in g_flashDriverRAM is same as g_flashDriverRAM1,i can change g_flashDriverRAM to function pointer to excute erasing and writing flash function but can not work when i use g_flashDriverRAM1.
I also try to copy the data in g_flashDriverRAM to a assigned RAM address and change the assigned RAM address as a function pointer to excute,it also can not work.
The main different of g_flashDriverRAM and g_flashDriverRAM1 is that g_flashDriverRAM has initialized when declaration but g_flashDriverRAM1 does not initialize when declaration.I check the map file and found that g_flashDriverRAM is store in .data segment and g_flashDriverRAM1 is store in .bss segment.
Follow figure are some part of my code:
(1)define two array, g_flashDriverRAM is initialized and g_flashDriverRAM1 is not initialized

(2)check the map file after compliering,it can be found that g_flashDriverRAM is store in .data segment and g_flashDriverRAM1 is store in .bss segment.


(3)change the g_flashDriverRAM to function pointer and excute erasing and writing flash operation,it can work well,however when copy the data in g_flashDriverRAM to g_flashDriverRAM1 and do the same operation,it cause hardfault.


Is there anything i forget to configure or any fault operation i have made?Can you tell me how to solve this problem?
Thanks and Best Regard,
Leo