MS-DOS FAT16 Formatting on OS X

It took a second to figure out how to format an SDCard with a MS-DOS FAT16 partition, so I wanted to share with everybody. This applies to any type of external disk drive.

There are some links to be found…such as and another one that’s almost identical.

First of all, the second set of instructions result in a “/Volumes/SDCARD/ does not appear to be a whole disk” error in OSX Lion. The drives listed in /Volumes by OS X are the mounted logical drives, and partitioning needs to occur on a physical disk, so I think using “/Volumes/”-anything would not work, but maybe it did in an older version of diskutil.

Regardless, both sets of instructions are approximately the same. When entering this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "XYZ" 1024M
in OS X Lion I kept getting this error message:
XYZ does not appear to be a valid volume name for its file system

I’m not sure why that isn’t a valid partition name. From what I recall MS-DOS FAT16 partitions support an 11-byte ASCII name. Rather than digging into that I tried this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "" 1024M
and got the error:
The size (1024M) must not be greater than the size of the whole disk

My SDCard is 1G = 1024M, so I’m not sure why that doesn’t work either. Rather than dig into that hole I used this command:
diskutil partitiondisk /dev/disk2 1 MBRFormat "MS-DOS FAT16" "" 1G

And my SDCard is now formatted. Hope this helps!

UPDATE 8/23/2012: The above worked for a 1GB micro SD card that was used and had been partitioned for an Android G1 previously. On another, brand new SDCard, the steps work but OS X complains that it can’t read the card. Trying to format an SDCard > 1GB is likely the problem – if I find a workaround I’ll post.


ATMega32u4 + WS2801 Demo Jig

I posted some firmware for an ATMega32u4 + WS2801 combo that works for demonstration or testing. This code is based on Sparkfun’s but has been modified to run on an ATMega32u4 with LUFA firmware support and compiles with avr-gcc. The LUFA usage is just there for show but with a little effort can be extended.

Pictured above is the firmware running with a WS2801 strip. I’m finding the random generator produces some washed-out colors, but in general they move properly down the strip.

IMPORTANT! Trying to drive the whole strip from USB/5V on the 32u4 will kill the MCU with overcurrent draw. Don’t do this! The default set in Main.c is 1. The MAX number is somewhere around 8.

Pinouts are described in firmware/main.c.

Generic 3.3v BT Module BoB

Just in are a stack of breakout boards I designed for a cheap BT module sold on eBay. UPDATE: it’s taken a very long time to determine that this is either the EGBT-045MS or EGBT-046S from Cambridge Silicon Radio. The breakout is simple, breadboard-friendly, and exposes all 34 pins on the module. The bluetooth module runs on 3.3v and comes with SPP-compatible firmware — which basically means it’s compatible with Arduino and most MCUs. It’s not 5v tolerant and needs level-shifters for 5v systems. A 5v version with built-in shifters is in the works. The bluetooth module ships with a default baud rate of 9600.

For now I’m just posting resources to this page for this module:

  • Board Layout: bob_ebay_bt_module
  • Datasheet: egbt-045ms-046s Datsheet
  • Pseudo-datasheet (found in a few places online): Bluetooth Module_BC4_Blue V2.0
  • Master to Slave Connection Howto
  • AT command set: AT Commands for Bluetooth Module. Also, refer to datasheet for complete command set. Note, for this firmware you have to not send LF/CR (enter key) at the end of your AT command. AT programming mode is up when your board is not paired by bluetooth devices. You must copy/paste the AT command since timing is important. You can send about one command per second.
  • Example Application Schematic (see note):
    . Note: this schematic refers to an older module. Refer to the datasheet for the proper information on this module and proper application notes.
  • Application Example using this breakout board: .
    This circuit design is based on the manufacturer’s application note above, but the expected PIO pins didn’t provide any feedback for me. UPDATE: this design was built before the discovery of the true datasheet with proper application notes – but it’s still valid. It took a few minutes to find PIO for connection status on pin 24, not 31 (32?) as indicated. Also I can’t find a PIO for RX/TX status; but a LED + resistor in parallel on either/both RX and TX lines can help with that (not pictured here). Some things to note from the design include:
    • Connection status PIO pin is connected to the blue LED. Connection status LED blinks fast when not connected (command mode), solid when connected (serial mode).
    • This design uses a CP2102 USB breakout board to power everything and talk to the BT module. The breakout is available at Sparkfun. You don’t need the CP2102 to use the bluetooth module – 3.3v Arduino boards are particularly well suited, as is any MCU or other circuit that uses 3.3v. I have a 5v version in the works.
    • The RX/TX lines on the CP2102 and BT module are cross-connected – such as rx -> tx; tx -> rx.
    • Getting this setup working takes a few steps to verify:
      1. Connect to CP2102 using unix’s Screen command or other RS232/TTY application at baud rate of 38400. On OS X ZTERM is a popular RS232 application. On Windows I’ve heard the “sscom32” is recommended since the command’s timing is important. You need a terminal emulator that supports 38400,N,8,1.
      2. First, test the AT commands. Type AT+VERSION, you should see something like “linvor1.5”. There is no need to exit command mode. You may want to issue additional commands but be careful when you do, and finishing this checklist first is the recommended approach.
      3. Connect to BT module using a smartphone app that permits arbitrary messages to be sent via bluetooth — such as Amarino2 APK.
      4. Verify that the characters sent from phone appear on the PC.
      5. You should also be able to see characters typed from screen/tty-application to your phone. In Amarino2 you can use the “Serial Monitor” for sending and receiving bytes.
    • Porting the setup to other 3v3 Arduino or MCU is straightforward (explanation needed).
    • When using a phone or PC to connect to this Bluetooth module you should see it listed with names that start with “Linvor”. The connectivity on this module appears to be quite robust for the price point.
    • DO NOT connect anything higher than 3.3 volts to any input pin or power pin on this module. You will surely burnout that pin!

Sun, Moon, Earth

Sunset over the Front Range of the Rocky Mountains in Colorado only lasted a few minutes today and was perhaps the best scene of the solar eclipse on this cloudy day. I’ve seen a few (annual) solar eclipses, several lunar eclipses, a blue-moon lunar eclipse, and moonset during a lunar eclipse; but this was my first time seeing a solar eclipse at sunset. It was unforgettable. The photo shows the unmistakable perspective of Sun, Moon, and Earth.

For this photo I used my Meade 90mm Maksutov/Cassegrain and taped a few pieces of printer paper to a magazine. For viewing it was great – I don’t mind laying on the ground to see something like this. But for photos I had to hold everything up by myself so it was difficult to get everything focused properly. When sunset started images like this started appearing on the projection matte. There was no time to improve my setup — rim-to-rim of sunset was only about 120 seconds.

This comes with the usual disclaimer: viewing the sun with naked eyes can be damaging, and viewing the sun with magnification can be instantly blinding. Viewing the sun with magnification should only be performed with qualified scientific solar filters or by using a safe method of projecting the image onto a matte (non-glossy) surface.

Durable Arduino Pro Mini Enclosure

I posted a 3D design file for a couple of enclosures today. Included is a 3D design for an Arduino Pro Mini enclosure. We were selling the design as a product on Ponoko but the cost of the print was ridiculous. Actually the cost of the prototype was ridiculous. 3D printing the case on superfine plastic isn’t cheap but is more reasonably priced on cheaper plastic. If you have a RepRap this design will suit you nicely. I’ll post some pictures on here and Ponoko very soon.

AndroidHTTPD – Multithreaded HTTP Server for Android

Yet another open-source HTTP web server for you. This time in the Android-Java flavor, extremely thin, yet useful. The code delivers a few changes to field/method visibility to NanoHTTPD to for easier extension and customization — nothing more or less! NanoHTTPDPooled wraps NanoHTTPD with a very simple and thin HTTP connection pool. AndroidHTTPD provides an example of Android usage.

This code doesn’t promise any of the power or robustness of Apache, Tomcat, or other professional-grade web servers. You can still get much done with these servers (either one). They’re suitable for usage in Android (mobile) apps, are non-blocking, fast, and thin.

The code’s at