2018-11-22 11:37 PM
Hi guys,
I have use the stm32f105 to do a job on the IAP jump tp APP, and normally it works fine, but latest day, I have to disable the USB code on the APP code, then use the flash download demonstrator to download the APP, it runs OK, and then re-power on the device, APP run into hard fault at once.
And I have print the CFSR=0x8200, HFSR=0x40000000, BFAR=0x5548535f(this value seems not right). I can not use BFAR to find the error place. So any one could give some suggestion?
2018-11-22 11:47 PM
Hi..
Try to de-init RCC and SysTick before jump to application
HAL_RCC_DeInit();
SysTick->CTRL =0;
SysTick ->LOAD =0;
SysTick->VAL=0;
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
//SCB->VTOR = APPLICATION_ADDRESS;
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
JumpToApplication();
Usman
2018-11-23 12:53 AM
Hi Usman,
Thanks for giving the suggestion, and it still goes into the hard fault, and the test code as below:
if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{
//__disable_interrupt();
__set_PRIMASK(1);
HAL_RCC_DeInit();
SysTick->CTRL =0;
SysTick ->LOAD =0;
SysTick->VAL=0;
//HAL_DeInit();
/* Move the 4 bytes to APP address */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);
/* Point to the APP entry address */
Jump_To_Application = (pFunction) JumpAddress;
/* Reset the top of the stack point address */
__set_MSP(*(__IO uint32_t*) ApplicationAddress);
/* Jump to the reset function */
Jump_To_Application();
}
and now, I think the IAP code does not recycle the source, and the main in IAP is below:
int main(void)
{
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
JumpToApp();
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
Maybe there is still some interrupt running?
2018-11-23 01:23 AM
Have you shift the interrupt vector on your application code?
2018-11-23 01:31 AM
Yes, I did the shift. And normally, the IAP and APP runs OK. This hard fault appear just when I disable the USB host function in APP. So it confused me.
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x00006000U /*!< Vector Table base offset field.
2018-11-23 04:00 AM
Looks to be loading a pointer with the content of an ASCII string.
Really should be looking at LR and PC values and understanding the specific code that is faulting. Look at .MAP file or listing file.
2018-11-25 06:53 PM
Yes, I think so. Just disable the USB function and the code size reduced, so the map changed, this may related with the problem. And I am looking at the assemble code now, I hope there will be find something.
2018-11-25 07:32 PM
Make sure you have a couple of KB for the stack
2018-11-25 09:08 PM
Yes, the hard fault happens at before the main() function, so I think the stack is no problem.
2018-11-25 09:34 PM
GNU tools?
Might also want to check startup code, and SystemInit() routines and call tree. Be especially conscious that statics may not yet be initialized when SystemInit() is called.