cancel
Showing results for 
Search instead for 
Did you mean: 

Can I set or act like that the boot0 pin set by the software? I use STM32F427VI. Thanks in advance.

PIyak.958
Associate II
 
5 REPLIES 5

You can call into the ROM, the processor can execute any arbitrary code you point it too.

You can remap memory, get the Reference Manual, search MEMRMP

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

Thank you for your answer.

I've tried this with this code. But it doesnt work. Do you see any mistakes?

/**

 * Function to perform jump to system memory boot from user application

 *

 * Call function when you want to jump to system memory

 */

void JumpToBootloader(void) {

 void (*SysMemBootJump)(void);

   /**

    * Step: Set system memory address.

    *      

    *      For STM32F429, system memory is on 0x1FFF 0000

    *      For other families, check AN2606 document table 110 with descriptions of memory addresses

    */

   volatile uint32_t addr = 0x1FFF0000;

   /**

    * Step: Disable RCC, set it to default (after reset) settings

    *      Internal clock, no PLL, etc.

    */

   HAL_RCC_DeInit();

   /**

    * Step: Disable systick timer and reset it to default values

    */

   SysTick->CTRL = 0;

   SysTick->LOAD = 0;

   SysTick->VAL = 0;

   /**

    * Step: Disable all interrupts

    */

   __disable_irq();

   /**

    * Step: Remap system memory to address 0x0000 0000 in address space

    *      For each family registers may be different.

    *      Check reference manual for each family.

    *

    *      For STM32F4xx, MEMRMP register in SYSCFG is used (bits[1:0])

    *      For STM32F0xx, CFGR1 register in SYSCFG is used (bits[1:0])

    *      For others, check family reference manual

    */

   //Remap by hand... {

   //SYSCFG->MEMRMP = 0x01;

   //} ...or if you use HAL drivers

   __HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();   //Call HAL macro to do this for you

   /**

    * Step: Set jump memory location for system memory

    *      Use address with 4 bytes offset which specifies jump location where program starts

    */

   SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));

   /**

    * Step: Set main stack pointer.

    *      This step must be done last otherwise local variables in this function

    *      don't have proper value since stack pointer is located on different position

    *

    *      Set direct address location which specifies stack pointer in SRAM location

    */

   __set_MSP(*(uint32_t *)addr);

   /**

    * Step: Actually call our function to jump to set location

    *      This will start system memory execution

    */

   SysMemBootJump();

   /**

    * Step: Connect USB<->UART converter to dedicated USART pins and test

    *      and test with bootloader works with STM32 Flash Loader Demonstrator software

    */

}

Is the SYSCFG clock enabled, does someone of the other side enable the CPU IRQ?

Used this method on the F205/F405 for a decade or more

Reset_Handler    PROC
                 EXPORT  Reset_Handler             [WEAK]
        IMPORT  SystemInit
        IMPORT  __main
 
                LDR     R0, =0x2001FFFC
                LDR     R1, =0xBEEFBEEF
                LDR     R2, [R0, #0]
                CMP     R1, R2
                BNE     NotDFuse
                STR     R0, [R0, #0] ; Invalidate
                LDR     R0, =0x40023844 ; RCC_APB2ENR
                LDR     R1, =0x00004000 ; ENABLE SYSCFG CLOCK
                STR     R1, [R0, #0]
                LDR     R0, =0x40013800 ; SYSCFG_MEMRMP
                LDR     R1, =0x00000001 ; MAP ROM AT ZERO
                STR     R1, [R0, #0]
                LDR     R0, =0x1FFF0000 ; ROM BASE
                LDR     SP,[R0, #0]
                LDR     R0,[R0, #4]
                BX      R0
NotDFuse
                LDR     R0, =SystemInit
                BLX     R0
 
                LDR     R0, =__main
                BX      R0
 
                ENDP ; sourcer32@gmail.com

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

The F427 may be a more complex beast with the ROM checking banking and bootable FLASH code. Use a Debugger, and determine if the ROM just bounces back control to your Reset Handler. In which case you'll probably want to implement your own loader to facilitate USB/DFU or USART update methods.

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

Hi Clive

I think, I dont understan what exactly is to do. I'm new to MCU.

I read many posts and also this one.

https://community.arm.com/developer/tools-software/tools/f/keil-forum/41955/stm32l072-jumping-to-embedded-bootloader-from-application-code

"Mixing up random ideas you copy and paste is not programming. Read the manuals and understand what you are doing."

I really want to understand how its works and what is to do.

Can yoe please help me?

What I know or think to know:

  • write smt. to ROM (0xBEEFBEEF)
  • and restart
  • is that what you wrote there in ROM then remap system memory to 0

Is that correct or is smth. missing?

Just crarify the thing on a hingher level and the go step by step deeper.

I hope you can help me to go trough the things and finally to reach tje goal.

Thanks in advance.