Category Archives: Electronics

Raspi Bplus-1

Fixing bash Shellshock vulnerability on Raspberry Pi

The recent bash vulnerability, a.k.a. “Shellshock”, is pretty bad, considering it might actually have been around for a very long time, maybe even dating back to the predecessor of bash. Not good.

So what about Raspberry Pi’s?
Are they vulnerable?

Turns out they are, but there is already a fix available for them and patching a Raspi is very simple. Whether your actual Raspi is vulnerable depends on what distribution you are using, and how recently you upgraded the software in it.
The Raspi used below is running IPE-R1, which is a blackout-proof version of Raspian.

First let’s find out what bash version we have:

root@raspi-2:~# dpkg -s bash | grep Version
Version: 4.2+dfsg-0.1
root@raspi-2:~#

You can also run this little script to determine whether your Raspi is vulnerable to Shellshock

root@raspi-2:~# env x='() { :;}; echo "WARNING: SHELLSHOCK DETECTED"' bash --norc -c ':' 2>/dev/null;
WARNING: SHELLSHOCK DETECTED
root@raspi-2:~#

Let’s fix this. Just refresh the repos and upgrade bash (the patched version is available in the main repos).

root@raspi-2:~# apt-get update && apt-get install --only-upgrade bash
Get:1 http://archive.raspberrypi.org wheezy Release.gpg [490 B]
Get:2 http://mirrordirector.raspbian.org wheezy Release.gpg [490 B]
Get:3 http://archive.raspberrypi.org wheezy Release [10.2 kB]
...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
 bash-doc
The following packages will be upgraded:
 bash
1 upgraded, 0 newly installed, 0 to remove and 54 not upgraded.
Need to get 1,443 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main bash armhf 4.2+dfsg-0.1+deb7u3 [1,443 kB]
Fetched 1,443 kB in 1s (1,386 kB/s)
(Reading database ... 29754 files and directories currently installed.)
Preparing to replace bash 4.2+dfsg-0.1 (using .../bash_4.2+dfsg-0.1+deb7u3_armhf.deb) ...
Unpacking replacement bash ...
Processing triggers for man-db ...
Setting up bash (4.2+dfsg-0.1+deb7u3) ...
update-alternatives: using /usr/share/man/man7/bash-builtins.7.gz to provide /usr/share/man/man7/builtins.7.gz (builtins.7.gz) in auto mode
root@raspi1:~#

The installed version of bash is now +deb7u3

root@raspi-2:~# dpkg -s bash | grep Version
Version: 4.2+dfsg-0.1+deb7u3
root@raspi-2:~#

The short test script above also returns nothing:

root@raspi-2:~# env x='() { :;}; echo "WARNING: SHELLSHOCK DETECTED"' bash --norc -c ':' 2>/dev/null;
root@raspi-2:~#

You could of course also just do an “apt-get upgrade” to upgrade all packages on your Raspi, would take a bit longer but will work just as well.
Also, if you are not logged in as root you need to do a “sudo apt-get update”, of course.

How to get OS X 10.9 Mavericks and Arduino IDE to play nicely with each other

Apple tried to be smart with OS X Mavericks, developing their own FTDI drivers. Just too bad they don’t seem to work.

I have been getting nothing but “avrdude: stk500_recv(): programmer is not responding” errors when trying to upload sketches to various Arduino compatible boards.
In the end, the only thing that worked was programming the boards using a dedicated programmer (in my case an USBasp).

Some digging around forums and Apple’s support site, the following steps has solved the issue on all the OS X machines where I have tried it. In short, you need to replace Apple’s drivers with the ones from FTDI.

  1. Open a terminal
  2. cd /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns
  3. sudo mv AppleUSBFTDI.kext AppleUSBFTDI.disabled
  4. sudo touch /System/Library/Extensions
  5. Restart computer
  6. Install FTDI’s virtual COM port drivers from http://www.ftdichip.com/Drivers/VCP.htm. In version 2.2.18 this package contains two executable files, I have had success with the one named FTDIUSBSerialDriver_10_4_10_5_10_6_10_7
  7. Restart again (might not be needed, good practise though after installing drivers)

Voila – The Arduino IDE can now upload sketches to all boards I have tried, both with the old/legacy bootloader and Optiboot.

Fail of the day #2: SSD drives out of spec

A while back I got an SSD drive with the question whether it could be repaired. At first glance it looked fine. But wait… the PCB is not level. In fact, it is seriously wobbly. What on earth happened to this SSD??

That PCB should really not have that shape..

That PCB should really not have that shape.

Looking closer at the flash ICs, it turns out several of them have pins that have disconnected from the PCB. Ok – that’s tough but nothing some careful soldering cannot fix.

But after inspecting the rest of the PCB it is clear that some inductors and capacitors have been torn off too. Wow – this drive took a real beating – nothing here to be salvaged except maybe a crystal or inductor. Could possibly be useful in other projects. Well – it goes into the to-be-used-in-future-projects box.

 

That’s only half the story… Quite a while back I came across another pair of PCBs. Another SSD, in fact – broken in two. Probably on purpose to prevent data extraction from the drive, but it gives a good opportunity to have a closer look at what is inside an Intel SSD drive.

2014-01-01_22-51-10

No rescue possible here, no matter how good soldering skills..

All the passive components (capacitors, resistors) are so small they are impossible to hand solder – no point in salvaging them. Most of the other components are held in place with epoxy, making removal impossible (but I will for sure buy Intel SSDs from now on – these things are built to last!).

The PCB seems to have multiple layers. There is for sure at least a ground plane in there, probably 1-2 signal layers too (hard to count them without a microscope).

The one component that might be of interest in other projects (adding memory to OpenWRT based routers comes to mind) is the SDRAM, is a Samsung K4S281632I-UC60 8Mbyte x 16 IC.  On the other hand – hand soldering that one will be… difficult (understatement) and require rebuilding the OpenWRT kernel. Hmm.. Will probably just recycle it.

FAIL of the day #1: Repair of NiMH charger

2014-01-01_16-25-22

When buying some GP branded NiMH rechargeable batteries about a year ago, a “GP PowerBank Travel” charger (model GPPB03GS) was included as a promotion. It’s a nice little charger that runs both off 220 V and 12 V (for use in car, I presume). It can charge 1-4 AA batteries, or 1-2 AAA batteries, with additional trickle charging after full capacity has been reached.

The charger worked well for some months, but one day after charging some batteries overnight the LED blinked red, and when removing the batteries it was clear something had gone wrong. See the melted plastic? Not good.

As this was very much an el-cheapo charger, one should probably not expect much from it. But I was still curious about how the 220V was brought down to more useful voltage levels, and if the internals would live up to safety standards. I was actually quite surprised at how complex and well designed the internals were:

Looking closer, there are three distinct parts of the PCB:

– 220V section, which is shielded with plastic blast shields towards rest of the electronics – nice! This is a classic Switched Mode Power Supply (=SMPS), with an optocoupler feedback loop. Looks like a SMD type TL431 voltage reference – very common in SMPS designs.

– 12V section, with some protection diodes, filter caps etc – but no other major components.

– Charger circuit, using an unknown controller IC. The markings have been shaved off. I just don’t understand why they go through the trouble of doing that… It’s not like this is some super classified product where the design should be kept secret at any cost.

A closer look at the components and PCB around where the plastic had melted does not give any clues of what has gone wrong – in fact nothing visible anywhere on the PCB indicates a catastrophic failure of the charger.

Bringing out the multimeter and measuring the output from both SMPS and 12V section shows that those voltages are all good – most likely the problem is instead in the unknown charging controller IC, or possibly some of the tiny SMD FETs, diodes etc that complement the charging IC.

So… given that this kind of charger cost next to nothing these days, I’ll leave it for dead for now. The SMPS works as it should, so maybe that part can be reused in some other project – I’ll stash it in the “possible-future-use” parts bin.

JBC CD-2BC soldering station unboxing

Got a new toy the other day…

After using the same ERSA MS 6000 soldering station for the past 20 (!) years or so, it was time to upgrade. Nothing wrong with the old one really, except that it was hard to get new tips and that heating it up took a minute or two.

Getting a Chinese rip-off from eBay would be easy, but if the next soldering station would also last 20 years, why not get something slightly better?

JBC has a good reputation and seemed to have good value for money. So – here are some pics from the unboxing. Enjoy!

Two dollar variable fan controller

Well – given current exchange rate, AU 2.59 = USD 2.33.. So it’s not quite a two dollar product, but pretty close. And “2.33 dollar fan controller” did not make for a nice subject line…

After the earlier post about variable 12V fan controllers, it might be worth looking at what is available on Ebay. Turns out you can get a variable controller delivered anywhere in the world for USD 2.33 – pretty amazing! It looks deceivingly like the Zalman Fan Mate 2 too:

Zalman Fan Mate 2 (left, USD 7) and eBay ditto (right, USD 2.3)

Zalman Fan Mate 2 (left, USD 7) and eBay ditto (right, USD 2.3)

The eBay controller only has one 3-pin male connector (where the fan connects), and then a soldered in wire with a 3-pin female connector, for attaching to the PC or other equipment.

The Zalman on the other hand has a 6-pin male connector on one end, a special Y-cable (it comes with the Fan Mate 2) is then needed to hook up the controller to fan and PC. Both variants of course work, the Zalman approach is maybe slightly better, as it allows the controller to be mounted closer to an inside corner, without the cables being in the way. Not a major difference though.

Looking inside the eBay controller, it is obviously different from the Zalman. For starters, it has a NEC B772 P PNP medium effect transistor in there, rather than a voltage regulator. I could not find a datasheet for that particular NEC device, but I am pretty sure it is more or less identical to ST’s 2SB772.

There is also a TL431 adjustable voltage regulator in there, together with a second SOT23 transistor market J6, it might be a S9014 NPN transistor (or equivalent).

So, in essence the eBay controller is also a linear regulator, but based off an adjustable regulator (rather than the fixed-voltage 7805 that the Zalman uses), with an extra power transistor to boost current. The extra transistor is needed, as the TL431 can only sink 100 mA on its own.

All good so far. But when reverse engineering the eBay controller, the schematic just doesn’t add up. Below is what the eBay controller looks like, with the above assumptions on components – and this is not a working circuit, as far as I can tell (or is it? Feel free to add your expertise in the comments!).

eBay variable fan controller - except that the circuit is a bit weird.. Need to re-check those PCB traces!

eBay variable fan controller – except that the circuit is a bit weird.. Need to re-check those PCB traces!

So…. either I made incorrect assumptions regarding what SMD components are used in the eBay controller, or I just didn’t check closely enough how the PCB traces were connected. Time to bring out the multimeter to check those traces – more to come on this topic.

Fritzing vs circuits.io vs Eagle – comparing schematics editors

During the recent work on the one dollar variable fan controller, I looked into options for documenting the work.

I have never really used CadSoft Eagle enough to get comfortable with it, and whenever I used it it seemed to be overkill for what I wanted to do. Still, it is usually still seen as the best software for this kind of work.

But maybe there are other options.. In particular I thought the more basic editors sounded promising – let’s give them a try. Disclaimer: Nothing near a full review was made of the different services. The verdicts below are instead based on 15-20 minutes use of each service, and no reading of any manuals or help pages.

Circuits.io

This would be the new kid on the block. Mix schematic editor with GitHub and you get something like Circuits.io. You can follow circuits created by other people, fork your own variants of other people’s circuits etc. Very nice concept, but it also seemed to have a lot of limitations..

circuits.io one dollar fancontroller

Circuits.io used to create a one dollar variable fan controller

For example, I failed mirroring the 7805 in the circuit to the right. Having the output to the left feels very awkward.. I am sure there are ways around it, but even though I really searched for it, I also failed to find a traditional 7805 symbol such as the one in the second image, and was left with the one used in the top schematic. Fail.

Traditional 7805 symbol

Traditional 7805 symbol

There for sure are nice things about circuits.io though. Having an entirely browser based editor is a very nice concept. It might be too early days for it now, but good things come to those who wait… I also liked the feature where you, given a PCB board design, can get files for 3D printing or milling a custom case for your board. Nice!

The fan controller project can be found at http://www.circuits.io/circuits/4841. Go fork it!

Fritzing

This is also a pretty new project, with a lot of promise. It is obviously geared towards hobbyists that might not have a ton of experience in electronics design, but it is still kind of nice.

One dollar variable fan controller, using Fritzing

One dollar variable fan controller, using Fritzing

With a slogan of “from prototype to product” it is clear that the Fritzing team is trying to cover it all. Not sure I would want to go this route with a full project though – I always get suspicious about software that offer a link to some third party service (in this case for manufacturing of PCBs). It probably works perfectly fine – I just feel left without the control I want to have.

Breadboard view in Fritzing
Breadboard view in Fritzing

The schematics editor is nice (better than circuits.io), and I even like the slightly silly feature where you can get a breadboard view of the circuit. Probably not a bit useful for an experienced electronics hacker, but still kind of cute.

The fan controller project can be found at http://fritzing.org/projects/one-dollar-variable-fan-regulator

Eagle

CadSoft Eagle is a professional schematics editor and PCB layout tool. The free version does have some limitations (PCB size and # layers, among others), but they are pretty generous and won’t cause any problems for most hobbyist projects.

The UI feels a bit dated, to be honest. But also quite efficient, given the vast number of components available. Seems lots of people also create their own Eagle libraries with various components, so there is a good chance you can find, download, install and use existing libraries. Otherwise it’s not too hard to create your own, half an hour of fiddling around with libraries left me with a working one. Nice!

Of the three tools Eagle is by far the best, even when considering the somewhat steep learning curve. Give it an hour and you will be able to create fairly complex circuits. PCB layout is still a bit of an art, no matter what product you use – you just have to learn as you go along, and from mistakes. Eagle does have some nice tools for eliminating the most obvious errors though – once again, nice.

All in all, going forward Eagle will (still) be the preferred solution around here.