USB Keyboard project DFU question - Page 1
Forum section: electronics / projects

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: June 23, 2024, 02:20:59 am
content: I have dusted off my USB keyboard project which I started a couple of years ago, but never had time to complete. I am hoping to get this done over the summer.I have switched microcontrollers to the STM32F105RBT6. One of my goals is to allow programming the device using DFU.I have added a switch for BOOT0. I am using an external 8MHz oscillator which is being increased to 48MHz by a PLL in the F105.I am confused right now because STM32CubeMX will allow me to configure USB as either a HID device, or a DFU device. I know that I can't do both at the same time. Will the chip automatically switch to DFU mode base on BOOT0's setting? Is there a way to configure both modes somehow?I'm not sure what to do at this point, and would appreciate some clarity from someone. Thanks.

author: ataradov
author_rank: Super Contributor
timestamp: June 23, 2024, 03:18:45 am
content: BOOT0 selects the ROM bootloader code, you don't need to do anything for this in the CubeMX, you don't even need a valid firmware of any sort.Your application only needs to be a HID device.Note that full DFU has application side too. If supported, the only command that is implemented is to switch to the boot mode, which reboots the device into the full DFU. But if you are using BOOT0 pin for that, you don't need this support.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: June 23, 2024, 04:12:35 am
content: Thanks so much, that is a big relief.This is all new to me, so I'm stressing out trying to get the board correct. I can mess with firmware/setup later.I have a connector for a J-Link on the board (well a 10-pin Cortex connector) as sort of a backup plan.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 17, 2024, 05:07:02 pm
content: With boards in hand, I am a bit concerned.(JLCPCB did a great job of assembly by the way, and I had 0 trouble with the USB connector)I see an unknown device. STM32CubeProgrammer does not see a DFU. Now I put a pullup on D+ per AN4879 (Section 3.1). I'm wondering if this is causing a problem. I ask this because later I read AN2606 and see "No external pull-up resistor is required". GRR. Make up your mind! I could probably cut the trace to that resistor. It is tiny, and I can barely see it, but I could probably do it. I'm looking for guidance before messing up a board.

author: ataradov
author_rank: Super Contributor
timestamp: August 17, 2024, 05:56:18 pm
content: Pull-up resistor alone would make host think there is a USB device. But you need to assert BOOT0 pin high in order to boot into the bootloader mode.Even if there is an internal resistor, the external one may not matter. It depends on the host. So, start with the BOOT0 pin and see if it enumerates.This device has integrated resistors, so external one is not necessary. You can just remove the resistor, no need to cut traces.And AN4879 mentions that this device has embedded pull-up resistor on the USB D+ line.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 17, 2024, 06:28:18 pm
content: The Boot0 is pulled high by default. I have a switch that will ground the pin for use after the device is flashed.Do you think that the pullup resistor is keeping the bootloader from showing up in Windows? Or do I have another problem. I haven't even soldered on that switch yet, as there is a pullup connected by default (to guard against undefined states during the switch closing). I thought that this would allow me to flash the board before soldering parts. This is so stressful to think that I may have botched this project.Ah, remove the resistor. Yes that shouldn't be too hard even with a small part. I really need some magnification though, but never settled on a solution. I would think that at least ONE of our labs would have an inspection microscope, but no. I keep going around and around on this. Do I need an inspection microscope, or just one of those round magnifiers with a ring light? The latter would allow to hold a board in my vice. I know, this is a separate issue...I suppose it is possible that the MCU did not start up. I think I'll scope out the OSC output. I have a SWD connector wired up, but was hoping to avoid using it (one more thing to figure out).

author: ataradov
author_rank: Super Contributor
timestamp: August 17, 2024, 09:31:43 pm
content: Quote from: Jonathon_Doran on August 17, 2024, 06:28:18 pmExtra pull-up may prevent USB from working, yes. If BOOT0 is high,. then I would cretainly remove the resistor.Quote from: Jonathon_Doran on August 17, 2024, 06:28:18 pmThis is a normal part of the design process, you are stressing over it like it is $1000 PCB.Quote from: Jonathon_Doran on August 17, 2024, 06:28:18 pmI don't know what size of resistors you are using and how good your eyesight is. I personally would not have issues dealing with them with a naked eye down to 0603 size.You don't need any special equipment, just side cutters or something to mechanically remove it if you don't have soldering equipment. And if you do, just blob a solder on the iron tip and contact that resistor, it will float into the blob. No precision soldering necessary.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 17, 2024, 09:53:32 pm
content: Quote from: ataradov on August 17, 2024, 09:31:43 pmWill do, thanks.Quote from: ataradov on August 17, 2024, 09:31:43 pmSorry about that. I have invested a lot of time (and a lot of that is for this particular learning process). Your earlier advice to just build the board was helpful, and I can see that it was the best thing for me to do.I'm mainly stressing about things I don't know how to handle.But successes are worth a lot. That USB connector that you recommended looks like it is working like a champ. I now have a footprint/symbol/part number, and JLCPCB didn't blink at my edited footprint.Once I have some experience with the STM32 parts, that will open up a lot of doors.Quote from: Jonathon_Doran on August 17, 2024, 06:28:18 pmI have a soldering station and good tips. The resistor in question is 0402. But there is good clearance around it. I still ordered one of those $50 ring lights to hopefully make my life easier. But I hadn't through of putting solder/flux on the tip like that. I can see that part floating off.

author: ataradov
author_rank: Super Contributor
timestamp: August 17, 2024, 09:59:50 pm
content: Quote from: Jonathon_Doran on August 17, 2024, 09:53:32 pmThis just makes your life harder for no reason. Stick to 0603 or even 0805 if you have board space. So much easier to work with while debugging.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 17, 2024, 10:28:40 pm
content: Yeah, I see how that is. Really no point in my case.Will add this to the list of things for the next rev of the board.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 19, 2024, 09:01:02 pm
content: I finally had some time to look into this. Pulling the resistor caused the board to no longer enumerate under Windows. Nothing happens when the board is plugged in. Fortunately I had two boards assembled, so I have one with the resistor still there.I'm wondering if the MCU is even starting up. I tried to look at the OSC output today, and just saw noise. I was hampered because I could not get a good ground reference. I poured a large ground plane on a corner of the board, but forgot to take off the solder mask.I have a couple of grounds accessible. There is a large pad for a SMD switch that I have not installed. I'm holding off because I am wondering if I should have a resistor between BOOT0 and ground (via the switch). Right now, BOOT0 is pulled up to 3V3, and the switch (when installed) will allow me to ground it. But I have it wired directly to ground. I'm second guessing this, but I have seen designs that run both 3V3 and GND directly into that pin. It doesn't mean that it is a good idea. I thought I would think about this before installing the switch. Also, until the part is programmed there is no point in running the code.I still have a SWD connector I can test, but it might be a couple of days before I have time to try.I'm collecting things to change for the next iteration. I wish there was a way that I could verify the MCU. Right now, power and ground is all that I'm sure of. Oh, and that with D+ pulled up Windows will see SOMETHING. But the STMCubeProgrammer didn't see the board.

author: ataradov
author_rank: Super Contributor
timestamp: August 19, 2024, 09:04:46 pm
content: If it does not enumerate without a resistor, then MCU is not running or it is not running a USB capable firmware. If there is a resistor, then the host would behave like you described even if there is no MCU at all. Forget about the board with the resistor. This MCU does not need it and it only adds to the confusion.Solder mask can be scratched off.Wait, your BOOT0 is grounded? Why do you expect DFU to run then? It only runs when BOOT0 is high. Or what do you mean by "But I have it wired directly to ground"? If you mean that switch pulls it directly to the ground, then it is fine. And it is not the source of the problem, since presumably you are experimenting with it being pulled up at the moment.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 19, 2024, 09:34:37 pm
content: From my previous post:Right now, BOOT0 is pulled up to 3V3, and the switch (when installed) will allow me to ground it.So, yes. The pin is pulled up right now. I wasn't sure if I needed a pull-down resistor, of if it was safe to connect directly to ground.The part (STM32F105RBT6) should have USB firmware in ROM which should be ran if BOOT0 is high. This is the default with no switch soldered in. The switch just allows me to ground the pin later.I am not clear on crystal operation with this chip, and my previous observations may not mean anything. I believe there is a default internal OSC, and I can configure the chip to use the external OSC once I program it. This seems logical. My setup of the clock generators is part of the programming, so the chip needs to be able to start up on its own. And I am thinking that the noise that I saw on the OSC out may be due to no OSC in going to the crystal. I don't have a testpoint on OSC in. But if I haven't programmed the chip, maybe that pin is not being driven yet.So my next priority is to connect my JLink-EDU to that SWD connector I put in (as a fail safe). I've used Jlink under Linux, but not Windows, so I might move this board over to a Linux box.

author: ataradov
author_rank: Super Contributor
timestamp: August 19, 2024, 10:01:30 pm
content: In this device a stable oscillator is necessary for USB operation. USB bootloader would start it on its own. Do you have USB_VBUS connected? It is necessary for USB bootloader to start.What sort of noise have you seen and how specifically you have observed it? Oscillator is analog and you should not expect to see logic levels there, it is possible that you misinterpreted the running oscillator as noise. Attaching any screenshots from the scope would help here.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 19, 2024, 11:06:00 pm
content: Thanks for hanging in here with me, I think I am making progress.VBUS is connected and is stable 3V3. I have a testpoint.I will share the screenshots if you really want them in a minute, but I need to confess that I'm an idiot.The bootloader AN2606 tells me this: The STM32F105xx/107xx bootloader is activated by applying Pattern 1 (described in Table 2).Table 2 tells me: Boot0(pin) = 1 and Boot1(pin) = 0Boot1? The symbol doesn't have a Boot1...The datasheet tells me: G5 28 37 PB2 I/O FT PB2/BOOT1For this part, that means that pin 28 can be overloaded with BOOT1.Oh. What is pin 28?The schematic tells me: XWhat I have done for the last couple of hours has been to set aside my normal duties and hook up the JLink. I can connect to the board via SWD! I can read registers, halt the CPU, reset it, read memory... And the PC is in SRAM. Why is it in SRAM? That much is probably obvious from the above.I cannot read the bootloader memory or the config data. I assume that when the device is not booting from the bootloader that this region of memory is not mapped.Fair enough?Time for another board spin?Yes. I'm not entirely sure what QOL changes I could put on here to help debug. That SWD connector was worth its weight in gold.And yes, I am an idiot.But I'm doing better.

author: ataradov
author_rank: Super Contributor
timestamp: August 20, 2024, 12:16:03 am
content: Why spin the board? Just bodge the pin to the ground. This is the whole point of getting the first board fast - use is as a very project specific prototyping board.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 20, 2024, 03:04:48 am
content: I'll think about bodging, but my ability to solder onto that fine a pitch is questionable. It would be character building, but without a microscope I'm not sure that I could do it.I've known folks who could drag solder those parts, but putting one pin on.

author: ataradov
author_rank: Super Contributor
timestamp: August 20, 2024, 03:19:39 am
content: Well, if you don't have proper equipment and you don't plan on doing electronics in the future, then it may be easier to reorder the board.

author: Jonathon_Doran
author_rank: Regular Contributor
timestamp: August 20, 2024, 10:37:18 am
content: I haven’t given up on the idea, I have to look at the schematic again and don’t have it here. The thought occurred to me that adjacent pins on that fine pitch part may not be used. A solder bridge that grounds one or two extra pins will be OK.Today is not a good day to learn how to solder fine pitch.