Author Topic: [solved] Programming a diymore STM32F407VET6 board with DFU over USB  (Read 1188 times)

0 Members and 1 Guest are viewing this topic.

Offline psysc0rpi0nTopic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: ar
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-board
I 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: [Select]
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 .elf file 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: [Select]
$ lsusb
Bus 002 Device 070: ID 0483:df11 STMicroelectronics STM Device in DFU Mode
$_

Then I installed dfu-util and tried to talk with the device:
Code: [Select]
$ sudo dfu-util --list
Found 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: [Select]
$ 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 0x08000000
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Opening DFU capable USB device...
ID 0483:df11
Run-time device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash  "
Downloading to address = 0x08000000, size = 619612
Download [=========================] 100%       619612 bytes
Download done.
File downloaded successfully
$_

This is exactly the same:
Code: [Select]
sudo dfu-util --download /tmp/arduino/sketches/565B457541832EAED9889914CDFB6C29/test.ino.elf --device=0483:df11 -a 0 --dfuse-address 0x08000000

The -a 0 is 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 and it is actually toggling.

So, where did I go wrong with dfu-util?
« Last Edit: April 15, 2023, 09:55:01 am by psysc0rpi0n »
 

Offline zilp

  • Regular Contributor
  • *
  • Posts: 206
  • Country: de
Re: Programming a diymore STM32F407VET6 board with DFU over USB
« Reply #1 on: April 15, 2023, 07:28:28 am »
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.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 1989
  • Country: dk
Re: Programming a diymore STM32F407VET6 board with DFU over USB
« Reply #2 on: April 15, 2023, 07:50:03 am »
I'm using the .bin file with dfu-util

Just generate with objcopy from the elf
https://stackoverflow.com/questions/49680382/objcopy-elf-to-bin-file

/Bingo
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1719
  • Country: se
Re: Programming a diymore STM32F407VET6 board with DFU over USB
« Reply #3 on: April 15, 2023, 09:48:36 am »
I'm using the .bin file with dfu-util
Are 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. >:D
Quote
Code: [Select]
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
...
Downloading to address = 0x08000000, size = 619612
Download [=========================] 100%       619612 bytes
Edit: apologies to bingo600 - OP's name had scrolled up off screen and I thought it was bingo600...
« Last Edit: April 15, 2023, 10:07:30 am by newbrain »
Nandemo wa shiranai wa yo, shitteru koto dake.
 

Offline psysc0rpi0nTopic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: ar
Re: Programming a diymore STM32F407VET6 board with DFU over USB
« Reply #4 on: April 15, 2023, 09:48:59 am »
I'm using the .bin file with dfu-util
Are 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. >:D
Quote
Code: [Select]
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
...
Downloading to address = 0x08000000, size = 619612
Download [=========================] 100%       619612 bytes

Yeah, you're right. I0m actually using the .elf file, not the .bin

In that case I'm going to try the .bin file 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!
[solved]
« Last Edit: April 15, 2023, 09:54:33 am by psysc0rpi0n »
 

Offline psysc0rpi0nTopic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: ar
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf