Hi Omar:
Thanks for your kindly reply, please see my answer below.
Could you please share with me the memory configuration?
A: Please refer below fig for more details.




At the moment of crash, to what direction are you trying to access?
A: An crash occurred before entering the function "mflash_drv_sector_erase_internal". At the moment, input value sector_addr=0x240000.


Additionally, Add the following to the FreeRTOSConfig.h
#define configTASK_RETURN_ADDRESS 0
A: The constants define has been added on the file. please refer fig below.

Best Regards
Edward