This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Crash when using FPEC after IAP with STM32F103

Hi,

I work with µVison4 and a STM32F103RC. My software use lot's of peripherals (adc, usart, ...) and there is also an EEPROM Emulation (Using flash and FPEC). It works well when the code is loaded starting from 0x0800000. If I load the code staring from 0x08002000 with an "In Application Programming" (IAP), every thing (all peripherals, interrupts and so on) works well to as long as I don't try to write to the flash with FPEC or try to erase am flash page. As soon as I write to the flash, the program crashes. Exactly the same code loaded at 0x0800000 works without failure. The flash is unlocked and I have the same values in the Flash-register just before "staring page erase" or "write word".

Can some body help me to found out ma error? Thanks

Pascal

  • Do the IAP functions return an error code before the crash? Are you sure all the code programming the flash is located in RAM ?

  • Here some more informations about the software:

    the IAP-Software is loaded at 0x0800000 and is like this:

    ------------------------------------------------------
    int main (void)
    {

    unsigned long int JumpAddress;

    init_RCC();

    // *********************************************************************
    // a few lines code deleted:
    // waiting 1 sec while check usart1 if a new download is needed
    // if download is need, than do it now starting from APPLICATION_ADDRESS
    // *********************************************************************

    // Test if user code is programmed starting from address "APPLICATION_ADDRESS"

    if (((*(volatile unsigned long int *)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000) {
    // Jump to user application

    JumpAddress = *(volatile unsigned long int *) (APPLICATION_ADDRESS + 4); Jump_To_Application = (void *) JumpAddress;
    // Initialize user application's Stack Pointer

    __set_MSP(*(volatile unsigned long int *) APPLICATION_ADDRESS); Jump_To_Application(); } while (1) { }
    }

    -----------------------------------------------------

    When I load my main application staring from 0x0800000 the software works without failures.

    When I load my main application starting from 0x08002000 I uncomment the following in top of the code:

    NVIC_VTOR = (unsigned long int)0x2000; // uncomment with IAP!!!!

    This is the only difference between both applications (loaded at 0x0800000 and loaded at 0x08002000). There is no failure in the transmission of the code. As soon as I try to write to the flash or to erase a page, the software crashes when loaded at 0x08002000.

    If I move the "writing to flash" at an other place, the software crashes at the new place.

    Thanks for help

  • Please repost using the proper tags. I can't read this!

  • Here the message again:

    Some more informations about the software:

    the IAP-Software is loaded at 0x0800000 and is like this:

    int main (void)
    {
    
    unsigned long int JumpAddress;
    
    init_RCC();
    
    // *********************************************************************
    // a few lines code deleted:
    // waiting 1 sec while check usart1 if a new download is needed
    // if download is need, than do it now starting from APPLICATION_ADDRESS
    // *********************************************************************
    
    // Test if user code is programmed starting from address "APPLICATION_ADDRESS"
    
    if (((*(volatile unsigned long int *)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000) {
    // Jump to user application
    
    JumpAddress = *(volatile unsigned long int *) (APPLICATION_ADDRESS + 4); Jump_To_Application = (void *) JumpAddress;
    // Initialize user application's Stack Pointer
    
    __set_MSP(*(volatile unsigned long int *) APPLICATION_ADDRESS); Jump_To_Application(); } while (1) { }
    }
    
    

    When I load my main application staring from 0x0800000 the software works without failures.

    When I load my main application starting from 0x08002000 I uncomment the following in top of the code:

    NVIC_VTOR = (unsigned long int)0x2000; // uncomment with IAP!!!!
    


    This is the only difference between both applications (loaded at 0x0800000 and loaded at 0x08002000). There is no failure in the transmission of the code. As soon as I try to write to the flash or to erase a page, the software crashes when loaded at 0x08002000.

    If I move the "writing to flash" to an other location, the software crashes at the new location.

    I hope you can read it now
    Thanks for help