2017-02-13 12:45 PM
Posted on February 13, 2017 at 21:45
So I'm DFU'ing. Successfully bootloading the device with the USB connections on PA11 and PA12 DFU is built into the STM32L476. Plodding along and loading my micro a few times with a few different compilations all good. THEN ---- POOF. One of them won't verify using DFU.
So I try a file that just *DID* work with DFU.
Yep - It worked again ?? WTH over.
Dump the offending file into the device with STLink ---- works.....
I repeat a few things, including inappropriate workplace language and its consistent. (The PROBLEM. Not the Language. I try to mix that up a lot. )
So thinking I have the all singing and dancing IDE (Truestudio), I look for PAD out options. D A R N if I can find it.
So I visit here again (I like it here) and I look here and find
https://community.st.com/s/question/0D50X00009XkdwK/dfu-dfuse-problem-with-stm32l4-stm32l476vg
Really?
Get your HEX EDITOR (XVI32) out and add PADDING?
The word LAME comes to mind. And 'DFU' takes on a whole other meaning. It's inside a 64 bit part for crying out loud.. Why doesn't the BLOWN IN DFU version know that - and ALIGN so the flash programming *blocks* are padded to 8 bytes?
Okay there's the blatant whining and complaining part. Can someone embarrass me with the obvious little tidbit that I *must* be overlooking?
Solved! Go to Solution.
2019-04-01 03:11 AM
Hi all,
I was trying to automate the generation of the dfu file using HEX2DFU (thanks Clive !) file but I got an error message regarding the stack pointer:
>HEX2DFU.exe blink2.hex -out blink2.dfu
HEX2DFU 0.01 Copyright (C) 2013-2017 sourcer32@gmail.com
All Rights Reserved, Non-Commercial Use Only
Loading blink2.hex...
02 Addr:0000 Type:04 Seg:00000000
:020000040801F1
Extended Linear 08010000
Basis : 08010000
04 Addr:0000 Type:05 Seg:08010000
:040000050801257D4C
00 Addr:0000 Type:01 Seg:08010000
:00000001FF
VID:0483 PID:DF11 VER:011A
ADDR:08010000 SIZE:00003720
SP:20050000 PC:0801257D
ERROR: Image appears to have invalid initial stack pointer
but strange enough, nor "DfuSe demo" nor "DFU File Manager" (both at v3.0.6) complains about the stack pointer and even my USB bootloader (that opens an *.dfu from a mass storage device and flash it) seems to work fine... apps are loaded and launched w/o problems.
My LD files are:
/* Entry Point */
ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = 0x20050000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x400; /* required amount of heap */
_Min_Stack_Size = 0x800; /* required amount of stack */
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
BOOTFLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
APPLFLASH (rx) : ORIGIN = 0x08010000, LENGTH = 960K /* (1024K-64K=960K */
}
...
so I don't understand where the alignment problem is...
any ideas ?
thanks,
Giampaolo
2019-04-01 03:59 AM
Hi Clive,
I've found an old message where you suggest to reduce the RAM size...
it works fine just by changing from the application's LD from:
_estack = 0x20050000;
to:
_estack = 0x20002000;
would it be possible for you to update HEX2DFU ?
tnx
Giampaolo
2019-07-18 02:33 AM
Hi, Clive.
Does your utility provide ability to encorporate Optional Bytes in the dfu output?
Best regards.
2020-06-09 04:15 PM
Hi clive 1
how to add _estack in vector table startup_stm32l476xx.s
i am using keil ide. i'm not aware of startup files and linker files. please can you help me out
Thanks,
Raghu.
2020-06-09 04:35 PM
...
__Vectors DCD 0x20002000 ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
...
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR SP, =__initial_sp
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
2020-06-09 10:38 PM
Hi Clive,
Thanks for quick response. now it's working
Thanks,
Raghu.
2020-06-18 09:19 AM
Hi clive 1
could you please share with me, dfuse demo working documentation or any refer link. how it is erasing the flash and writing.
Thanks,
Raghu.
2020-06-18 11:15 AM
Please use Google, I have finite resources
File Format Documentation I worked from, UM0391 - DfuSe File Format. Specification
https://drive.google.com/file/d/0B7OY5pub_GfIR2ZBcDk3UXNjdzg/view?usp=sharing
2021-03-31 12:26 AM
Hello,
Just to say a big THANKS to you for your utility that saved my day.
Four years after you discovered this solution it is always useful.
For information, i was trying to update the firmware of a custom STM32L476 board with USB instead of ST-Link.
The dfuse_demo was not able to detect my STM32, but a dfu-util -l was successful... (not understand that)
Doing a firmware download using dfu-util was successful (apparently), but the STM32 was not starting at all after reset.
Using hex2dfu before dfu-util has resolved this problem.
With best regards,
Stephane