[solved] Programming a diymore STM32F407VET6 board with DFU over USB - Page 1
Forum section: electronics / general

author: psysc0rpi0n
author_rank: Frequent Contributor
timestamp: April 15, 2023, 01:11:34 am
content: Hi.I bought a similar board to this one quite some time ago:https://www.diymore.cc/products/stm32f4-discovery-stm32f407vgt6-microcontroller-32bit-flash-mcu-arm-cortex-m4-core-development-boardI say similar because the one I bought seems not available anymore there and, instead, they have that VGT6 instead of VET6 (mine).I never used it before but today I decided to spend some time with it.I found this example code to make PC8 blink. I just changed the frequency to be able to check the blinking/toggling with a DMM becaus emy scope is actually at work.Code:void setup() {pinMode(PC8, OUTPUT);}void loop() {digitalWrite(PC8,HIGH);delay(10);digitalWrite(PC8,LOW);delay(10);}I compiled it with Arduino IDE and used the generated.elffile to upload it to the board.To program the board we wactually must pull BOOT1 pin to LOW and only then plug in the USB cable. Then we can see the device in DFU mode with:Code:$ lsusbBus 002 Device 070: ID 0483:df11 STMicroelectronics STM Device in DFU Mode$_Then I installeddfu-utiland tried to talk with the device:Code:$ sudo dfu-util --listFound DFU: [0483:df11] ver=2200, devnum=70, cfg=1, intf=0, path="2-1", alt=3, name="@Device Feature/0xFFFF0000/01*004 e", serial="3962374B3238"Found DFU: [0483:df11] ver=2200, devnum=70, cfg=1, intf=0, path="2-1", alt=2, name="@OTP Memory /0x1FFF7800/01*512 e,01*016 e", serial="3962374B3238"Found DFU: [0483:df11] ver=2200, devnum=70, cfg=1, intf=0, path="2-1", alt=1, name="@Option Bytes /0x1FFFC000/01*016 e", serial="3962374B3238"Found DFU: [0483:df11] ver=2200, devnum=70, cfg=1, intf=0, path="2-1", alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg", serial="3962374B3238"$_Code:$ sudo dfu-util --download /tmp/arduino/sketches/565B457541832EAED9889914CDFB6C29/test.ino.elf --device=0483:df11 -a "@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" --dfuse-address 0x08000000dfu-util 0.9Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.Copyright 2010-2016 Tormod Volden and Stefan SchmidtThis program is Free Software and has ABSOLUTELY NO WARRANTYPlease report bugs to http://sourceforge.net/p/dfu-util/tickets/dfu-util: Invalid DFU suffix signaturedfu-util: A valid DFU suffix will be required in a future dfu-util release!!!Opening DFU capable USB device...ID 0483:df11Run-time device DFU version 011aClaiming USB DFU Interface...Setting Alternate Setting #0 ...Determining device status: state = dfuIDLE, status = 0dfuIDLE, continuingDFU mode device DFU version 011aDevice returned transfer size 2048DfuSe interface name: "Internal Flash "Downloading to address = 0x08000000, size = 619612Download[=========================] 100% 619612 bytesDownload done.File downloaded successfully$_This is exactly the same:Code:sudo dfu-util --download /tmp/arduino/sketches/565B457541832EAED9889914CDFB6C29/test.ino.elf --device=0483:df11 -a 0 --dfuse-address 0x08000000The-a 0is just an alias for the longer version above.After this, we need to remove the pull-down from BOOT1, pull down BOOT0, unplug and plugin the USB cable and press the reset button to make the program run. So I did, and then I checked with the DMM if PC8 was toggling or not.It wasn't.So, next I tried STM32CubeProgrammer. BOOT1 to low, unplug and plugin USB cable, press reset and connect to the device in STM32CubeProgrammer. Then selected the file and hit "Start programming". When it finished, again remove BOOT1 pull down, pull down BOOT0, unplug and plugin USB and press reset. Check PC8 with DMM andit is actually toggling.So, where did I go wrong withdfu-util?

author: zilp
author_rank: Frequent Contributor
timestamp: April 15, 2023, 07:28:28 am
content: I don't think that dfu-util can parse ELF files, so you'll have to convert it to a raw image or DfuSe first.

author: bingo600
author_rank: Super Contributor
timestamp: April 15, 2023, 07:50:03 am
content: I'm using the.binfile with dfu-utilJust generate with objcopy from the elfhttps://stackoverflow.com/questions/49680382/objcopy-elf-to-bin-file/Bingo

author: newbrain
author_rank: Super Contributor
timestamp: April 15, 2023, 09:48:36 am
content: Quote from: bingo600 on April 15, 2023, 07:50:03 amAre you really?From the command lines you have posted it would seem you are using the .elf file, and dfu-util is complaining, also, notice the size!I suspect that more than 600 kB for a blinky is a bit excessive even for an Arduino framework.QuoteEdit: apologies to bingo600 - OP's name had scrolled up off screen and I thought it was bingo600...

author: psysc0rpi0n
author_rank: Frequent Contributor
timestamp: April 15, 2023, 09:48:59 am
content: Quote from: newbrain on April 15, 2023, 09:48:36 amYeah, you're right. I0m actually using the.elffile, not the.binIn that case I'm going to try the.binfile that Arduino IDE also generates!Edited;And yes, the binary file is working in the same way as the STM32CubeProgrammer do!Thanks for the help to those 3 kind persons!

author: psysc0rpi0n
author_rank: Frequent Contributor
timestamp: April 15, 2023, 11:56:08 am
content: I posted here my ridehttps://www.hackster.io/PsySc0rpi0n/stm32f407vet-diymore-cc-board-programming-2af289