Skip to main content
cable gu
Associate II
November 23, 2018
Question

Hardfault on IAP jump to APP

  • November 23, 2018
  • 4 replies
  • 2673 views

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?

    This topic has been closed for replies.

    4 replies

    u_2man
    Associate II
    November 23, 2018

    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

    cable gu
    cable guAuthor
    Associate II
    November 23, 2018

    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?

    u_2man
    Associate II
    November 23, 2018

    Have you shift the interrupt vector on your application code?

    cable gu
    cable guAuthor
    Associate II
    November 23, 2018

    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. 

    Tesla DeLorean
    Guru
    November 23, 2018

    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.​

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    cable gu
    cable guAuthor
    Associate II
    November 26, 2018

    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.

    Tesla DeLorean
    Guru
    November 26, 2018

    Make sure you have a couple of KB for the stack

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    cable gu
    cable guAuthor
    Associate II
    November 26, 2018

    Not GNU tools.

    You said that the statics not initialized means there is static variable or function?