cancel
Showing results for 
Search instead for 
Did you mean: 

IAP application startup error

longchair
Associate III
Posted on November 08, 2012 at 10:22

Hello,

I have been studying the IAP samples recently, basically the one from AN2557.

I have tried to adapt it for my application, the idea being that I would load a new fw from the microSD card when it would be available.

therefore I have made in my Keil projet two configurations :

- One being for the bootloader

- One being for the ''application''.

I just want to be able to debug the application without having to use the bootloader to update the fw.

I am working on a STM32F103RBT6, and I have defined that my application would be stored at 0x08010000 (upper 64k), and my bootloader will lay at the regular address 0x08000000.

therefore in my bootloader configuration , I have defined that :

IROM1 = 0x08000000

and in the application configuration

IROM1 = 0x08010000

Then I have defined the BOOTDLOADER define in the bootloader config.

and I have the following main function :

int main (void)

{

 #ifdef BOOTLOADER

  // check if we need a FW update

  if ((f_mount(0,&fs))== FR_OK)

  {

   // check if we have a FirmwareFile

   if (FIRMWARE_Upload(''GueNightFlyARM.bin'',ApplicationAddress)==SUCCESS)

   {

    // reset the chip

    NVIC_SystemReset();

   }

  }

  

  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x10000);

  

  // now run the application

  /* Test if user code is programmed starting from address ''ApplicationAddress'' */

  if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)

  {

   /* Jump to user application */

   JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);

   //JumpAddress = *(__IO uint32_t*) (ApplicationAddress );

   Jump_To_Application = (void (*)())JumpAddress;

   

   /* Initialize user application's Stack Pointer */

   __set_MSP(*(__IO uint32_t*) ApplicationAddress);

   Jump_To_Application();

  }

  #else

   return MainApplication();

  #endif

}

The upload of the firware seems to be good, when i compare memory with the binary from the bin file, they seem identical. Though when it jumps to the application with

Jump_To_Application();

, I get a NMI_handler exception hander call.

I have been comparing the samples with my code and don't see why this would happen.

Any Idea is welcome :)

Lionel.
1 REPLY 1
Posted on November 08, 2012 at 13:38

The NMI handler might just be the dumping spot for undefined vectors, which share a common address. This most likely would be coming from a Hard Fault, it could come from other interrupts you are generating in the boot loader, but not servicing in the application.

Use a debugger, and single step the jump into the application. Understand where it goes. A jump to an even address will fault on a Cortex-M3.

Disassemble, and/or review the code and hex file you have for the application. Confirm it is building for the correct address, and the vector table is correct. Confirm the code is being loaded into flash properly.

Watch also what SystemInit() is doing, a lot of ST code assumes reset conditions of the RCC and switches clocks with little care to what the part is currently using as a source.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..