STM32L476 dfu upgrade bug

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
shaoziyang
Posts: 337
Joined: Sun Apr 17, 2016 1:55 pm

STM32L476 dfu upgrade bug

Post by shaoziyang » Tue Nov 15, 2016 2:50 pm

I found when upgrade firmware for STM32L476 with dfu file, it will not run after download. But when I use stlink to download hex file, it is work.

I try it in dfu-util in ubuntu and DfuSe Demo in windows, get same result.

User avatar
dhylands
Posts: 3454
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: STM32L476 dfu upgrade bug

Post by dhylands » Tue Nov 15, 2016 5:25 pm

I can reproduce that with my STM32L476DISC (running Ubuntu 16.04 on my build machine). If I use pydfu.py (which is the default), then it seems to work fine.
So this works:

Code: Select all

make BOARD=STM32F476DISC deploy
while this doesn't:

Code: Select all

make BOARD=STM32L476DISC USE_PYDFU=0 deploy
MicroPython has been using pydfu.py as the default since it's faster than dfu-util

Since I was flashing the identical same image, I have to conclude that its a bug in dfu-util. I was using a version of dfu-util built from the latest sources.

shaoziyang
Posts: 337
Joined: Sun Apr 17, 2016 1:55 pm

Re: STM32L476 dfu upgrade bug

Post by shaoziyang » Wed Nov 16, 2016 1:27 am

dhylands wrote:I can reproduce that with my STM32L476DISC (running Ubuntu 16.04 on my build machine). If I use pydfu.py (which is the default), then it seems to work fine.
So this works:

Code: Select all

make BOARD=STM32F476DISC deploy
while this doesn't:

Code: Select all

make BOARD=STM32L476DISC USE_PYDFU=0 deploy
MicroPython has been using pydfu.py as the default since it's faster than dfu-util

Since I was flashing the identical same image, I have to conclude that its a bug in dfu-util. I was using a version of dfu-util built from the latest sources.
I try to generate dfu with hex file, and using dfu-util and DfuSe to download, it is work.

shaoziyang
Posts: 337
Joined: Sun Apr 17, 2016 1:55 pm

Re: STM32L476 dfu upgrade bug

Post by shaoziyang » Wed Nov 16, 2016 2:37 pm

dhylands wrote:I can reproduce that with my STM32L476DISC (running Ubuntu 16.04 on my build machine). If I use pydfu.py (which is the default), then it seems to work fine.
So this works:

Code: Select all

make BOARD=STM32F476DISC deploy
while this doesn't:

Code: Select all

make BOARD=STM32L476DISC USE_PYDFU=0 deploy
MicroPython has been using pydfu.py as the default since it's faster than dfu-util

Since I was flashing the identical same image, I have to conclude that its a bug in dfu-util. I was using a version of dfu-util built from the latest sources.
Old version (1.8.2) is work with dfu-util.

User avatar
dhylands
Posts: 3454
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: STM32L476 dfu upgrade bug

Post by dhylands » Wed Nov 16, 2016 4:40 pm

I think that what happens is that the very last flash block doesn't get written properly. Whether a given image will work or not depends on what exactly is in that last flash block.

Regardless, it's still a bug in dfu-util and NOT a bug in MicroPython.

shaoziyang
Posts: 337
Joined: Sun Apr 17, 2016 1:55 pm

Re: STM32L476 dfu upgrade bug

Post by shaoziyang » Thu Nov 17, 2016 2:40 pm

dhylands wrote:I think that what happens is that the very last flash block doesn't get written properly. Whether a given image will work or not depends on what exactly is in that last flash block.

Regardless, it's still a bug in dfu-util and NOT a bug in MicroPython.
I have read flash and make a compare, left is dfu can't run, right is fine one.

There are two block different, first is 0x4000-0x5FFF
1.jpg
1.jpg (145.08 KiB) Viewed 3323 times
2.jpg
2.jpg (142.17 KiB) Viewed 3323 times

shaoziyang
Posts: 337
Joined: Sun Apr 17, 2016 1:55 pm

Re: STM32L476 dfu upgrade bug

Post by shaoziyang » Thu Nov 17, 2016 2:41 pm

second is from 0x20000-0x487FF
3.jpg
3.jpg (156 KiB) Viewed 3322 times
4.jpg
4.jpg (144.13 KiB) Viewed 3322 times

User avatar
dhylands
Posts: 3454
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: STM32L476 dfu upgrade bug

Post by dhylands » Thu Nov 17, 2016 5:19 pm

Interesting. So not at the end, but someplace in the middle. The 0x4000 is the beginning of the block right after the filesystem.

So it's still random as to whether a given image will work or not, and it will only work until it has to call code in one of the corrupted blocks.

Post Reply