Better sslh

For those that don’t know, sslh is a TCP port multiplexer. This basically means that you can serve both https and ssh traffic from the same port. It’s most useful for circumventing corporate firewalls that block TCP port 22 (i.e. ssh), but allow TCP port 443 (i.e. https) by serving both on TCP port 443.

In the default configuration, however, all connections that go through sslh look to ssh or apache as if they came from localhost. This isn’t ideal if you want to run something like denyhosts or fail2ban to block malicious ssh login attempts.

sslh does have an option to do “transparent” proxying so ssh and apache think that the connections have come from the right place. In this post, I’ll describe how I set this up on my machine.

Read the rest of this entry »

Debugging STM32 with GDB and OpenOCD

Screenshot from 2013-02-23 00:28:10

When developing my Valentine’s day puzzle box, I found myself really wanting to single-step through some code to figure out where things were going wrong.  Fortunately, the STM32F3 Discovery board that I was using supports on-chip debugging.  Unfortunately, it wasn’t already integrated into the template that I was using for the project.

Read the rest of this entry »

Valentine’s day puzzle box



***UPDATE*** I’m going to make some updates to the code, so I’ve modified all the github links below to point to a tagged version. For the latest-and-greatest code, look here.

After I saw this post on about ST Microelectronics giving away STM32F3 Discovery boards for free, I knew I had to have one, but I didn’t really have a specific project in mind for a while.  Then, one day I remembered a reverse geocache box that was also featured on hackaday, and realized that I could do something similar.  The F3 Discover board includes a 3-axis accelerometer & 3-axis gyroscope, so instead of using GPS, I would only have the box open when it was rotated through the correct sequence of orientations.

For those who don’t want to read the whole post below, the code is posted on my github repository.  Also, those looking for photos should skip to the last half of the post.

Since I had ordered the free sample in late November, I figured that I’d have enough time to make this puzzle box as a Christmas gift for my wife.  Unfortunately, it didn’t arrive until the day that we celebrated our early Christmas (before we travelled to see our families). Not quite enough time to throw it together…  Fortunately, that just meant that I had more time to put something together by the next gift-giving opportunity…St. Valentine’s day.

Read the rest of this entry »

I know USB

I’ve been trying to get my STM32F3 Discovery board to register as a Virtual COM Port (i.e. RS232 serial over USB) when I plug it in via the “USB User” port.  I had a false start trying to use the code for the F4 Discovery from here…Apparently, the USB hardware is too different between the 2 boards.

However, I did manage to get the example USB joystick/mouse code from the F3 Discovery firmware package from the ST website to run.  It is pretty neat…tilt the board one way or another, and the cursor moves!

That code, along with this “USB in a NutShell” guide, and this description of the USB CDC Virtual COM Port should give me enough info to implement what I want.  After reading through “USB in a NutShell”, I feel like this meme is appropriate…

I’m on Hack a Day!

I submitted a tip to Hack a Day about the template I put together for the STM32F3 Discovery board, and they posted it!


Halloween 2010

My vision for an electronically-enhanced Halloween was something like this:

It is a dark and stormy night. The air is filled with the sounds of children…screaming in terror at the evils of the night, and oohing in delight at the candies received.Little Timmy approaches the next house…it looks plain enough, with just a couple of styrofoam tombstones in a corner. Unfazed, he continues approaching the door. As soon as he steps up on the front porch, lightning flashes almost blind him, and thunder claps almost deafen him. Startled, Timmy makes another step. A soon as the thunder dies down, a ghost rises from behind some gravestones, and a horrible screaming begins. Timmy, with tears streaming down his face, can’t tell if the screaming is coming from the ghost or from himself…

So yeah, that’s what I was going for. Instead, I only had time to get the ghost to rise up from the grave, and I had to trigger that manually. I did manage to make a couple kids cry, though. It was a qualified success.

The Trigger

Read the rest of this entry »

Modifying a camera flash – part 1


A camera flash uses high voltage, and a large capacitor. Even if the camera has been sitting around for a “long time”, the capacitor can still hold enough juice to give a good shock. In order to avoid this, be sure to fully discharge the capacitor by shorting the 2 terminals with a screwdriver or something. (But not your nice screwdriver…the arc can actually pit the metal)


I was about to buy a disposable camera just to dismantle it, but it seemed a waste of $10 (or whatever it cost). I remembered a couple people mentioning that sometimes you could get them for free from photo labs, so I figured I’d give that a shot first.

So I went to my local grocery store’s photo department, and asking if they had any “spent” disposable cameras. I felt a little foolish asking for what was essentially trash, so I described how I wanted the circuitry from them. I don’t really think it mattered, though. The guy behind the counter just brought the bin out for me and told me to have at it. Awesome!

I ended up with 2 Kodaks and 1 Fuji.

Read the rest of this entry »

Motor Controller

Design Goals

  • Variable speed using PWM
  • “Safe” circuit with no chance of a short circuit
  • minimal pin count


I don’t think I mention it below, but I chose the particular model of NFET because it was the same one that was used in the original drill that I pulled the motor from.  The NFET there also had a decent sized heatsink attached to it, so that could have been another source of problems.

I also considered using a TVS diode to suppress the motor surge.  Again, I have not tried this to see if it would have made any difference.

I found out much later that most of my problems with the solid-state solution were probably because of the way that I was driving the NFET gates.  A proper gate driver will be able to provide the necessary voltage to the high-side gates, will provide the necessary current to ensure fast switching, and will add a delay to eliminate any shoot-through current (where both NFETs on one side are active at the same time, creating a short circuit).

Version 1.0

Read the rest of this entry »