Author Topic: USB Keyboard project DFU question  (Read 1018 times)

0 Members and 1 Guest are viewing this topic.

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
USB Keyboard project DFU question
« on: June 23, 2024, 02:20:59 am »
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.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #1 on: June 23, 2024, 03:18:45 am »
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.
Alex
 
The following users thanked this post: Jonathon_Doran

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #2 on: June 23, 2024, 04:12:35 am »
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.
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #3 on: August 17, 2024, 05:07:02 pm »
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.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #4 on: August 17, 2024, 05:56:18 pm »
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.
« Last Edit: August 17, 2024, 05:59:42 pm by ataradov »
Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #5 on: August 17, 2024, 06:28:18 pm »
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).
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #6 on: August 17, 2024, 09:31:43 pm »
Do you think that the pullup resistor is keeping the bootloader from showing up in Windows?
Extra pull-up may prevent USB from working, yes. If BOOT0 is high,. then I would cretainly remove the resistor.

This is so stressful to think that I may have botched this project.
This is a normal part of the design process, you are stressing over it like it is $1000 PCB.

Do I need an inspection microscope, or just one of those round magnifiers with a ring light?
I 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.
Alex
 
The following users thanked this post: Jonathon_Doran

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #7 on: August 17, 2024, 09:53:32 pm »
Extra pull-up may prevent USB from working, yes. If BOOT0 is high,. then I would certainly remove the resistor.


Will do, thanks.

This is a normal part of the design process, you are stressing over it like it is $1000 PCB.

Sorry 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.

I 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.

I 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.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #8 on: August 17, 2024, 09:59:50 pm »
The resistor in question is 0402.
This 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.
Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #9 on: August 17, 2024, 10:28:40 pm »
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.
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #10 on: August 19, 2024, 09:01:02 pm »
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.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #11 on: August 19, 2024, 09:04:46 pm »
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.
« Last Edit: August 19, 2024, 09:06:24 pm by ataradov »
Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #12 on: August 19, 2024, 09:34:37 pm »
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.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #13 on: August 19, 2024, 10:01:30 pm »
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.

Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #14 on: August 19, 2024, 11:06:00 pm »
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) = 0

Boot1?  The symbol doesn't have a Boot1...
The datasheet tells me:     G5 28 37 PB2 I/O FT PB2/BOOT1

For this part, that means that pin 28 can be overloaded with BOOT1.

Oh.  What is pin 28?

The schematic tells me:   X

What 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.   |O

But I'm doing better.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #15 on: August 20, 2024, 12:16:03 am »
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.
Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #16 on: August 20, 2024, 03:04:48 am »
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.    :o
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11753
  • Country: us
    • Personal site
Re: USB Keyboard project DFU question
« Reply #17 on: August 20, 2024, 03:19:39 am »
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.
Alex
 

Offline Jonathon_DoranTopic starter

  • Regular Contributor
  • *
  • Posts: 93
  • Country: us
Re: USB Keyboard project DFU question
« Reply #18 on: August 20, 2024, 10:37:18 am »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf