cancel
Showing results for 
Search instead for 
Did you mean: 

bootloader without manual pin settings

prsh
Associate II

hello

I am using stm32l4 series microcontroller with keil mdk arm 5 programing.

Had successfully completed the booting process by manually setting boot0 pin and resetting the device using flash loader demo tool. Now i wanted to do the same without manual change of boot0 pin. Is it possible???Is there any tool for purpose??

Thanks​

8 REPLIES 8

Which L4 part?

Something like this would probably work if the code isn't checking the flash

/*
In startup.s
 
Reset_Handler PROC
    EXPORT Reset_Handler [WEAK]
    IMPORT SystemInit
    IMPORT __main
 
    LDR R0, =0x20017FF0 ; Address for RAM signature
    LDR R1, =0xDEADBEEF
    LDR R2, [R0, #0]
    STR R0, [R0, #0] ; Invalidate
    CMP R2, R1
    BEQ Reboot_Loader
 
    LDR R0, =SystemInit
    BLX R0
    LDR R0, =__main
    BX  R0
 
    ENDP ; Reset_Handler
 
 
Reboot_Loader PROC
    EXPORT Reboot_Loader
 
    LDR R0, =0x40021060 ; RCC_APB2ENR
    LDR R1, =0x00000001 ; ENABLE SYSCFG CLOCK
    STR R1, [R0, #0]
    LDR R0, =0x40010000 ; SYSCFG_MEMRMP
    LDR R1, =0x00000001 ; MAP ROM AT ZERO
    STR R1, [R0, #0]
    LDR R0, =0x1FFF0000 ; ROM BASE of L4
    LDR SP,[R0, #0] ; SP @ +0
    LDR R0,[R0, #4] ; PC @ +4
    BX R0
 
    ENDP ;sourcer32@gmail.com
 
 
In main.c */
 
//***************************************************************************
 
void BootDFU(void)
{
  puts("Entering Boot Loader..");
  *((unsigned long *)0x20017FF0) = 0xDEADBEEF; // 96KB
  __DSB();
  NVIC_SystemReset(); 
}
 
//***************************************************************************

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

STM32L432KX and bootloader using uart

prsh
Associate II

Also what will be the state of BOOT0 pin??

You're defining the pin state externally, you've indicated that's LOW.​

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

For the STM32L432 change the RAM address to 0x2000BFF0 or 0x2000FFF0 to place the magic value close to the 48K or 64K end of things.

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

i am going with backup register (rtc).

am i going right with the initialisations??

if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_9))

{

__HAL_RCC_PWR_IS_CLK_ENABLED();

HAL_PWR_EnableBkUpAccess();

__HAL_RCC_SRAM1_IS_CLK_SLEEP_ENABLED();

write_to_backup_rtc(1,0);

NVIC_SystemReset();

if(read_from_backup_rtc(1,0) == 1)

{

BootLoaderInit(1);

}

  }

prsh
Associate II

successfully done bootloading. but issue with the current consumption.

in bootloading mode -->> 0.015-0.016A

in programming mode -->> 0.003 - 0.004A

have given timer after which only my bootloading mode starts but it is sometimes showing correct output as expected (0.004A i.e. initially program is running than after sometime going in boot mode) and sometimes initially going in boot mode (0.016A).

Thanks in advance!