How to program a blank STM32 micro using DFU bootloader mode via the USB port.
Also Zadig and WinUSB device mapping on Windows 10.
Part 3 of the Padauk opens source programmer series.
Forum: https://www.eevblog.com/forum/blog/eevblog-1306-(3-of-5)-3-cent-padauk-micro-stm32-dfu-bootloader-programming/
#STM32 #DFU #Padauk
EEVblog Main Web Site: http://www.eevblog.com
The 2nd EEVblog Channel: http://www.youtube.com/EEVblog2
Support the EEVblog through Patreon!
http://www.patreon.com/eevblog
AliExpress Affiliate: http://s.click.aliexpress.com/e/c2LRpe8g
Buy anything through that link and Dave gets a commission at no cost to you.
Donate With Bitcoin & Other Crypto Currencies!
https://www.eevblog.com/crypto-currency/
T-Shirts: http://teespring.com/stores/eevblog

Hi, Welcome to part three in the Paducah 3 cent Microcontroller Programming series where we build up open-source hardware and software to program these 3 cent microcontrollers. Now in part two, we looked at actually assembling this PCB but you plug it in. it doesn't do anything. It's dumb because the Atmel processor on here is completely blank.

so we have to program the firmware into this thing. But without using an Atmel programmer, we're going to use what's called DFU or device firmware upgrade via the USB And it sounds easy, but there's a few traps. you young players. Let's go.

Okay, we've got our border sampled and yes, I do have a little S O8 SMD adapter for that. I actually did have one. You can see a little So8 chip in there at the moment. just happened to have one who's lying around and forgot to order one, but I did actually have one so no workers I could have just budgeted a SMD adapter board.

Anyway, Anyway, doesn't matter what we want to do now is actually program the Stm32 micro on this thing which is an STM 32 F 6 for those playing along at home. And if you actually plug this in, it's not going to do anything because it's not programmed. There's no loop in Windows to tell you that this thing's actually plugged in. because it's not a well, it's not doing anything.

So the first thing we want to do is actually measure the voltage regulator on here because we do have a 3.3 volt voltage regulator. so we just want to measure across one of these bypass caps here just you know surrounding the micro just to make sure we get 3.3 volts. So I can't easily put this on screen so you have to trust me. I'm probing it.

Yeah - 3.3 volts cuz they had my pros backwards. But yeah, so we've got 3.3 volts is 3.3 volts going to the micro. Now we can't actually measure this other stuff down here. like 6.6 and 13 volts.

Programming: These are the programming. These are the VDD and the programming voltages down here that go off to the micro because these need to be enabled and things like that now. Programmer: I Don't know we could try, but it doesn't matter, we can do that later. What we care about is getting our micro working 3.3 volts on there and that a USB is connected here and where and it's going through and then it goes through and it actually programs.

Now we're not actually going to use this header here to program we actually could using the STM tools. But the good thing about the Stm32 processes and a lot of other processes that they have a built-in serial bootloader in them. Which means you can just connect straight up to the Usb and talk to the-- and program that using programming software. it's called our DFU and DFU mode stands for device Firmware upgrade and it supports like several different processes support the same thing, so the 1d if you program software can support might potentially support multiple different programmers.

Stm32 being one of them because you saw I just plugged it in and Windows didn't detect it at all because there's nothing in there. what you have to do and on here. I'll take off that Yes! So A to Dr. is a little button on here which you have to press down, hold down and then when you plug it in hopefully fingers crossed.
we'll get the windows do a little bit. There it is. hopefully you heard that if we go over to Device manager and there it is other devices. Stm32 Bootloader winner winner chicken dinner.

That means what? Whoa, it's gone. aha and that looks like it's Windows that's gone over to here rather than other devices that's now under Windows. Probably just installed the driver II thing for it and now it's a universal serial bus controller and it's the STM device in DFU mode. So Windows automatically knows about this.

I don't know about Linux and Mac or whatever you're you're on your own, but STM device. So that means that our micro is soldered correctly or 3.3 volt voltage regulator here u2 is all working and our resistant. You know there's no shorts on the data lines on USB connectors soldered correctly. There's a lot of little, yeah, tiny little joints in there.

You can get a little, you know, hairline short or something like that between one of the data lines and it just wouldn't do anything and I was hoping that it wouldn't work. so I'd have to do some troubleshooting but ya can't always win them anyway. I Hope yours doesn't work if you're trying to build this up or your next project doesn't work so you have to troubleshoot it. Do you learn a lot when things fail and you have to troubleshoot them? This work first.

Go. Okay, you've learned how to solder, but you know I'd have a troubleshoot anyway. so this Micro is now talking. so now we can download the DFU Programmer software.

So now if we go to the Github, Z' software sources can be found easy p DK Programmer Software and if we're going to firmware here, install d Fu Util on your computer. there's Linux. There's is there. Ma Ki, Air, Mac OS and Windows unplug.

USB A tells you are to keep holding the button and then you execute this dear if you utility this very complicated thing anyway, that's that's the binary file which we can download from up here. easy PB K Programmer: That's our bite. You know they've already compiled that with the Stm32 compiler and then you put it into a certain memory address and things like that so you know it goes into flash internal flash memory and that's the address it's going to and all that sort of jazz. Anyway, they've already figured that out for us.

that's all the complicated stuff. Somebody's already done that, so we don't need to know. Um, and we should get that's this output in a command box for this da-fu utility. So let go install that.

So here's the DFU utility are supported devices: Open Moko! Ah, there you go. Stm32 are built in bootloader so there you go. It supports some ODS own demo, pumpers, supports some other devices. Anyway, let's install that.
So thank you Stefan Schmidt and toward of Olden I Don't want to build it and browse it via the web interface or clone it I Don't want to clone the Get Releases folder Tada Win 64 yet. We want version I guess the latest version 0.9 It'd be nice if they just put the older ones in like old subdirectory or something, but it's pretty obvious. Ego I mean 64 zip I guess that's it. There we go.

These are the files we've got in here so we'll have to. you know DOS command line over 2d a few you tilled so there you go for those. plan look at home. there's all the instruction looks very comprehensive.

excellent You Hermann wrote the manual good on you. Okay, so we want to copy that and I've downloaded our easy PDK prog and I've put it in my C Drive Here we go over to our command CD d Fu we're in like Flynn There we go so we should be able to run that Now here we go. What it might Felicia flash its LEDs afterwards. but let's run it.

Hopefully that's all we need. Let's go. Ah, can I open D A few did I not know D a few capable you with speed of a USB a device available. Ah right.

Is there something wrong with this address? Maybe this address isn't correct I don't know I haven't used this before. Yeah, it just it cannot find the device. So do this again. When in doubt, turn it off and on again.

Aha is it something to do with this like port 9 Hub oh one. Do I have to change that? Maybe I don't know. So yet there it is. There's the O 4, 8, 3 and PID DF 11.

Yeah, it's got the other stuff in front of it vid underscore and it's got the end. PID But I assume that that's what you do anyway. Um, that seems right. let's try it one more time.

Oh Everyone's probably screaming at me. but yeah, I'm sorry. this is like the first time I've used this. So yeah.

I don't know how this addressing actually works, but the device is there. it's in Windows you saw it. It had the same numbers at least. So I seen the errors in here.

It says the device so that even though the addresses correct, it was not migrated due to partial or ambiguous match. So on. Windows you have to register the device with the win. USB Drive Out Live Us Beyke Please let us see a wiki for more details.

Ok, if your target device is not H you must install a dry before you can communicate with it using Lib. USB Currently this means install one on Microsoft's Win USB Lib Drivers: Ok, no worries. The most common version of the dig: I think I've done this I think I've done this for something before. Yeah, I've certainly done this before for a couple of things.

I think it was for one of those USB RF dongle things. I'm gonna make this easy for you are they? Maybe it would have been easier to actually go in and program it via the header Perhaps I'm using. but then you've got to have a programmer. Where is this? You don't actually need an STM programmer.
They're very cheap. You can buy them for like five or ten bucks on eBay It's just an extra thing you've got to have. This is how you do it without any programming hardware at all, which is cool. Alright so I've downloaded Zadig.

It's been updated very recently which is great Driver: I Don't know if I need that do I? There's nothing there in store. Wins See Ok I Guess in Win USB the latest version I Guess no, it's not gonna let me know. Note: there it goes. gotta wait impatient day So you know it's these things that make it like really tricky to do that.

Like if you do this all the time, you probably already have this install that would have just worked and I you know like yeah, do that all the time. No worries, you know two-second job a fact like I Thought that it would be a very quick job to do this, but um, you know the drive was successfully installed. Thank you. Do I have to reboot actually over to our device manager? Let's have a look at the properties.

Device is working properly. Events was not migrated Judah Partial or ambiguous Match same thing but I'll give her a ball anyway. Nah, still can't find it. So ok going back to here it's going.

Currently supports Win USB and Hid drivers for generic USD devices as well as the Lib USB the Win32 and Liberate Us BK drivers. So we've installed Win USB and it doesn't work so maybe one of these other ones might work. You know I know my eyes are starting to roll in my head which frozen you said API for Windows guy, you know it. Like makes sense to people who know, right? But if you just want to program your little widget II thing.

Whoa. So I reached out to the Twitterverse with this error message like is this might not migrated due to partial or ambiguous match Does that have something to do with it? Or is it something else And you know you deep in the window when not even barnacle ease can help you out. That's a new one for me. Davey and I Worked at Microsoft for fifteen years as a developer on Windows Murphy gets me every time.

So yep, this could take a while. So let's go back to the dig here. and although there's no devices showing up here, if you go up here and you go list all devices tada it pops up. Why it doesn't like just why would you not do that I don't know.

Anyway, so let's try reinstalling the driver Stm32 boot loader. There it is. So let's change that driver the esti tub and that is actually a thing because if you go over to here like this and you go back into here you go into here. St.

Tub 30 There it is. device started so this device not migrated. That was a red herring because that was like the first thing and looks like it went through a sequence and it's installed this St Tub 30, whatever that is I Got no idea. So it's the services St Tub 30 So we want to replace that service with Win 30 with the Wind USB driver and there it is.
Oh 480 3d F11 Bingo Replace driver Here it goes here, It goes here, It goes here, it goes Tada and OH Okay, you know our devices. There you go. It went from a controller to a device that's looking promising. Installation can take some time.

Okay I think we might have a winner winner chicken dinner here. Done! We actually go back over to here. If we actually list devices Tada found DFU We got it. We're gonna do it.

It's gonna work now because we've listed it. it's a found device. Go! Yes, we did it. We did it.

File downloaded successfully. Ahh fantastic. So we now let's disconnect it. Ok, so yeah, it's all good.

It's programmed. let's see if it does the dip when we plug it in. It does don't have to hold down the button so it's programmed now. everything's working.

Sweet. Fantastic. Well that was a bit of a learning experience. was it in here? I've actually done this before I I should have remembered this I should have remembered that I've overwritten drivers exactly like this with unit when USB and it's a little bit complicated.

It's easy once you know see that would have been if these instructions were on that page. you would have just done it and it would have just worked. You know? So yeah, yeah, there you go Now the instructions are in this video. For some reason my video capture software is come a GAD sir and it's giving this weird black and white effect with a stripy color by I don't know I Kind of like it so I'll stick with it anyway.

We plugged it in now and as you can see it now works without having to press the button and go in. tune into the bootloader mode and Bingo! Now we get STMicroelectronics Virtual Comport. So it's just got a regular serial comport seven and that's what software is going to use to communicate with this and then program the chip.

Avatar photo

By YTB

24 thoughts on “Eevblog #1306 3 of 5 : how to program an stm32 using dfu bootloader”
  1. Avataaar/Circle Created with python_avatars christopher békési says:

    You could have just used the DFU utility provided by ST directly instead of fiddling with the WinUSB driver. The reason for the replaced driver is because the ST driver interface is not directly supported by the DFU tool you used. ST link Utility or STM32CubeProgrammer would be a much better option and you would get access to all the option bytes as well

  2. Avataaar/Circle Created with python_avatars Alive and well in Israel says:

    It was enjoyable to watch you figure out the Zadig thing. I've had to mess with that a few times, and it's always great when it finally works.

  3. Avataaar/Circle Created with python_avatars limpqizbuit says:

    I love how even with how advanced technology has gotten. We still have gems like you teaching the ground floor basics. Looking forward to building some of my first pcbs in the near future!

  4. Avataaar/Circle Created with python_avatars Graham Daniel says:

    Fantastic! I had been considering setting myself up to program and use some Padauk micros, saw your first vid a couple of nights ago. had a little look on your vids list but missed the follow ups. Last night was a 12 hour day at work and a midnight 2hour callout this morning. Had this interesting blast from the past, looking at STM32 and DFU on this vid which reminded me of the STM32F103 motherboard I designed up just over a decade ago and here was this vid, tackling 2 subjects in one! Thanks! ps Zadig was a BS circus when I used it too.

  5. Avataaar/Circle Created with python_avatars MOHAMED ELSISY says:

    Thank you very much, i did all steps even the dfu with the address of 0x0800 and all steps have been done, but even now when i am plugin the board, it can not give the recognized sound !. I have to use boot0 and nrst mode, i am using stm31f411 black bill board.

  6. Avataaar/Circle Created with python_avatars 木子 says:

    I got same problem with stm32f401 in platformio, when I replace driver use zadig, it can upload use dfu, but it has no virtual com,why?

  7. Avataaar/Circle Created with python_avatars Hola! osman özdemir says:

    Can I upload code to the same processor over and over again this way? (no using TTL again)

  8. Avataaar/Circle Created with python_avatars joakim says:

    This is great, gave it a thumbs up. Question:

    "–dfuse-adress" it says not applicable for .dfu downloads. Isn't that exactly the type of file the firmware is?

    I couldn't get it to work, i actually skipped that command and just went straight to downloading the file onto the device. It completed the download, i'm not sure if it works as intended. Thoughts?

    Any answers appreciated, thanks.

  9. Avataaar/Circle Created with python_avatars DAVID GREGORY KERR says:

    Windows requires a reboot unlike Linux MInt but I reboot anyway.

  10. Avataaar/Circle Created with python_avatars Paul Stoleriu says:

    I've also used zadig to overwrite usb drivers for interfacing with smartphone bootloader. I think the windows driver stack is FUBAR and we should run the hell away from microsoft products

  11. Avataaar/Circle Created with python_avatars Rafal Z says:

    So is that all mean that on the end you have programmer integrated on your flash ? And DFU from system memory is not in use anymore as not going anymore to boot mode? Is the driver going to flash, how much kB?

  12. Avataaar/Circle Created with python_avatars Gacheru Mburu says:

    👍

  13. Avataaar/Circle Created with python_avatars christopher békési says:

    Before watching any further; I've worked with STM32s a ton, and the Cortex M3 does not come with a built in DFU through USB. You'd have to tap into the UART1 headers and flash throgh a serial converter.

  14. Avataaar/Circle Created with python_avatars Steve Tobias says:

    I have a couple of STM32 development boards that I have come a gutza on. I might try this and see if I can get them working.
    Thanks Dave!

  15. Avataaar/Circle Created with python_avatars Erik Schiegg says:

    May I propose the Atom Lite M5 Stack as a future topic? Are they any good? ESP32 inside.
    PS: It's ok, Andreas Spiess made a video.

  16. Avataaar/Circle Created with python_avatars Internaut says:

    thanks to this video I have a nice and healthy easy pdk programmer excellent!!!!.. but my chips did not arrived yet 🙁 feel great!

  17. Avataaar/Circle Created with python_avatars PyroRob69 says:

    Haha, a Windows nightmare, as usual.

  18. Avataaar/Circle Created with python_avatars Amaury Jacquot says:

    you got problems just because you use windows. for us playing along at home with linux, no problems 😉

  19. Avataaar/Circle Created with python_avatars Qs Tech Service says:

    FlashCat programmer
    works good for programming 😳👍 easy breezy beautiful cover girl 👧

  20. Avataaar/Circle Created with python_avatars Chris says:

    I've never tried it on Windows with an SMT32, but I remember Zadig from back when the RTLSDR fever started. Actually DFU looks more straightforward on linux if you have the precompiled (or can compile) the same dfu-util in the video. You just have to look up the correct USB VID/PID with lsusb. No driver replacement needed, the kernel handles this out-of-the-box. At least for an STM32. I came across some F103 boards where the USB dataline pullups were missing. If you don't have a debug probe for STM cortex-m devices there's an alternative UART way too using STM32-FLASHER.

  21. Avataaar/Circle Created with python_avatars Ronnie Pirtle Jr says:

    The aliens are shooting a laser beam on your screen Dave. You figured out their technology!

  22. Avataaar/Circle Created with python_avatars Rémi Busseuil says:

    What about the official stm32 DFU firmware?

  23. Avataaar/Circle Created with python_avatars Klint Krossa says:

    ask to list this video on the github wiki

  24. Avataaar/Circle Created with python_avatars Steven Knudsen says:

    DFU gets it programmed, but does nothing to help with debugging. Just go straight to SWD since you will eventually anyway.

Leave a Reply

Your email address will not be published. Required fields are marked *