Built-in DFU programming via Arduino possible?

If you made your own board, post here, unless you built a Maple or Maple mini clone etc
Post Reply
arsadri
Posts: 6
Joined: Tue Sep 04, 2018 2:26 am

Built-in DFU programming via Arduino possible?

Post by arsadri » Wed Sep 05, 2018 3:28 am

Hi all, (I've searched a lot, if I need to read a FAQ please first answer my questions and then point me to that thread)

I like to design my own PCB (because of price, different shape and size, ...) and be able to program a STM32 MCU (other than STM32F103xxxx) via a USB cable and use it for serial communication in the sketch. (because it is convenient specially if you have many boards to program at the same time, or you need to reprogram your board many many times when the physical model of something you are investigating is unknown). (briefly, I can't use dev-boards) But I like Arduino because others are familiar with it and they can extend this design.)

Can any of STM32s with built-in DFU (AN3156) be programmed from Arduino IDE using their native USB port? How will they appear in the IDE? (In dfu-utils website http://dfu-util.sourceforge.net/, it says it supports almost all STM32s, and if I'm not mistaken Arduino IDE uses that??)

If not, it seems that, either I should clone maple-mini using STM32F103 and STM32duino-bootloader, or put a USB-to-Serial chip and keep programming the STM32 via its serial port. Am I right? (Can I make a Nucleo board and have either of ST-Link or mass storage methods?)

------------------
I have read every post in this section of the forum and pretty much any thread with keywords I have used in the text above and a lot more. Sorry if this is a FAQ.
(I've read : http://stm32duinoforum.com/forum/viewtopic.php?t=2427 and viewtopic.php?f=39&t=2386&start=10#p32281, still no clear answer, I've listed other posts I've read down below)
I have used Serial programming, SWD and JTAG before and I know how to design my own maplemini using: https://github.com/rogerclarkmelbourne/Arduino_STM32
I have used a nucleo64 board using:
https://github.com/stm32duino/Arduino_Core_STM32.
I now that new boards can be defined but the question is what will be their programming method?:
https://github.com/stm32duino/wiki/wiki ... nt-(board)

Best regards

edogaldo
Posts: 432
Joined: Fri Jun 03, 2016 8:19 am

Re: Built-in DFU programming via Arduino possible?

Post by edogaldo » Wed Sep 05, 2018 5:31 am

If you look in platform.txt and search for "uploader tools" you will find all details about supported upload tools and how to use them.
Then, boards.txt specifies, for each board, the supported upload methods.
You can even define your own upload methods if needed.

Best, E.
Last edited by edogaldo on Wed Sep 05, 2018 8:44 am, edited 1 time in total.

arsadri
Posts: 6
Joined: Tue Sep 04, 2018 2:26 am

Re: Built-in DFU programming via Arduino possible?

Post by arsadri » Wed Sep 05, 2018 8:44 am

Hi edogaldo,

tnx, so I have mass storage, st-link, serial and black magic, no programmer for DFU bootloader. Since there is no proper Mass-Storage-Virtual-COM bootloader, the answer to my question is NO. There is no way to use a USB cable for both programming and serial monitoring on all STM32s.(Only for those few supported by STM32duino)

According to "TN1235", the firmware on the nucleo-stm32f103 chips and the driver is a composite made up of both Mass storage and virtual-COM-port. Do we have access to the bin file programmed onto those chips?

Best regards
Alireza

edogaldo
Posts: 432
Joined: Fri Jun 03, 2016 8:19 am

Re: Built-in DFU programming via Arduino possible?

Post by edogaldo » Wed Sep 05, 2018 8:48 am

If you use Roger's core the you have DFU upload method: https://github.com/rogerclarkmelbourne/ ... m.txt#L112
Not sure it supports the ST's DFU protocol, you have to check..
STM official core instead doesn't support DFU as far as I know.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: Built-in DFU programming via Arduino possible?

Post by stevestrong » Wed Sep 05, 2018 9:36 am

According to AN3156, the built-in DFU are only in STM32F1 Series:
– STM32F105xx, STM32F107xx
So it looks like F103 does not have built-in DFU.
You are best served with stm32duino bootloader 2.0.
Do you really need that 8kB flash reserved by this? When your application is larger than 120kB, you may better use F4x series. Or revise your code.

edogaldo
Posts: 432
Joined: Fri Jun 03, 2016 8:19 am

Re: Built-in DFU programming via Arduino possible?

Post by edogaldo » Wed Sep 05, 2018 10:09 am

Some confusion..
Nucleo boards use ST-link 2.1 whose firmware is proprietary and not accessible (you can find on the web some people claiming having cracked it but with pretty complex approaches).
What you can try is to test if the existing DFU upload tools work with MCUs that have embedded DFU support.

ag123
Posts: 1322
Joined: Thu Jul 21, 2016 4:24 pm

Re: Built-in DFU programming via Arduino possible?

Post by ag123 » Sat Sep 15, 2018 6:49 pm

if you leave the arduino IDE aside.

the main tool is dfu-util
http://dfu-util.sourceforge.net/
some of the very early releases may not directly support DFUse (i.e. STM's DFU), but version 0.8 and 0.9 (current release) supports it.
note that i'm using linux and hence all these is from the linux view point. for windows you'd need to set the libusb driver stack up correctly for things to work. i've been using dfu-util to install sketches on both stm32duino core (arduino ide default) as well as those boards which support DFUse firmware uploads successfully for a long time.

stm32f103 do not have built in DFU, the DFU is provided in the stm32duino bootloader (sketch install at 0x8003000) or the maple bootloader (sketch install at 0x8005000), maple bootloader may be considered 'legacy' but then some board makers still ship the old maple boot loader. Hence, one should check that using the dfu-util -l command

varous other (larger) stm32 socs has DFU bootloader builtin, e.g. stm32f407ve, ze, vg, zg series
dfu-util can be used to upload sketches on stm32f407ve e.g. the stm32f4-black board based on the STM's DFUse internal boot loader
viewtopic.php?f=39&t=1976&start=10#p26203
^^^ review this link
sketch install to the default flash memory location 0x8000000, start of flash
and the other thing is you'd need set the boot pins to make that work,
there are some caveats like it may be necessary to disconnect/connect the usb cable to get the usb to reset (or to use a utility to cause a usb bus reset) (see the link above)

i've been using dfu-util to installl sketches on both stm32f103 (i.e. stm32duino bootloader) this is default and supported within the arduino ide, e.g. boards like maple mini or blue pill),
as well as stm32f407ve, but I'm running that on the command line. i'd think it is mainly a matter of configuring platform.txt, boards.txt etc if one wants to integrate the arduino ide to use dfu-util for the DFUse (i.e. STM's DFU upload).
command line works well for me and i didn't bother with the integration.

one the key thing above is the different install address of the sketch, that is done by seting up the "ld scripts" (also called the scatter files)
so that during compilation, the binary would be built for the correct install address. you'd find the 'ld scripts' in various sub directories e.g. the board sources in the core

Post Reply