Unfortunately, I ended up damaging my max3232 breakout board in the process. Fortunately, I had an rs232 to USB adapter, and so I ended up using a python script on my laptop in place of the max3232. I.e., I hooked the SpaceBall to my Win10 laptop via the rs232-to-USB-adapter, and hooked a black pill running a SpaceBall-to-SpaceMouse emulation script with a USB Composite Serial+HID profile to another USB port on the laptop, and then used a python script on the laptop to bridge between the two serial connections. Here is my code: https://github.com/arpruss/mouse3d_stm32f1
It’s interesting that one can actually get some use out of an STM32F1 board without attaching any extra electronics, just by plugging the STM32F1 into a PC and running a script. (The Soft Joystick example in the USB Composite library does something similar. It lets you have much of the functionality of vJoy without installing any drivers.)
That said, I’m waiting for a new max3232 unit, so I can have a less awkward setup.

Yesterday, I managed to do the USB emulation all on Windows, using USB/IP (a cool project, but alas the latest drivers are not signed). My code is here: https://github.com/arpruss/USB-Emulation
i noted that certain ICs some of which i bought on aliexpress seemed cheaper than what it would cost to buy direct from a manufacturer’s web e.g. TI, STM etc. those that ‘worked’ so happened to be blue pills / maple minis which some how they seem to be able to source at costs lower than the ‘retail’ prices on STM’s or TI’s web.
i’ve literally heard that some of the components are recovered from junk just that i’m not sure how true that is.
as for max3232, i’ve been wondering if it would be worth it to simply use some ULN2003 in its place
https://en.wikipedia.org/wiki/ULN2003A
apparently there are chinese local fabs which makes ICs that are ‘similar’ to ULN2003, it is more likely ‘real’ as those are simply darlington transistor arrays. Just that again the capacity could be suspect, e.g. the ‘cheap’ chinese ICs may not deliver on the 500mA load currents.
chinese uln2003 are going for prices like 10 pieces a dollar or even 20 pieces a dollar shipped
given that there are ‘chinese local fabs’ i suspect some of the ‘chinese local fabs’ may try to ‘fake’ brand name ICs, mainly the simpler ones
they may try to achieve the same pinouts and label the ICs as such, but the chip itself may simply be a bunch of transistors arranged like those uln2003
and they label them after the brand name SKUs. well all these are just speculation
but i think using ULN2003 in place of max3232 may work though it does not comply with the specs. that’d make it rather easy to simply pull up the output pins to VCC with a resistor and hook them up as TX or other outbound signal lines. As for inbound, e.g. RX it is mainly to protect stm32 from the excessive voltages and perhaps some resistor dividers or zener diodes may do the trick, but that would cost some extra hardware and pins on the board, i.e. the resistors. the voltages would be one of a bummer which a max3232 handles, if one don’t have a source for V+ at rs232 levels, it may be easier to just get max3232
oh some additional google turns this up one could make do with 2 transistors and resistors as well
https://www.sparkfun.com/tutorials/215
http://usbip.sourceforge.net/
it is a little unusual to bridge usb this way, but nevertheless it is an interesting use case.
for one thing, this would make it possible to use usb devices ‘remotely’, one could use a keyboard for a computer half a world away
nice article from you
http://breaking-the-system.blogspot.com … th-no.html
i think i’d try it out soon, but i do agree that using a VM is a safer / better way to try all these things out
we’d be able to even simulate a usb device to the host os running in the VM in python before doing all that code on stm32
It’s easier for me to prototype a USB device on stm using the USBComposite library than using USBIP on Windows, but perhaps that’s just because of familiarity. And it’s really unfortunate that the USBIP library comes in two varieties: (a) official release which is signed but crashes when a device disconnects, and (b) unofficial patched version which doesn’t crash but isn’t signed and required me to turn off SecureBoot.
I’ve tested with a simple USB-to-serial bridge sketch on a black pill, together with the sp3232 board. When I send “M<cr>” to the SpaceBall via Serial1, which is supposed to turn periodic axis report mode, the SpaceBall reboots as if I had sent it a “Z<cr>” (reboot). When I send it “Z<cr>”, it does nothing. The “%” command which echoes things works well, and “%M<cr>” echoes an M. Other commands I tried work, too.
On the other hand, if I connect to the SpaceBall via a cheap USB-to-serial adapter, everything works fine. Same laptop, same terminal emulator (e.g., the one in the Arduino IDE).
Off-hand, does anyone have any ideas as to why some transmissions, like “M<cr>”, might be getting garbled (I tried many times — this is not a one-off), but others, like “%M<cr>” work fine?
I’m doing this at 9600 8N1, so definitely within the capabilities of the STM32F1 UART.
Do you have some level shifters, like this? https://www.aliexpress.com/item/10pcs-l … 66582.html I’ve done every project successfully with this little things.
You can also test you code with a 5V device like Uno, Micro, Mini…
Edit: You did the wiring like this? https://os.mbed.com/teams/OpenMoCo/code … Connection Maybe this circuit ist too much simplified? –> https://www.google.at/search?q=max3232+ … 058#imgrc=_
It turned out to to be really tricky. Here is what finally worked to avoid the latch-up overcurrent problem with the fakes.
1. Add 10K pull-ups to both of the “max”3232 inputs. This reduced the frequency of the latch-up problems from one in three boots to one in ten or fewer.
2. Put a 50 ohm resistor between USB +V and “max”3232 VCC. This reduced the voltage to somewhere around 4V, as well as protecting against overcurrent. The real max3232 works at 3-5.5V but it looks like the fake suffers from latch-up at higher voltages. I couldn’t just run at 3.3V, as then the output voltage was too low to power the SpaceBall.
It worked beautifully with no changes and no soldering, powered by the pill’s 3.3V.


