DFU issue with system Boatloader: ''Matching Not good''..
Hi,
I'm using STM32L476RE in a custom board without HSE. I ported Discovery (76VG) Blink Project (following Clive1's DFU system bootloader) and successfully tested on my board in both Keil and TureStudio. It’s only a 4KB .DFU file to load by DfuseDemo. Now, in my real Truestudio project generated by CubeMx, the .dfu file is 68KB and DFU showing following error ''Matching is not good'' (attached).
Am I doing something wrong in configuration? I can’t use Keil here as code size exceeds limit. Datasheet says, System memory 28KB aliased on 0x00000000-0x000FFFF and SRAM1 96KB and Flash 1MB (Attached Image). I request your guidance to solve this issue. In the final version of my custom board, I'll only have USB (or SD) to load program.
In Keil, I've changed my startup_stm32l476xx.s file
Reboot_Loader PROC
EXPORT Reboot_Loader
LDR R0, =0x40021060 ;// RCC_APB2ENR Address 0x40021000 (Base)+60 (offset)
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 ;
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =0x20017FF0 ; // End Address of SRAM1 (STM32L4) 0x20017FFF --Bootloader_Ram_Key_Address
LDR R1, =0xDEADBEEF ;// Bootloader_Key_Value
LDR R2, [R0, #0]
STR R0, [R0, #0] ;// Invalidate Bootloader_Key_Value
CMP R2, R1
BEQ Reboot_Loader ; /* End bootloader jumping */
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Reset handler
In Atollic Truestudio,
.section .text.Reboot_Handler
.type Reboot_Handler, %function
Reboot_Handler:
LDR R0, =0x40021060 // RCC_APB2ENR Address 0x40021000 (Base)+60 (offset)
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
.size Reboot_Handler, .-Reboot_Handler
.section .text.Reset_Handler
.weak Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
LDR R0, =0x20017FF0 // End Address of SRAM1 (STM32L4) 0x20017FFF --Bootloader_Ram_Key_Address
LDR R1, =0xDEADBEEF // Bootloader_Key_Value
LDR R2, [R0, #0]
STR R0, [R0, #0] // Invalidate Bootloader_Key_Value
CMP R2, R1
BEQ Reboot_Handler // Jump to DfuModeEntry Lable if Bootloader_Key_Value matches
// Conitnue without entering DFU Mode
ldr sp, =_estack /* Atollic update: set stack pointer */
/*Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2], #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
bl __libc_init_array
/* Call the application's entry point.*/
bl main
LoopForever:
b LoopForever
.size Reset_Handler, .-Reset_Handler
#stm32l476 #dfu Note: this post was migrated and contained many threaded conversations, some content may be missing.