upgrade the APP and jump to Boot directly from the APP (without restarting), but HardFault error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

upgrade the APP and jump to Boot directly from the APP (without restarting), but HardFault error

1,418件の閲覧回数
ljq
Contributor II
  • Chip: S32K146    OS:FreeRtos

  • App Jump Boot
    • #define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile uint32_t * ) 0xe000e010 ) )
      #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )
      void EnterUpgradeModeForJump(void)
      {
          T8U i;
          EnterCriticalCode();
          DisableAllIRQs();
          DISABLE_INTERRUPTS();
      for(i=0;i<SYSTEM_TASK_ID_SYSMONITOR;i++)
      {
      System_Task_Deactivate(i);
      }
      Sys_Board_Hw_DeInit();
      Hal_FlashInit_Api();
      Update_Program_Mcu_SysInfo();
      Hal_FlashDeInit_Api();
      /* Stop and clear the SysTick. */
      portNVIC_SYSTICK_CTRL_REG = 0UL;
      portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;
      ExitCriticalCode();
      App_JumpTo_Boot_API();
      }
    • App Deinit the hardware resources used before the jump (except for Clock and IO, there is no Deinit that can be called by Clock,IO port cannot be powered off), and reinitialize the Clock and serial ports in Boot
    • can jump to Boot normally and upgrade, but HardFault occurs during the upgrade process
    • If the code of Boot is rebooted and upgraded, it is OK, only if the App is directly jumped is an error
0 件の賞賛
返信
3 返答(返信)

1,404件の閲覧回数
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

first, I would try to find the source of hard fault. This application note could be useful:

https://www.nxp.com/docs/en/application-note/AN12201.pdf

There's obviously something what is not de-initialized before jump. This is always a risk when jumping from one application to another without reset. Especially, I would check all interrupts - if interrupt flags, local enable bits in peripherals, interrupt priorities are reverted back to default state.

Regards,

Lukas

 

0 件の賞賛
返信

1,394件の閲覧回数
ljq
Contributor II

void BusFault_Handler(void)
{

BFSR = (S32_SCB->CFSR & 0x0000FF00);
/* BusFault Status Register (BFSR) CFSR[15:8] indicates the cause of BusFault
* [15] BFARVALID = 1 BFAR holds a valid fault address
* [13] LSPERR = 1 Bus fault occurred during floating-point lazy state preservation
* [12] STKERR = 1 Stacking for an exception entry has caused BusFault, BFAR address is not valid
* [11] UNSTKERR = 1 Unstack for an exception return has caused BusFault, BFAR address is not valid
* [10] IMPRECISERR = 1 Imprecise data bus error, BFAR address is not valid
* [9] PRECISERR = 1 Precise data bus error, BFAR address is valid
* [8] IBUSERR = 1 error on prefetching an instruction, BFAR address is invalid
* */
if(BFSR & S32_SCB_CFSR_BFARVALID_MASK){ // If the address in BFAR register is valid
BFAR = S32_SCB->BFAR; // BFAR holds the address of the location that generated the BusFault
}
if(BFSR & S32_SCB_CFSR_PRECISERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_IMPRECISERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_LSPERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_STKERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_UNSTKERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_IBUSERR_MASK) asm("BKPT");

asm("MOVS R0, #4");
asm("MOV R1, LR");
asm("TST R0, R1");
asm("BEQ __MSP");
asm("MRS R0, PSP");
asm("B getStackFrame");
asm("__MSP:");
asm("MRS R0, MSP");
asm("B getStackFrame");
}

 
  • Each time it is stuck in the following error :BFSR = 0x8200

BusFault_Handler(): if(BFSR & S32_SCB_CFSR_PRECISERR_MASK) asm("BKPT");

BFAR point to __isr_vector

0 件の賞賛
返信

1,235件の閲覧回数
pedritorres21
Contributor I

void BusFault_Handler(void)
{

BFSR = (S32_SCB->CFSR & 0x0000FF00);
/* BusFault Status Register (BFSR) CFSR[15:8] indicates the cause of BusFault
* [15] BFARVALID = 1 BFAR holds a valid fault address
* [13] LSPERR = 1 Bus fault occurred during floating-point lazy state preservation
* [12] STKERR = 1 Stacking for an exception entry has caused BusFault, BFAR address is not valid
* [11] UNSTKERR = 1 Unstack for an exception return has caused BusFault, BFAR address is not valid
* [10] IMPRECISERR = 1 Imprecise data bus error, BFAR address is not valid
* [9] PRECISERR = 1 Precise data bus error, BFAR address is valid
* [8] IBUSERR = 1 error on prefetching an instruction, BFAR address is invalid
* */
if(BFSR & S32_SCB_CFSR_BFARVALID_MASK){ // If the address in BFAR register is valid
BFAR = S32_SCB->BFAR; // BFAR holds applinked apk address of the location that generated the BusFault
}
if(BFSR & S32_SCB_CFSR_PRECISERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_IMPRECISERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_LSPERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_STKERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_UNSTKERR_MASK) asm("BKPT");
if(BFSR & S32_SCB_CFSR_IBUSERR_MASK) asm("BKPT");

asm("MOVS R0, #4");
asm("MOV R1, LR");
asm("TST R0, R1");
asm("BEQ __MSP");
asm("MRS R0, PSP");
asm("B getStackFrame");
asm("__MSP:");
asm("MRS R0, MSP");
asm("B getStackFrame");
}

 
  • Each time it is stuck in the following error :BFSR = 0x8200

BusFault_Handler(): if(BFSR & S32_SCB_CFSR_PRECISERR_MASK) asm("BKPT");

BFAR point to __isr_vector

I am facing the same issue.

0 件の賞賛
返信