relocating program code STM32F103VE

Comments

5 comments

  • Avatar
    Royce Arnold

    Have you modified the flash_placement.xml file so that the links re-locates your vectors to where you intend?

    I have several application that run similar to what you describe.

    I have modified the

      STM32FXXXXXX_MemoryMap.xml     ---> Define you memory areas (i.e. Bootloader / Program / Storage).  In my case I relocated FLASH to 0x8020 0000)

      flash_placement.xml      --->  adjust the .vectors entry   (in my case 0x8020 0000)

      relocated the vector table using NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x20000) or equivalent.

     

     

    0
    Comment actions Permalink
  • Avatar
    Peter Lissenburg

    Hi Royce,

    Thanks for your reply. My post took a little while to appear here, in the mean time I emailed support and with some assistance from Michael found that the vector offset register was getting set incorrectly.

    This was due to a second call to SystemInit();; As the

    SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */

    line relied upon

    #define FLASH_BASE            ((uint32_t)0x08000000) /*!< FLASH base address in the alias region */

    Which is incorrect. As I want it to be 0x08008000 This does not normally matter because the start.s file sets it correctly ;

      ldr r0, =0xE000ED08
    #ifdef VECTORS_IN_RAM
      ldr r1, =_vectors_ram
    #else
      ldr r1, =_vectors
    #endif
      str r1, [r0]

    Using _vectors, AFTER the call to SystemInit();

    However a second call to SystemInit(); buried in my code was resetting it to the incorrect address again.

    Once that second call was commented out, all worked well with just the edit to the MemoryMap file. No other changes needed.

    Now I'm having "fun" making memory segments and assigning them to pages in the bottom of flash Working well.

    Still a little confused about the vectors, because if I leave the first page blank. On the memory window in the debugger I see 0xFE (?) but if I write a bunch of data there my program won't start. Well that makes sense, but why can't I see the vectors? I can live in ignorance about that while I get other work done, but it would be nice to know.

    Again thanks for your response.

    Cheers.

    Pete L.

     

     

    0
    Comment actions Permalink
  • Avatar
    Royce Arnold

    Pete,

     

    No problem. 

     

    Based on what you've stated, my take is that you may not have any initialized values at the original vector table location.  The processor will always use the original vector table locations (exception being the BOOT0/1 pins options) on start up before the SCB->VTOR is executed.  I have a bootloader application that utilizes the original vector table.  After it decides what to boot, it adjust the vector table location to meet the application requirements.  So, if you do not have any valid vectors defined in the original table, the application with run from the debugger, but not from a reset.Also, I'm not sure of changing the FLASH_BASE address.  That may have some undesirable side affects.  That is not a modification that was required for my applications.RA

    0
    Comment actions Permalink
  • Avatar
    Peter Lissenburg

    Hi Royce,

    it's all working OK with everything original except the modification to the memory map file.

    Pete L.

     

    0
    Comment actions Permalink
  • Avatar
    Peter Lissenburg

    Hi Royce, you are quite correct. I over looked the no debugger situation. And yes with the vectors in the right place I can now see them! And it boots out of reset!

    Cheers.

    Pete L.

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.