2015-06-12 06:59 AM
I want to develop product using stm32f030cc controller.for that product i want to develop boot loader which can jump to internal boot loader in system memory with out altering boot pin.right now my board is not ready so try to implement this on discovery kit stm32f0308 rev a.so which is the best way to jump on boot loader in system memory from user application????? and which are the change when i migrate to my board with stm32f030cc????
i am useng MDK-Arm 5 and stm32cubemx #stm32-bootloader-flash-loader2015-06-12 07:13 AM
Posted several examples of how this might be done for F0/Cortex-M0 parts.
https://community.st.com/0D50X00009Xkg1VSAR
Edit: Fixed DEAD LINK, Original post from 12-June-2015
2015-06-13 02:19 AM
i made following change in startup_stm32f030x8.s file
Reset_Handler PROC EXPORT Reset_Handler [WEAK] LDR R0, =0x2000FFF0 LDR R1, =0xDEADBEEF LDR R2, [R0, #0] STR R0, [R0, #0] ; Invalidate CMP R2, R1 BEQ Reboot_Loader IMPORT __main IMPORT SystemInit LDR R0, =SystemInit BLX R0 LDR R0, =__main BX R0 ENDP Reboot_Loader PROC EXPORT Reboot_Loader LDR R0, =0x40021018 ; RCC_APB2ENR (+0x18) LDR R1, =0x00000001 ; ENABLE SYSCFG CLOCK STR R1, [R0, #0] LDR R0, =0x40010000 ; SYSCFG_CFGR1 (+0x00) LDR R1, =0x00000001 ; MAP ROM AT ZERO STR R1, [R0, #0] LDR R0, =0x1FFFEC00 ; ROM BASE (STM32F03x) ; LDR R0, =0x1FFFC400 ; ROM BASE (STM32F04x); LDR R0, =0x1FFFEC00 ; ROM BASE (STM32F05x); LDR R0, =0x1FFFC800 ; ROM BASE (STM32F07x); LDR R0, =0x1FFFD800 ; ROM BASE (STM32F09x) LDR R1, [R0, #0] ; SP @ +0 MOV SP, R1 LDR R0, [R0, #4] ; PC @ +4 BX R0 ENDP ; but code got stuck on some hard fault handler and not even user application startedin step debug after executing ldr or str with resister as addres base instruction got in hardware fault( LDR R2, [R0, #0] STR R0, [R0, #0] ; Invalidate)2015-06-13 10:01 AM
Probably because the part only has 32 KB of SRAM?
Consider 0x20007FF0 With *((unsigned long *)0x20007FF0) = 0xDEADBEEF; on the C side before you reset the part.2015-06-14 10:39 PM
2017-07-13 08:12 AM
,
,
Hi Patel,
My Environment:
STM32F042 Nucleo-32 dev board which has STM32F042K6T6 MCU of 32pin QFP
KEIL ARM MDK v5
Host Windows 10 OS ,
The ,BOOT0 pin PB8 is not available on the CN3 or CN4 connector. ,
I've used the same code posted above in this thread as it is and in fact the user flash application is handing over the control to system memory bootloader successfully. However the bootloader code ,hands over the control to the user flash application within few mSecs. According to the datasheet of MCU, the bootloader code looks for the BOOT0 pin if the BOOTSEL option bit is not explicitly set to don't check for BOOT0 pin. ,This presents two solutions. First one is programming the BOOTSEL to skip checking the ,BOOT0 pin in the bootloader start routine.This will allow the BOOT0 pin to be used as normal GPIO pin for any other operations. The other one is setting the BOOT0 pin thru code using the internal pullup and to HIGH. I've used the second solution in the below posted code
So then I've created a new function that explicitly sets the BOOT0 pin to HIGH before making the jump to the system memory. This change fixed the loop of moving from bootloader to user flash application. The MCU stays in bootloader code. ,
//File : main.c
void SetBoot0Pin(void)
,
{,
__HAL_RCC_GPIOB_CLK_ENABLE(),,
GPIO_InitTypeDef gp,,
gp.Pin = GPIO_PIN_8, //BOOT0 pin,
gp.Mode = GPIO_MODE_OUTPUT_PP,,
gp.Speed = GPIO_SPEED_FREQ_LOW,,
HAL_GPIO_Init(GPIOB, &,gp),,
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, (GPIO_PinState) 1),,
}//File : startup_stm32f042x6.s
, Reset handler routine
,
Reset_Handler PROC,
EXPORT Reset_Handler [WEAK],
LDR R0, =0x200017F0,
LDR R1, =0xDEADDEAD,
LDR R2, [R0, ♯ 0],
STR R0, [R0, ♯ 0] , Invalidate,
CMP R2, R1,
BEQ Reboot_Loader,
IMPORT __main,
IMPORT SystemInit,
LDR R0, =SystemInit,
BLX R0,
LDR R0, =__main,
BX R0,
ENDP,
,
Reboot_Loader PROC,
EXPORT Reboot_Loader,
IMPORT SetBoot0Pin,
LDR R0, =SetBoot0Pin,
BLX R0,
LDR R0, =0x40021018 , RCC_APB2ENR (+0x18),
LDR R1, =0x00000001 , ENABLE SYSCFG CLOCK,
STR R1, [R0, ♯ 0],
LDR R0, =0x40010000 , SYSCFG_CFGR1 (+0x00),
LDR R1, =0x00000001 , MAP ROM AT ZERO,
STR R1, [R0, ♯ 0],
LDR R0, =0x1FFFC400 , ROM BASE (STM32F04x),
LDR R1, [R0, ♯ 0] , SP @ +0,
MOV SP, R1,
LDR R0, [R0, ♯ 4] , PC @ +4,
BX R0,
ENDP ,Snapshot when the code is jumped to system memory bootloader. Notice the jump to the code location 0x1FFFCB45 as per the memory window showing the value at the reset vector address.
Allowed the code to run for some time. Notice the change in PC register shown in the registers window
Hold on. The story is not ended.Next is to ensure that the device is available/detected as USB DFU device in device manager. This is where my setup is not working. The device is not re-enumerated and no entries of USB DFU device in device manager and so the Dfuse demo tool is not listing the device. what could be the problem? ,
I've used FTDI usb to serial cable and connected it to the nucleo board ,
PA9 -USART1 Tx
PA10 -USART1 RX
and ground of course
Also I've tried using the test app that was posted in other thread to find the device is in DFU mode. That application is not receiving any data that confirms that the USB DFU is not running. Notice that it is for STM32F072 but I hope that this should work for STM32F042 as well.
,The test app is not receiving any characters back from the device. Someone please guide me on what could be the problem?
2018-04-02 11:31 AM
Hi Clive,
I am using STM32F207.
My Boot0 pin is tied to ground. I am setting up my boot loader with internal SRAM. I am trying at address 0x2000 0000 or 0x4002 4000. but none of them works. I am suspecting I am not using the right address?
I am trying to access internal SRAM for my boot loader. In my case, could I use 0x20007FF0? if I need more than 32KB of SRAM, says 128KB of SRAM, what address should I use?
Your insight is greatly appreciated.
Best,
Henry Trinh
Cymer/ASML