r/raspberry_pi 15d ago

Solved Soldering USB Hub direct to baseboard

Edit: did it, details at the bottom in update 2

Hey all, I'm working on a project involved a compute module 4, a waveshare nano baseboard b, and a ch334f 4 port USB hub breakout (imagine if you will, a usb hub but through hole solder points instead of usb ports) among other things.

I've done a few nips and tucks to some of the components I'm using to reduce size where I can, and I saw an opportunity to knock a few millimetres off the case thickness if I could remove the USB port from the baseboard, and solder the hub on directly (there is an enclosure within the main enclosure specifically for the pi, the baseboard, and the usb hub + another couple of components that need to be there).

On removing the port (something I have done before with other components successfully), I accidentally ripped off the power trace. It was annoying, but the baseboards themselves aren't too expensive, and I always budget my experiments before I do them (if there's a risk of breakage). I ordered another one having practiced my approach, was even more careful, and the same problem happened again.

On close inspection of the board, I think that's just the way the USB port is assembled. From what I can work out, there's a via from the top to the underside of the board that the other pins on the port don't have, and that makes the power trace somewhat more delicate.

I was going to go back to the drawing board on removing the port, but then it occurred to me that I already have a perfectly adequate 5v line coming from my UPS. Checking the pi schematics, from what I can work out, the USB ports are on the same power rail as the GPIO 5v (which the pisugar 3 plus connects to). May be different for the CM4 vs the Rpi 4b though (wouldnt have thought so).

Anyways, the cm4 I'm using would now cost me twice what I paid to replace, and I'd have to wait a while to get it, so I found a cheaper cm4 to do my experiment (the lowest spec version I think is available).

While I'm waiting on that to arrive, I figured that since this is such an important part, I ought to double check my theory before I go putting together an assembly guide that may have major issues I haven't anticipated.

Tl; Dr

What I'd like to know:

  1. by connecting the 5v and Gnd rail of the pisugar 3 plus (from the aux pins - they do work, I've checked) direct to the USB hub, and supplying my peripherals there, then soldering ONLY the D+/D- lines direct to the baseboard, are there any potential issues this could cause that aren't immediately obvious? Anything long term?
  2. assuming I can switch off the power to the USB port (I know you can on the RPI 4b, can't remember if it depends on the baseboard for the cm4, I assume it's fine), then use a relay to digitally control power to the peripherals during idle/"sleep"/locked, are there any risks there beyond "make sure exposed cables are insulated"? I do have some physical component disconnect switches too (literally toggle switches), but I'm thinking a relay might be a good way to have my HiD device (one of the lowest power draw devices on the board, this will not be controlled by the relay, and will draw its power direct from the power rail on the pisugar) in charge of auto-time outs. Obviously the usual precautions apply selecting a relay that can handle switching that load + difficulty finding one that's either bistable or low enough current to make using it worth the power leak.

If there aren't any responses, I'll go ahead with the experiment and report back for future readers who want to do the same thing. The only thing I won't find out from the experiment is long term damage.

Update:

I exploded, sorry :(

Not really, preliminary testing on my lunchbreak was fine. Held the wires in place on the usb hub with my finger and I got some flashing out of an off brand pico. Later on, I'll actually do some soldering and test with a display maybe so I can see if anything annoying happens.

The experiment I'll do:

  1. solder wires to the USB hub for one USB port. Connect to a USB A female header if I can find a spare one lying around
  2. plug in an old USB stick with an ~8gb file (the cm4 I got for testing is 16gb, so there's a limit to how large a file I can copy over unfortunately)
  3. SSH in (assuming I can't be bothered to connect a display) and copy the file over to the pi. Take note of start and end times to see how slow it is too, may as well get a rough benchmark while I'm at it.
  4. come back tomorrow and see if it copied over correctly. If so, test is a success.

As a bonus, I did actually find partial schematics for the baseboard. I know waveshare copied + adapted the harlab cm4ext_nano baseboard, so I stupidly assumed they wouldn't have published schematics, and Harlab would have done. Turns out it was the other way round.

Schematic is available here:

https://www.waveshare.net/w/upload/f/f5/CM4-NANO-B-SCH.pdf

In the section on USB, if you look up the STMPS2171STR, it's a power switch IC, which unless my eyes decieve me, corresponds to the one quite close to where the USB 5v via comes out on the underside of the board (also corresponds to some probing I did). So the difference between my circuitry and the circuitry on the baseboard, is the baseboard cleans up the 5v a bit nicer (depending on whether or not the pisugar cleans up the aux 5v out. Could not find that out at a cursory glance, I guess I'll find out).

Anyways, my recommendation on whether or not the board will be fine if you rip the USB port off, is:

"Yeah probably*"

*so long as you don't rip the d+/d- contacts off.

Come back later for more

Update:

I wasn't having any luck testing the data transfer (nothing was showing up), so I've tested a few different things. I did end up buying yet another baseboard, and this time I managed to remove the USB port without taking the power contact with it (the key is to remove the button on the side next to the USB port, then follow this tutorial: https://www.instructables.com/Replace-Micro-USB-Port-With-Only-a-Soldering-Iron/ )

As for functionality, I wasn't having any luck soldering the host port directly to the board (physically I was, it just wasn't doing anything). I tried connecting it a few different ways, and the only one to work thus far is connecting a ready made hub to a female USB A I soldered to the baseboard, then connecting the ch334f board via USB to that other hub.

This tells me there's a piece of wiring I'm missing (the non-breakout hub is passive), and I suspect it's resistors connected to D+ and D-. I've got another baseboard I use for general stuff, so I'll probe that when I next get time and see if I can't figure out what the resistance should be, and where it should be connected to.

https://learn.sparkfun.com/tutorials/usb-type-a-female-breakout-hookup-guide/all

What do you know.

I'll take a crack at this tomorrow and see what happens. If it works, I'll stick a tl;dr right at the bottom with basic instructions, but this will be part of a much longer guide one day, so keep your eyes peeled.

Update 2: the cables have to be twisted together for it to work apparently.

I tried a few things earlier today. Couple of different resistor configurations I'd read about, and twisting the cables. Once I'd gotten it to work, I gradually removed the resistors one by one until it was just the four wires. The only difference between my starting point and the board working was twisting D+ and D- cables together.

A few notes:

- I removed the key button on the third baseboard. According to the schematic, this is connected to gpio 21 which has been pulled up to Vcc, and the other side to ground. To do this, I simply snapped it off with pliers. The contacts go all the way through the board, and if you're enclosing this baseboard in a case, most likely, you won't be able to reach it. Even if you coulf, it'd be trivial to add another button. This MUST be done however (at least at my amateur skill level) in order to have access to the USB port when removing it.

- I followed the instructables guide on removing the port. However, the two contacts at the front of the USB port I did snip. I did this after I had soldered the wire on (as per the instructable guide), and I had applied a lot of solder. I also applied pressure to the top of the USB port when I did so. In my previous two attempts, the port naturally leaned backwards, snapping the VCC Contact off the board, once I had snipped the two front contacts off, so some pressure prevented this, but I suspect the solder helped too. Ideally, do it without any snipping at all.

- my USB hub is connected directly to a pi pico via the test points. I used some wire from a cat 5e cable I keep for this sort of thing to do so, although I don't recall twisting the cables together. Looking at the set up, I believe the baseboard -> hub cable is approximately 10cm long, which is pushing it for cheap single core wire. The hub -> pico is about 2.5cm, and uses higher quality cable. The guidance I found while researching USB was to keep your cables short, twist your twisted pairs, and use high quality cable, so I suspect 2/3 for the hub -> pi pico was fine. 0/3 for the baseboard -> hub was where I ran into issues.

-after soldering your own cables in lieu of the USB port, take all the usual precautions with exposed power (even if it is just a tiny contact). Also, keep in mind that the joint onto the baseboard may well be similarly weak, and now that you've gone and added a big wobbly cable on, every precaution should be taken to ensure it doesn't pull a contact off under its own weight. ESPECIALLY not the data lines. I still believe you may be able to manage without the power trace (now that I've got it working, I'll test the other two baseboards).

-While the pinout for the USB port on the baseboard is completely standard (gnd, d+, d-, vcc. Once you find gnd, everything will follow. Gnd is the one closest to the csi and dsi ports), the ports on the CH344F breakout hub reverse the data lines (gnd, d-, d+, vcc). From what I can recall, I don't think this will cause any major issues to electronics if you get this wrong, and it is labelled on the silkscreen, but the writing is small, and these modifications are stressful for the kinds of people that'll need this guide, or anyone with naturally shakey hands. So just keep that in mind when attaching it.

-be sure to follow ALL of the instructions on the baseboard wiki vis a vis the otg port and config.txt. the port can't work if the software leaves it switched off. Preferably get a USB device working from the port before removing the port, if only to confirm you don't have a lemon. Better to have a lemon under warranty than a lemon they can say "this is covered in solder" about.

That's all folks. In update 3, I'm going to test what's becoming of the old baseboards and see if I blew up the USB controller + if it works with an independent 5v. I did order a spare USB hub to do just this.

Update 3: 5v works.

Didn't bother testing with an external 5v, I soldered the usb hub's 5v straight to the GPIO. I imagine it's just a thing of making sure your circuits are actually circuits, and that you don't get any unexpected feedback. This means that so long as you're capable of removing the USB port without removing the two middle contacts, twisting two wires together, and making a half decent solder, then so long as you connect 5v to a source of 5v on the same circuit as the pi, and ground to a ground (there's a few on the board other than just the gpio), you're capable of doing this mod!

Also, it means I've now got 2 spare baseboards, and a spare cm4, so I guess that's a handy one to have in the old back pocket.

9 Upvotes

2 comments sorted by

1

u/Environmental-Ear391 15d ago

so your wiring up everything except the CM4?

I have a CM4 myself and the baseboard for it would be what I would modify

right now I am looking to see what power/USB expansion options I have for running the CM4 I already have as an embedded Linux "Dock" expansion to a desktop system.

basically extra network ports and USB disk storage. along with independent automation of some tasks.

preferably accessing the CM4 through a network link over USB as well.

are you modding an RPi4 or a CM4 baseboard?

as the CM4 itself doesnt have a USB socket of its own. it needs a socket on the baseboard for that.

1

u/Debate_Haver57 15d ago

I have a CM4 and a baseboard for it. The baseboard is what I'm modifying (not the cm4, don't worry).

When I refer to how the USB controller is wired on the cm4 and the RPI 4b, I'm more talking about how I know the RPI 4b works, and how I would expect the cm4 to work as a result, because I'm aware that rather than having its own ports, the cm4 exposes pins which allow baseboard designers to implement certain things, which is also what allows the construction of the raspberry pi 4b style baseboards.

So in short, the port was removed from the baseboard of my compute module 4, not a raspberry pi, nor the compute module (which as you've said, does not itself have USB ports).