A Digital Micrograph Script to Change the Length of Scalebars of All Open Images

This digital micrograph script will change all the open image windows to be of the same displayed numerical scalebar length (e.g. 20 micrometers). If the images are of different magnifications then the scalebar sizes will be different, but numerically the same. Calibrations are not changed, scalebars are still correct. I wrote this script to serve a single purpose, and perhaps you will find it useful. If you don’t like it, that’s cool, you’re free to write your own. I kinda posted it here because I didn’t have many options.

If you’re into DM Scripting, then you might be interested in The DigitalMicrograph™ script database at The Austrian Centre for Electron Microscopy and Nanoanalysis, or Dave Mitchell’s DigitalMicrograph™ Scripting Website, which are great resources.

You can also get this script from Github.

// A script to set all the open images to the same displayed scalebar length. 
// Doesn't change calibration of images, so if images have different magnifications the bars will be different (but correct) lengths
// Scalebar position doesn't change, but will change length.  
//
// Note DM quantizes scalebar display to specific values (0.5 nm, 1 nm, 2 nm, 5 nm, 10 nm, 20 nm, etc), regardless of what you enter.
// Also, choice of a larger fontsize may make the scalebar snap to the next highest display value.  Decrease your fontsize in that case.  
// 
// Steven Cogswell, P.Eng.
// October 2012
//
// Thanks to Pavel Potapov and D.R.G. Mitchell (Scale_bar_control.s) for information how to handle scalebars and annotations in DM script

Image curr
ImageDocument imgdoc
number NumAnn, AnnID,AnnType,Fontsize
number TextID, left,right,bottom,top, retval, numwindows, i
number scalex,scaley, nmscale, barwidth
string imagename

// User chance to abort entire operation
retval = ContinueCancelDialog("This script tries to give all open images the same displayed scalebar value")
if (retval == 0) {            // 0 if user cancelled, 1 if okay
	result("Cancelled.\n") 
	exit(0)
}

// Get desired scalebar length
nmscale=20
retval = GetNumber("Desired Scalebar Length", 20, nmscale)
if (retval == 0) {            // 0 if user cancelled, 1 if okay
	result("Cancelled.\n") 
	exit(0)
}
result("User entered scale "+nmscale+"\n")
nmscale=nmscale+0.01  // Rounding makes the scale a little short, this just bumps it up. 

// Get desired font size
Fontsize=20
retval = GetNumber("Desired Font Size", 20, Fontsize)
if (retval == 0) {   // 0 if user cancelled, 1 if okay
	result("Cancelled.\n")
	exit(0)
}
result("User entered font size "+Fontsize+"\n");  

// Processing
numwindows = CountDocumentWindowsOfType(5)
  // Get number of images open
result("Processing "+numwindows+" images\n")

// Loop over all open windows 
for (i=0; i<;numwindows; i++) {

	imgdoc=GetImageDocument(i)
	curr:=imgdoc.ImageDocumentGetImage(0)     // The current image being processed
	imagename = curr.GetName()    // Display name of image 

	GetScale(curr,scalex,scaley)
	result("Image "+imagename+" X scale: "+scalex+" Y scale:"+scaley+"\n")
	barwidth=nmscale/scalex     // number of pixels a bar of nmscale would actually be

	//loop through annotation index
	NumAnn = CountAnnotations(Curr)     // Get number of annotations in current image
	for (number j=0; j<NumAnn; j++)
	{
		AnnId = GetNthannotationId(curr, j)
		annType=AnnotationType(curr,AnnID)

		if(annType==31)    // type 31 seems to be the scalebars
		{
	  		result("scale bar found: ")
	  		GetAnnotationRect(Curr, AnnId, top, left, bottom, right)
			result("scalebar box: L:"+left+",R:"+right+",B:"+bottom+",T:"+top+"\n")
	  		SetAnnotationRect(Curr, AnnId, top,left, bottom, left+barwidth)     // Same position, lengthen bar to length of nmscale
	  		SetAnnotationSize(Curr, AnnId, FontSize)   // Set the font size
		}
	}
}

result("All Images Done.\n")

So, now you want to move to OSX Mountain Lion.

I’m not kidding, I’m word-for-word copying this old post because little nothing has changed, and you feel a need to read this.

Want to move to OSX Mountain Lion? Concerned? Be Safe:

  1. Make sure you have a Time Machine backup. If you don’t have a time machine backup, you’re a fool.
  2. Make sure your machine can actually run OSX Mountain Lion, “iMac (Mid 2007 or newer), MacBook (Late 2008 Aluminum, or Early 2009 or newer), MacBook Pro (Mid/Late 2007 or newer), MacBook Air (Late 2008 or newer), Mac mini (Early 2009 or newer), Mac Pro (Early 2008 or newer), Xserve (Early 2009).” No, your G5 will still not run OSX Mountain Lion
  3. Use SuperDuper or CarbonCopyCloner to make a clone of your existing system out to another hard drive. Buy an external drive, or buy a drive dock and buy bare drives to plug into it. Docks are great for Time Machine backups too. Do not whine that hard drives are expensive. How much is your time worth to you?
  4. Buy and download the OSX Mountain Lion Installer. Don’t pirate it, for fuck’s sake. It’s only $30 $20. Save a copy of the Installer somewhere safe, make an installable DVD or USB Key while you can.
  5. If you’re using Filevault 1, turn it off (and you should be using Filevault, if you’re using a portable machine). It’ll make transitioning easier, and you’ll want to enable the “whole disk filevault” after Mountain Lion is installed. If you’re using Filevault 2 (the Filevault introduced in Lion 10.7), you can leave it enabled – OSX Mountain Lion can install to an existing whole-disk-encrypted volume without any problems.
  6. Install OSX Mountain Lion to the SuperDuper’d Drive and not your internal drive. Don’t do anything to your internal drive.
  7. (alternately: install OSX Mountain Lion to the internal drive, and disconnect your SuperDuper’d drive for safety. This is more work to get back to normal though for when your OSX Mountain Lion goes wrong.)
  8. Boot from the drive you put OSX Mountain Lion on (the SuperDuper’d drive)
  9. Find out exactly how many Rosetta apps you didn’t know you have. Start looking for replacements, since Rosetta is dead. PowerPC has been dead for years. Move with the times. I’m also looking at you, stupid developers still shipping PowerPC code
  10. Use it like this for a few days. Try out everything you normally use to find out it doesn’t work anymore. Keep track. Nicely ask developers to get OSX Mountain Lion versions out.
  11. If it doesn’t work out, don’t worry. Just boot from your untouched Snow Leopard Lion drive, carry on as if nothing happened. If you fuck things up, use your Time Machine backup to save your ass.

Did that all turn out nicely? Fine. Your choice at this point:

  • Install OSX Mountain Lion to your regular drive
  • SuperDuper your external clone drive with OSX Mountain Lion back to your internal drive. Disconnect external drive and keep it safe.

Make sure to keep your Time Machine backup for when you need to roll back.

Never work without a net.

How to Add Podcasts to a Playlist in iOS 5.x even with iTunes Match Turned On

iTunes Match is a pretty nifty service that I won’t go into detail about. If you don’t know about it, go read up. When you turn on iTunes Match on your iOS device (iPhone 4 in my case), it ‘takes over’ the music portion of your phone, removes all the sync’d from iTunes music, and makes all your music addable via download from the iTunes cloud server. No problems.

The problem is playlists and podcasts. I know, podcasting is dead, but before iTunes Match, on the iPhone you could add Podcasts to a playlist just like any other media. But now with iTunes Match enabled, and you go to add a playlist on the phone (I’m not talking about making playlists in iTunes, I mean on the phone itself with “Add Playlist” in the Music app), the “Podcasts” icon does not appear in the list of things you can select from anymore:

Interestingly with iTunes match disabled the option appears again. Probably just some silly thing in how iTunes Match is implemented in iOS. Maybe it will get fixed in a revision of iOS, maybe not. Either way, here’s how to add podcasts anyway.

It’s actually pretty simple: When adding tracks to a playlist, drag down to reveal the search box. In the search box you could type the name of your podcast (if you remembered it), but instead just enter ‘podcast’.

You damn right, it knows, it gives you a list of all the podcasts

and scroll down some more for individual podcast episodes.

Then you can add those mo-fo’s to your playlist

and presto, it’s like you never spent $24.99 on iTunes Match and had it ruin your ability to listen to podcasts in a playlist.

Hardware Debugging the Arduino using Eclipse and the AVR Dragon

There is no music associated with this post.

I’ve written before about using an Atmel AVR Dragon to debug an Arduino board, using AVR Studio 4. I recently had some communication from Stephen Lake where he mentioned he was using Eclipse for Arduino development. I’d looked at Eclipse a long time ago and setting it up was an absolute terror with no real benefit. Stephen said it was much easier now, so I figured I’d have a look. Along the way I found the toolchain is robust enough these days to support DebugWIRE debugging of the Arduino and not have it suck too hard. I spent a lot of time trying to get the setup right, so I figured I’d detail it out if you’re trying to figure it out too, and save you the effort.

I’m standing on the shoulders of giants here. I’ve developed none of the software/plugins involved. I just put the pieces together from some disparate sources, some of which are a little out of date. The real credit goes to the authors of the software used in this. I did the setup on Windows and Linux, and the steps are 90% the same. I haven’t tried any of this out on OSX. This worked for me, maybe it will work for you. Maybe it won’t. I did this with Arduino IDE 1.0 installed.

Here’s what you’re going to need:

  • An Arduino that’s been modified for DebugWIRE operation
  • Eclipse
  • An AVR Dragon. Other debuggers might work, but a Dragon is what I have
  • WinAVR (Windows) or the AVR Toolchain (Linux)
  • libusb for Windows
  • Some patience. Okay, a lot of patience.

Get a DebugWIRE-capable Arduino

I wrote a whole big-ass article on this before, so you can reference that. For this experiment I used my modified Diecimila board. It will probably work with the UNO and other boards, I just haven’t tested them. Your mileage may vary.

Eclipse

More specifically, Eclipse IDE for C/C++ Developers (includes Incubating components). At the time of this writing Eclipse was 3.7.2. The nice thing about Eclipse is that it doesn’t have to be “installed” on your system, you can just unzip the folder and run it from that. That means you can keep many, many different versions of Eclipse configured for different tasks like I do around and not have to worry about trying something that will foul it up in some other aspect. I started out with the base CDT version and added into it. You’ll also need Java for this, of course, since Eclipse requires Java to run. Hey, I hear Eclipse can be used for Java development. groan.

On Ubuntu you can just apt-get it, but I chose to download and unzip it.

Atmel AVR Dragon

The dragon is (still) only $54 from Digikey in Canada. I’m sure you can get one just about everywhere. You can probably make all this work with the Atmel JTAG ICE III (I didn’t even know they had a III out), but those are expensive and so I don’t have one. You don’t have to do any mods to the Dragon other than maybe put some pin headers on it. I put a ZIF socket onto mine, but we won’t use it for this exercise.

AVR Dragon connected to Diecimila via ISP cable

WinAVR (ie – GCC Toolchain)

For Windows you want WinAVR. I used WinAVR 20100110 in this, and there’s nothing newer (and not likely to be anything newer). You might think that 2010 is old and you need something newer and cooler, but trust me working with the 20100110 is a lot easier than trying to build your own toolchain on Windows. When I started with this I had problems and I thought “a newer version might fix it”, and the problems just turned out to be me, and the building new stuff turned out to be a colossal pain.

You’ll also want some version of AVR Studio. In this I used 5.1 but I know it works with AVR Studio 4, since my previous article involved Studio 4. The thing to note is that v4.x and v5.x want different versions of the Dragon firmware, so if you want to go back and forth between 4.x and 5.x you’ll have to keep re-flashing the Dragon too. That’s a pain in the ass.

On Ubuntu you can just use the stock available AVR toolchain stuff,

apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude avarice

As of this writing, the versions were gcc-avr (1:4.5.3-2), binutiles-avr (2.20.1-2), gdb-avr (7.2-1), avr-libc (1:1.7.1-2), avrdude (5.10-3), avarice (2.10-3ubuntu1). Like WinAVR, there are newer versions available but the stock ones worked (I did build avarice 2.12 to test, didn’t make any difference in what I saw). I also had the stock Ubuntu 11.10’s OpenJDK for Eclipse.

From here on out I’m going to stick to the Windows side of things, but really, if you use Ubunnnntu you’ll figure out how to set the right stuff in Eclipse, you’re smart like that.

libusb for Windows

Here’s where the pain in the ass really comes in. I spent the longest time trying to get this sequence of stuff right, and here’s what worked. This is the primary reason I wrote this article, because it was such an orderal figuring out the right way to make this all work correctly.

If you install one of your AVR Studio (v4 or v5), it will install the AVR Dragon USB driver. That’s great. The Dragon works fine in AVR Studio. Problem: nothing else will. The WinAVR stuff won’t talk through the Jungo driver to the Dragon. Instead, you’ll have to install libusb-win32 to provide an alternate usb access that the WinAVR stuff can work with.

Difficulty: when you install the libusb stuff, the Jungo driver is not active, and so AVR Studio doesn’t work with the Dragon. So if you’re like me and you keep popping back and forth between environments, you have to keep changing the driver. The good part is, it’s easy to do, it’s just busyness. There may be an alternate way to make this work, but I couldn’t find it.

So you need libusb-win32 for this. I used version 1.2.6. There is a version that comes inside the WinAVR directory itself, but I wasn’t successful getting it to work flawlessly. It probably does, but if so I wasn’t doing it right. I was able to do it right with the 1.2.6 version, so that’s what I’ll describe.

With AVR studio installed, and your dragon attached, you can check in the Windows device manager that you have a driver for “Jungo” in play, and the AVR Dragon is associated with it. Unzip the libusb-win32 stuff, and look inside for the “install-inf.exe” program. If you run that, this will make a very nice .INF style installer for your Dragon that uses the libusb driver.

Once you’re done you can push the “Install Now” button to actually install the driver.

From here on out, if you’re going to go back and forth between AVR Studio and the WinAVR-style toolchain you’ll have to learn how to switch between the Jungo driver and the libusb driver. It’s pretty easy. With your Dragon attached, bring up the device manager. Select whatever driver is currently installed, right-click and select “uninstall.” Don’t worry, this doesn’t remove anything, the driver sticks around on your computer. The driver will disappear from the device manager list. Unplug and re-plug in your Dragon via USB and you’ll see the Windows “found new hardware” message. Walk through the Install New Hardware wizard, but don’t let it automatically install anything. Choose “Install from a list or specific location”, and “Don’t search. I will choose the driver to install.” Then you’ll get to pick between the Jungo driver and the libusb driver.

Verify Dragon Operation with Jungo and libusb drivers

AVR Studio

Before you go any futher, you should verify that you can get your Dragon to work in AVR Studio and the WinAVR toolchain. Switch to the Jungo driver, start up AVR Studio, and start up the “AVR Programmer”.

You should be able to connect to your Dragon, and read the fuses on the chip. The nice thing about AVR Studio 5.1 is the programmer will tell you the correct chip if you’ve picked the wrong one. On my Diecimila it’s an ATMega168.

NOTE THE FUSE CONFIGURATION. Messing up the fuses is the easiest and fastest way to making your Arduino experience unhappy. We’re going to be changing some fuses during the course of debugging, so you’ll have to learn how to put all the fuses back correctly when you’re done. If you screw up the fuses, the on-board Arduino bootloader will not work correctly. Also note that the fuses are different for the different Arduino models. The ones I show are for my Diecimila. The ones on the UNO are set differently.

Also, you can use the AVR Studio programmer to burn the bootloader back to the Arduino in the event you mangle things up pretty good. This is useful since the Arduino IDE will let you burn the bootloader with a variety of devices but the Dragon is not one of them. Remember to choose the right bootloader for your chip for pity’s sake.

AVRDUDE and libusb

With your Dragon connected, and connect to your modified-Arduino via the ISP cable, switch over to the libusb driver as described earlier. Open up a command prompt (Start -> Run -> cmd). The main command-line program from WinAVR we’ll use will be AVRDUDE. WinAVR sets that PATH variable, so you can type avrdude commands from any directory.

Easy: Check to see that your dragon even responds. Use dragon_isp with avrdude:

avrdude -p atmega168 -c dragon_isp -Pusb 

You should get something like this:

avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.17s
avrdude: Device signature = 0x1e9406
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

Sometimes you have to hit the command a couple of times before the Dragon will start talking. You’ll hear windows make that little “dunk” sound as the Dragon resets itself, and if you try to avrdude it too quickly it won’t respond correctly. With the libusb driver installed and set to be the current driver you can unplug/replug as much as you want and it’ll always use the libusb driver. It won’t go back to Jungo unless you uninstall the libusb one and switch back manually.

If you get something like this:

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch
         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
         Using Port                    : usb
         Using Programmer              : dragon_isp
avrdude: usbdev_open(): did not find any USB device "usb"

That means you have usb issues. Check that the libusb driver is being used. Try replugging your Dragon and see if that helps.

For even more detail, use the -v flag on avrdude:

avrdude -p atmega168 -c dragon_isp -Pusb -v

You’ll get reams of data. Remember, this is for the Diecimila with the ATMega168. If you have an UNO or a Mega or something with the ATMega328 your results will be different.

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch
         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"
         Using Port                    : usb
         Using Programmer              : dragon_isp
avrdude: usbdev_open(): Found AVRDRAGON, serno: 00A200011176
JTAG ICE mkII sign-on message:
Communications protocol version: 1
M_MCU:
  boot-loader FW version:        255
  firmware version:              7.21
  hardware version:              1
S_MCU:
  boot-loader FW version:        255
  firmware version:              7.21
  hardware version:              7
Serial number:                   00:a2:00:01:11:76
Device ID:                       AVRDRAGON
         AVR Part                      : ATMEGA168
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no        512    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00
         Programmer Type : DRAGON_ISP
         Description     : Atmel AVR Dragon in ISP mode
         Vtarget         : 5.0 V
         SCK period      : 8.00 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.16s
avrdude: Device signature = 0x1e9406
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 0
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

Remember our little talk about fuses earlier? Take note of your fuse values (in my case, FF DF 00), as you’ll need them later to reset stuff. You can choose to have avrdude write them to a file, but it’s also good just to make a note somewhere.

If your Dragon talks to avrdude correctly with the libusb driver, you’re all set. Practice going back and forth between AVR Studio configuration and avrdude configuration for your Dragon.

You can also use avrdude to re-flash the arduino bootloader, in case you mess it up. Just change references to the dragon_isp and -Pusb for the configuration.

For example, for my Diecimila, and the Dragon programmer I use this, which also sets the fuses:

avrdude -p atmega168 -c dragon_isp -Pusb -v -U flash:w:ATmegaBOOT_168_diecimila.hex:i -U hfuse:w:0xDF:m -U lfuse:w:0xFF:m -U efuse:w:0x00:m

For just the bootloader, and no fuses:

avrdude -p atmega168 -c dragon_isp -Pusb -v -U flash:w:ATmegaBOOT_168_diecimila.hex:i 

Where the ATmegaBOOT_168_diecimila.hex is from the arduino bootloader directory in the Arduino IDE tree (in Arduino-1.0’s case that’s arduino-1.0\hardware\arduino\bootloaders), pick the right bootloader for your chip. Remember your fuses are probably different. Which is why it’s good to use AVRDUDE or AVR Studio to find them out and write them down before you mess with anything. The ultimate reference is your arduino boards.txt (arduino-1.0\hardware\arduino\boards.txt). If you’re too lazy to look there, there is this reference as well, but I note that one of my fuses is slightly different in my Diecimila. Look up what all the fuse codes do if you’re concerned.

AVRDUDE will erase all the flash as a feature of doing this, so if you had an arduino program on the chip it will also be gone when you re-flash the bootloader. When the Arduino is “empty” it sits there flashing the LED (pin 13) on the arduino board on and off.

Ladyada also has a tutorial on using AVRDUDE, where they talk about more of the options.

Install Arduino Support for Eclipse

This is the reason that this whole post is even possible. It used to be a huge pain in the ass. No stop, don’t do anything that article says. Instead take the advice at the top of it and go get this plugin instead. The full installation instructions are there on that nice person’s site. Thanks very much for that.

In short: in Eclipse, choose “Install new software”, enter his plugin repository address, and add the latest version of the plugin (1.2.1 as of this writing).



Now at this point you’re all set to do Arduino development in eclipse. You can write code in Eclipse, and upload it in Eclipse (via avrdude). There are some differences between doing development in Eclipse vs. doing it in the Arduino IDE. If you’re new to Eclipse you’ll find it has a shit-tonne of features and things that make you scratch your head. Also, code you develop has to be modified slightly to conform to the Eclipse CDT standards. This is detailed in the baeyens.it instructions. In particular Eclipse will throw out tons of warnings you never knew about for code that works fine in the Arduino IDE, because the Arduino IDE is set to compile with the warnings off. Warnings on is helpful if you’re trying to figure out problems, but if you’re new to the whole coding scene it will probably be pretty daunting to wrap your head around them. Also, the Eclipse ide still requires prototypes for functions, which if you’re written functions in the Arduino IDE you’re probably asking “What are prototypes?” I wouldn’t call using Eclipse for Arduino development a beginner’s task. Learn to do stuff with the Arduino IDE first. Again, the reason I’m writing this is because we want to move on to doing hardware debugging with Eclipse.

Install GDB Hardware Debugging into Eclipse

Most of this is similar to this setup for doing debugging with basic AVR chips, and not specific to the Arduino. I’ll give some specific setup points for integrating this with the Arduino plugin.

Here’s some more magic install stuff. In Eclipse “Install New Software”, and you can select “Work With: all available” sites. You will see a staggering amount of extra stuff you can install into Eclipse, only a fraction of which I even know what it does. What you’re looking for is GDB Hardware Debugging, so you can enter “gdb” into the filter box, and it will narrow the list down.

I didn’t install SimulAVR (the simulator), because I didn’t care about that. I also didn’t set up AVARice as an Eclipse “external tool” because quite frankly figuring out this debugging setup was more difficult that way. I found it much easier just to rely on running the WinAVR tools from an open command-line window.

Most of the settings are project dependent, so you’ll have to set them every time you start debugging a new project in eclipse, so I’ll go through that using some demo code.

A Simple Project in Eclipse

First off, make a new Arduino sketch in Eclipse using the Arduino plugin instructions. (File -> New Project)

Note that this will make two projects in your Eclipse tree. One for your test project, and one which contains the core Arduino code in a separate project meant for your specific Arduino board. In my case, the Diecimila. I called my project “ArduinoDebugTest.”

In the ArduinoDebugTest.cpp file, let’s use this code:

// Do not remove the include below
#include "ArduinoDebugTest.h"
#define LEDPIN 13
//The setup function is called once at startup of the sketch
void setup()
{
// Add your initialization code here
    pinMode(LEDPIN,OUTPUT);
    Serial.begin(9600);
}
// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
    digitalWrite(LEDPIN,HIGH);
    digitalWrite(LEDPIN,LOW);
    delay(1000);
    digitalWrite(LEDPIN,HIGH);
    Serial.println("I turned the LED on, off, and on again");
}

This code is pretty simple, because all we want is something simple we can use with the Dragon debugger to see that it works. It’ll flash the LED on the arduino board, then print something via the Serial porn on the Arduino.

Build this code with Eclipse (there are many ways to do this, including the little hammer icon on the toolbar, also right-clicking on the project). You’ll see in the console lots of messages go by as it builds the Arduino Core and then builds your program. If everything works out the final message will include the size of your code:

Device: atmega168
Program:    2568 bytes (15.7% Full)
(.text + .data + .bootloader)
Data:        232 bytes (22.7% Full)
(.data + .bss + .noinit)

That should look at least partially familiar, since the Arduino IDE also reports a size when it’s done compiling. Connect your Arduino board via USB to your computer and upload the code with Eclipse (the AVR upload button). Note that the Arduino Plugin very nicely sets up avrdude for you for the upload.

Here’s a fine point to remember: because you’ve modified this Arduino board to work with DebugWIRE, you’ve also lost the ability for avrdude (and the Arduino IDE, which uses avrdude) to auto-initiate the upload. So you have to be quick and push the reset button on the Arduino board when you start the upload. That will trigger the bootloader to look for a new upload for a couple of seconds, then it starts your on-chip arduino program. Timing is important. I find I can push the “AVR Upload” button, then immediately push the reset on the Diecimila and the upload works fine. You can see it works if the TX/RX led’s on the Arduino furiously light up for a few seconds. With the Arduino 1.0 IDE your timing has to be more precise because the IDE always does a build before the upload, so you have to wait until the build part is done – push the reset button – and then catch when the IDE’s upload starts. Also, in Eclipse you’ll see some status messages in the Console saying the upload is working and finishes.

After the upload finishes you should see the Arduino LED start to flash. Then start up the Arduino IDE’s serial monitor (or your favourite terminal program that you know how to get to talk to the Arduino’s usb-serial), and you should see this:

Congratulations, you’ve successfully gotten the code-edit-build-upload workflow working. Now the real fun starts. You can actually stop here and happily continue on your life using Eclipse for Arduino development and never have to bother yourself with hardware debugging.

Build your project with Debugging Info Available

With Eclipse, normally you have build configurations for “Release” and “Debug” versions. When you build for debug the compiler adds in extra symbols and shit which the debugger (GDB) uses to figure out just what the heck is going on in your compiled code, and trace that back to what the source code was.

I had issues making a “Debug” build configuration work with the Arduino plugin, and I think it’s because of the separate project for the Arduino Core that has to be compiled against. Headers would get confused and code wouldn’t build (“pins_arduino.h” kept getting involved, so something was wrong). So in the end I just elected to turn on debugging in the Release configuration and it works fine. The Arduino IDE normally does build things in debug mode (-g), and I think from the output the Arduino Eclipse Plugin is the same, so this may not make any difference – but I set some options to be sure.

In the properties for your project (not preferences for eclipse – these properties are stored for each project), go to the C/C++ Build Settings, and in the Release configuration (the only one which should be there) you want to turn on debugging information.

Normally it looks like this by default:

Change it to “Standard debugging info -g2” and “stabs (avr-gdb / insight)”. Do this for both “AVR Compiler” and “AVR C++ Compiler” to be sure.

(This may not make any difference, as the Arduino Plugin is already setting flags, but this makes me feel better).

After this you should rebuild your program, and upload it to the Arduino over the USB port.

If you have consistency problems with building, trying doing the “make clean” before rebuilding, as that will make it recompile everything. Computers are fast, you can wait the ten extra seconds.

Put Arduino chip into DebugWIRE mode

This is pretty easy, but very important. The Dragon can only debug in debugwire if debugwire is turned on in the AVR chip (duh). Problem is when debugwire is active SPI is not available, so you can’t leave debugwire on all the time. So get used to putting it in and out of debugwire mode.

To set debugwire mode, the easiest way in this workflow is to use avrdude to set the appropriate fuse. You can use the fuse calculator in eclipse, or one of a million online ones. You can also use AVR studio, but if you do this you’ll have to pop back to the Jungo USB driver, then back to the libusb driver to get anything more done.

In my case, the Diecimila’s regular hfuse setting is 0xDF (we saw that earlier with avrdude, remember?). To enable DebugWIRE the hfuse setting has to be changed to 0x9F. Use avrdude to change it:

avrdude -p atmega168 -c dragon_isp -Pusb -v -U hfuse:w:0x9F:m

Results are something like this:

Changing fuses:
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.16s
avrdude: Device signature = 0x1e9406
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DF
avrdude: safemode: efuse reads as 0
avrdude: reading input file "0x9F"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.16s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0x9F:
avrdude: load data hfuse data from input file 0x9F:
avrdude: input file 0x9F contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.06s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as 9F
avrdude: safemode: efuse reads as 0
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

To change it back, reset them to 0xDF:

avrdude -p atmega168 -c dragon_isp -Pusb -v -U hfuse:w:0xDF:m

You may have to do the operation twice, as avrdude might have trouble on the first pass and ask you to redo the command without powercycling. There is a “-c dragon_dw” mode you can use, but I find that avrdude is smart and notices the dragon is in Debugwire mode and switches as needed.

After you change the debugwire fuse state, you have to power-cycle your Arduino. You also might as well power-cycle the Dragon itself, since I have much more “first try worked” success if both get power-cycled.

Once you’ve enabled the debugwire fuse, the Arduino’s on-board bootloader will not work. SPI is disabled and so the bootloader doesn’t function correctly. So make sure you’ve got the correct code uploaded before you enable debugwire. Otherwise you’ll have to disable it, upload, then re-enable it.

Hardware GDB Debugging with the Dragon

If you found the stuff up until now not complicated enough, this probably will satisfy you. What we’ve done up until this point is essentially the same workflow as the Arduino IDE does. What we’re going to have to do now is change the build process slightly in order to accommodate GDB, which is the program behind all the debug session stuff we’re about to do. Then we’re going to find a really big pitfall, but more when we get to that.

Debugging is accomplished through GDB. Eclipse talks to GDB. GDB knows how to talk to AVARICE. AVARICE is the program that knows how to run DebugWIRE on the AVR Dragon. The Dragon is the board that talks via DebugWIRE over the ISP cable to control the execution of code on the Arduino board. Make sense? We have to get all these layers to talk to each other correctly or none of this shit works.

We’ll start on the Eclipse end. Start by making a new “Debug Configuration” in Eclipse (click the arrow next to the little picture of the bug, a couple of squares to the right of the hammer… sigh). A dialog starts up with a bunch of C/C++ options on the left side. Click and add a new configuration on the one called “GDB Hardware Debug”

Then we’re going to march through the tabs on this debug configuration.

First thing is in the “Main” tab to pick your .elf file, which is the compiled code used by the debugger which has all the symbols and shit in it. When I use this with the standard AVR development plugin it auto-inserts the proper .elf file for me, but with the Arduino plugin you have to navigate to your Arduino Eclipse workspace and select the .elf by hand. No big deal.

Set your GDB command to be the avr-gdb.exe in the WinAVR directory. You need to change the preferred launcher to the “Standard GDB Hardware Debugging Launcher” down at the bottom of the dialog window. I couldn’t make this work with the DSF launcher. You can tell you’ve got the right one because it has the option for “protocol version: mi” as shown. I change the port number to 4242, only because the original AVR Debugging article does that.

Then in the “Startup” tab have the setup as shown. Note this is different than the AVR debugging article setup. In particular rather than break on “main” we’re going to break on “setup” since in the Arduino version of the world the “main” is hidden. Turn off reset, halt, and load image (I couldn’t get it to work anyway). Turn on load symbols. I don’t make any changes in the next two tabs (source, common) so you can leave those as is.

Once you’ve got all the settings done, you can click “Apply” and close the dialog. Don’t bother trying to start “Debug” yet, because we need to get AVARICE running.

Running AVARICE is pretty easy. In a command window:

avarice --debugwire --dragon --ignore-intr :4242

If your Dragon is connected properly, you have libusb active as the driver, and your chip is in DebugWIRE mode. you’ll see this:

AVaRICE version 2.9, Jan  7 2010 22:42:57
JTAG config starting.
Found a device: AVRDRAGON
Serial number:  00:a2:00:01:11:76
Reported debugWire device ID: 0x9406
Configured for device ID: 0x9406 atmega168
JTAG config complete.
Preparing the target device for On Chip Debugging.
Waiting for connection on port 4242.

If you get an error, check that you’re using libusb. Also in most cases just cycling the power on both the Dragon and the Arduino puts it back to working. If you give avarice a -v flag for verbose it will constantly spit shit out for you to read and not be interested in as you debug.

Are we there yet? Start the Debug Session

Okay, with your eclipse debug configuration set, debug-enabled code uploaded to the arduino, debugwire enabled, and avarice up and running and waiting for a connection, it’s time to start up the debugger. Click the little bug and select your debug configuration. It will want to change “perspective” on eclipse to show the debug windows, go ahead. It’ll also rebuild your code, but don’t worry about that, since it should be the same version that’s on your arduino already (right?).

if you look at your command window, you should see AVARICE has hooked up with GDB:

Connection opened by host 127.0.0.1, port 4951.

and ta-dah, that’s really it. Because you set the breakpoint for “setup” the code initialized and stopped at the beginning of your setup() routine. Now you can use the single-step commands in the toolbar to march through your code. When you end your debugging session AVARICE will quit, so you need to restart that before you restart debugging. The chip will remain in debugwire mode so you’re all set.

So now, you’re debugging, is it what you expected? Arduino’s success as a platform comes from the fact that the hardware is cheap, the IDE is easy to use, and the Arduino Core is a shitload huge library of awesome functions that make coding for it easy. If you use the “step into” command you’re going to be buried under the mountain of code that goes together to make your own Arduino code run, which will get pretty tedious, and you normally don’t have to debug yourself anyway. Also, timing based things (delay(), sending serial stuff) is going to get seriously broken if you try single stepping through it. Your friend in these cases is the “step over” command in the toolbar, which essentially says “run this whole command, including any subroutines, and come back after you’re done since I don’t want to see any of that single-stepped”.

As the exercise, you can single-step (step into/step over) until you get into your loop() routine, and then you can use step-over each of the digitalWrite() commands, and you should see the light on the Arduino change accordingly. When you hit the delay() and the Serial.print() you’ll want to use step-over unless you’re not bored enough single stepping.

You can set breakpoints and use the “resume” toolbar icon to say “just run until this line gets hit, then I’ll start stepping”, which can be useful if you have a lot of code that runs before your routines you want to debug are executed.

You’ll find your code keeps jumping out to this previously-hidden main() routine, which is how C/C++ actually works, so you just have to step through that back into your loop() code each time.

Also debugwire disables SPI, so if you were hoping to use this to check SPI hardware, I’m afraid you’re out of luck. Back to Serial.print(), or using something like a logic analyser (I have the Salae one).

To get back out of debugging, there’s a red button on the toolbar called “terminate”.

Note that when single-stepping it can take a seemingly long time between steps, because GDB/AVARICE/Dragon is doing a lot of talking amongst themselves getting status from your chip. I believe every time the single-stepper stops the Dragon dumps the entire contents of the Arduino’s ram for display by GDB/Eclipse. You do get lots of fun light flashing on the Dragon during all this, though.

Optimization Can Be a Bitch

The sample program above didn’t have any variables, on purpose. When you’re debugging in Eclipse one of the windows shows the variables in your program, which is – in my opinion – the best part of debugging. It lets you spy into the variables and see if variable “a” is really holding what you think it’s holding. I didn’t use any variables for illustration above because it wouldn’t have worked right, here’s why, and here’s how you work around that.

The Arduino is an embedded platform with limited ram and storage (flash). The Arduino people (correctly) turned on size optimization in the Arduino’s compiler. Optimization is big topic in compiler design, and it essentially boils down to “the user wrote this code to do this task, and as the compiler I will re-write it to make it work faster/better/smaller”

The problem with debugging optimized code is that… well, it’s different code than what you wrote. In particular, the size optimizer (-Os) on GCC will do some amazing stuff like “you set this variable, and never used it, so I removed all references to it from the actual compiled code.” There’s also the general case of “oh, you didn’t have a lot of variables, so instead of keeping them in ram I kept them in registers instead for easier access.” Variables held in registers tend not to show up in the “variable” window so you can’t spy on them, you have to go look at the registers directly.

Let’s do a little experiment to show this. Make a new Eclipse Arduino Sketch called ArduinoOptimizerTest and use this code in your .cpp file:

// Do not remove the include below
#include "ArduinoOptimizerTest.h"
//The setup function is called once at startup of the sketch
void setup()
{
    Serial.begin(9600);
}
// The loop function is called in an endless loop
void loop()
{
    int a;
    int b;
    a=25;
    b=a+a;
    Serial.print("a is ");
    Serial.println(a);
    Serial.print("b is ");
    Serial.println(b);
    delay(1000);
}

Now this is a damned boring program. It stores a number in a variable, does some math, and prints it out. Yawn. You don’t need an Arduino for this, but we will do this to show just how much the Optimizer works to make you a better person. To show we’re not cheating, build this with the debugger info set, load it onto your arduino, and check it with the serial monitor to see that it does give output. (“a is 25” “b is 50” over and over).

Easy, it worked, right? This is a stupid experiment, right? So now go into debugging mode with the Dragon. Put the chip into debugwire mode, do a debug config, and start debugging in Eclipse and have a look at what’s going on.

Oh shit, check it out. See when you ran your program and single stepped it… it never ran the a=25 / b=a+a lines, for some reason the single step went right over them to the Serial.print() line. Why did it do that? Well, check the disassembly window on the right hand side. The Disassembly is the “these are the actual machine code instructions GCC compiled your code into and are running on the Arduino.” It’s a lot of strange looking little single-purpose instructions but you can see how your code has been translated into the machine code.

See how it says “loop:”, a couple of push r16/push r17 and then the instruction pointer for “Serial.print” is that “ldi” instruction? The GCC -Os optimizer said “you know what, you set those a and b variables, but never actually use them other than to do that print, so we just skipped all that and moved it all into the print call itself. The code was simple enough that the optimizer optimized it all away. The results are the same, but the execution is different than you expected.

Note that this is not actually a problem, this is a good thing. It means the compiler is looking out for you and trying it’s damnedest to make your code fit in the limited Arduino space and still do everything you want. It does mean that if you’re stepping through the code you may get surprised.

As an aside, many many many years ago when I was writing unix code on Sun systems you could not debug optimized code at all with the debugger. You had to debug with the un-optimized code only. So if you had a bug that showed up when optimized, but not when un-optimized, you were really shit-outta-luck. It was the best thing evar(tm) when GCC started doing enough work to let you debug stuff that had been mangled by the optimizer.

So okay, as an academic exercise now, what if you want the “pure” code you wrote to debug, and not the optimized version? Easy. We go back into the project properties and turn off the optimizer (-O0 instead of -Os for both the AVR Compiler and AVR C++ Compiler).

Then you have to rebuild – right click your project and do “make clean” first, to make sure all the code gets rebuilt without optimzations. When your build finishes you’ll see that sure enough, your code is larger than when it was built with -Os. You could get a problem where the code could be too big to fit in your Arduino, but in this test case it’s still okay. Upload the code to your Arduino (remember you’ll have to take it out of debugwire mode to do that, then re-enable debugwire again), start up AVARICE, start up the debugger, and here’s what you’ll see:

See that the instruction pointer will actually be able to land on the “a=25” line, and the disassembly shows that there’s actual code assigned to it now. You can also see the disassembly directly for each of the instructions that follow (a shit load of instructions to do something that seems simple, isn’t it? This is why the optimizer works so hard for you).

In the two screenshots you can also see that “a” and “b” were set to some random values before being initialized, which is the reason you initialize variables.

Remember to re-build your projects with optimization on (-Os) again if you’re going to continue.

If you’re doing all this on Linux, you don’t have to worry about the libusb steps, since avrdude/avarice work on linux just fine with the default ubuntu install. Also there’s no AVR studio for linux, so hey, no having to deal with that end at all. Just remember how to set your chips back to factory with avrdude if you mess things up.

Condensed Version

  • Write Code in Eclipse, build without errors
  • Upload to Arduino over usb-serial in Eclipse
  • Enable DebugWIRE on Arduino with AVRDUDE
  • Start AVARICE
  • Configure and start up debugging in Eclipse
  • Debug until your eyes cross
  • Disable DebugWIRE when done

Summing Up

So this works for me, maybe it will work for you. Is it easier than debugging using my previous method with AVR Studio? I guess that depends on how much you like Eclipse.

Is this any better than debugging using AVR Studio? Not sure on that one yet, I’m still investigating doing the debug with AVR Studio 5.1. Certainly less toolchain setup in that case. Using Eclipse in the mix does give you better diagnostics on code errors than using the Arduino IDE, at the cost of more complexity.

Is any of this easier than just using Serial.print() statements? Hell no. But if you really can’t figure out why something’s not right, this might be the best way.

Finally, here’s another Arduino picture, as required by law.

Really, that's all folks.

Summary Execution of 2011

Last year I wrote up a big nothing about the stats here on my repository of garbage. This year I figured I’d do something similar but I’d dial it back a bit.

First off, here’s the top viewed stuff during 2011.

Post Title Views
Modify an Arduino for DebugWIRE 4,952
(Yet Another) Sparkfun SerLCD library for Arduino 1,291
The Arduino Duemilanove with ATMega328 and that Reset Line 710
A Minimal Arduino Library for Processing Serial Commands 654
An Arduino Library for the ADT7310 SPI Temperature Sensor 478
So, you want to move to OSX Lion. 448
An Arduino-Based MIDI Wah Controller for Logic Pro 375
Using the Sparkfun Speakjet Voicebox Shield with an Arduino in Passthrough mode 268
A Too-Simple Arduino Library for Handling the Seeeduino Relay Shield (and Generic Relays) 257
Recovering Installed Firefox Extensions (i.e. – Socialite) 150
You don’t give a shit what I think of Duke Nukem Forever, and neither do I. 129
Don’t get Lien’d on in New Brunswick 118
Dark Sparkling Crystals 88
Why iBooks Sucks 79
Easily Melted 79
Pay No Attention to that Crap Behind the Curtain 69
Get yer mail from Thunderbird into GMail in Zero Steps 54
Late to the Party 50
Torchwood: Miracle Day Review and Analysis 46
Invalid Opcode at 0027 with Spinrite 45
Loop it through Jones 44

It’s no surprise that the “do my homework for me” posts are top of the list, as usual. Most people reading the OSX Lion post are either (a) trying to get it to run on their G5 (it won’t), or (b) trying to find out how to pirate it (pay the $29 you cheap fucks). The first music-related post you get that’s on the list is Dark Sparking Crystals, and the problem is those aren’t even real stats.

This year was the year of wordpress referrer spammers. I won’t go into the details of referrer spam, but essentially if I were to look at my stats for things, this is the sort of bullshit I’d see.

I even went as far as to change the url of Dark Sparkling Crystals (see what the url is there), and that didn’t have any effect. I’m sure if you’re a big time famous blawg that these things barely show on your radar, but in my case most of 2011 is made up of referrer spam.

The next highest musical bit was from Easily Melted, which was just a case of mistaken identity. Easily Melted – which was published in August 2009 – got a big bump in August 2010 from people searching for (natch) “Easily Melted.” I figured it was some political thing, given the results I see when I search for “easily melted”.

Late to the Party makes the list again as the post that’s the “next” post from the DebugWIRE post. People surf in to try and get the DebugWIRE post to do their homework for them, click the next, have to see Merlin Mann, then quit.

So yep, of the new music done in 2011. The most poopular was Loop it through Jones. The sad part of that was that unlike everything else I make, The Dolphin was the one piece of specifically crapped together just by tossing apple loops into an assemblage. That was a reaction to the accusation that all I did was “stick apple loops together” (which I don’t), and sure enough it becomes the most poopular. I can’t win.

You have to go a bit down the list to find the first original music post, and it’s The Rampart Part 1 from Rampant in the Carpark (35 views), which I think drags a lot of people in searching for “Reaping previous system.” The next one is XMESSTWOZEROONEONE from Tis the season to cash in (28 views), and think that’s because this blawg’s only reader Scott Redman pimped it out a lot before xmas.

I won’t bother detailing out a list of results like last year, but suffice to say that the median number of views for a musical post is 7.

I didn’t really get any fun search terms this year. Just things like “caustic soda instructions”, “steven cogswell asshole”,people with homework to do, and lots and lots of people looking to pirate osx for their G5.

The all-time champ for music is still 2009’s The X Stands for CASH (2009’s xmas bullshit). Now runing at 90 view.

The most popular downloads are the schematic from the “do my homework for me post” (420 downloads, which I’m sure is ironic), and the second being my SerLCD arduino library (225 downloads). I suppose it’s a mark of achievement when I find my libraries being reposted as other peoples’ work. Sigh.

So what about other things? This year I continued with Radio Reddit, which near as I can figure is pretty much dead. It overflows with people submitting music and nobody actually listening.

This year I submitted “Boardozer” and “Thumbtack”, and here’s my to-date-since-joining-Radioreddit stats. Last year’s AWXMASFY submission never got approved, so I never bothered trying submitting this years xmas crap.

I bet if you were to multiply the number of plays through by the number of listeners the results would be pretty poor. Also, nobody ‘submitted’ my music for voting this year – which only exemplifies the lack of interest in Radio Reddit.

I also bought “ad space” on Radio Reddit for two months (not to promote myself, for someone else) and while the Radio Reddit guys were really good at taking my money, I got zero communication from them. I was supposed to get statistics and such and got nothing. I emailed, I submitted questions and nobody would get back to me. So I gave up on that.

Back in September 2011 I joined Soundcloud, as it was the one site that will let you embed a player on a wordpress.com blawg. From the stuff I see people can’t figure out how to use the wordpress audio player. (Hence my Public service announcement for dorks). I thought maybe the Soundcloud one would be a little more obvious.

Soundcloud is pretty easy to use. The problem is their business model doesn’t fit for guys like me with tons of hours of material. The “Solo” level costs me €79 a year, and still “only” gets me twelve hours of storage space. The 2009-2011 stuff comes out to about 16 hours as it is, without counting what I call “the old music”. Hence I didn’t put any of the 2009 or earlier material on Soundcloud. The next tier up is a mind-numbing €131 a year, and I ain’t payin’ that much just to contribute to my loser hobby.

Soundcloud’s stats are flat-out confusing, and at one point there was a post from them acknowledging they were wrong. I’ve never been able to make sense of their charts. Here’s the best I can get you:

The problem with Soundcloud is that – unlike wordpress.com – if I look at my own stuff, even while logged in, it counts it as a view. So I have no clue how much of that is me, or is someone else. Pro tip: if you’re looking to game Soundcloud, you’ve just seen how. Most of Soundcloud seems to be made up of people who toss loops together and call themselves “DJ’s” anyway.

I did get a bit of hate mail this year, which I won’t bother talking about, and I did get one ‘thanks’ for the “help me do my homework” post. So, thanks. Scott Redman remains the only regular listener, near as I can tell. Scott’s a great guy.

I didn’t make it onto No Agenda this year, but I did make a new theme to replace my old theme for Starbase 66, the international Starlost podcast. I had a bunch of stingers show up on Here Goes Nothing, and For Those About to Rock, but it’s doubtful you would have noticed those unless you were on the lookout. My post on Duke Nukem Forever was enough to get me an appearance on a plodcast – which then got cancelled. I also made a terrible appearance on Starbase 66 #100, for some reason I haven’t figured out yet.

This year I tried to avoid doing as many “cover” pieces as I have in years past, since they just invite complaints. I did still manage to put a couple in, however. No lawsuits yet. From my own stats, Schwarzchild Radius, Boardozer, and The Rampart Part 1 were the ones I listened to myself the most. I did like the bit starting around 5:00 in Undisputed Wavyhate Champion (what a terrible title that is), and Last Drink Before the Abyss I think manages to mesh my amateurish ukulele playing with the rest of my amateurish playing. Will You was so well received someone thought it was a joke piece I’d ripped off from someplace else. Oh well.

Summary: 2011 sucked ass, but at least I didn’t smash any bones up this time. AWTFY.

Let’s Put 2011 in a Box and Burn It.

And With That, the end of 2011’s disastrous run of music comes to a close. As is the tradition (2010, 2009) I’ve bundled up all the garbage of the last twelve months and stuck it into a single archive so that both people who read this can download it. You can still listen and download individual tracks from the 2011 music page, on Soundcloud or Bandcamp.

According to my expert calculations this year’s stuff clocked in at four hours, forty-seven minutes and forty two seconds. Slightly longer than 2009 – for which I only published for about half the year, but quite a bit short from 2010, which was just over seven hours. As I was famously told once, it’s hard to get up when you’re standing on my neck.

There’s nothing new in the archive that wasn’t in the previously-available download. Don’t bother downloading it thinking you’re going to find l33t crackz or keygens in it.

You can download the archive here (521 MB). me.com go bye bye

Maybe you can download the archive here (521 MB). (Mirror which will also go away) Those went away, as expected

The MD5 is cb39faabd9247157efab6c32c4a0da1d. You still don’t know what MD5 is, and I still don’t care. Apple’s me.com is going away, and so this archive will be unavailable from me.com after it goes away, because that’s what going away means.

Update:If you were really, really dying to have this in an obscure or lossless format, well then you want to go to Something or Other on Bandcamp, where you can get that. It’s still free.

This year’s cover was again designed by Ro Karen, who spent more effort making this cover than I probably did making anything to go with it.

Speaking of not caring, as usual the licence (license) for this is the same as always, some Creative Commons mumbo jumbo that you’re not going to bother adhering to.

Creative Commons License

Yes, everything is free. Yes, you can download it for free (even the lossless Bandcamp version). No, you don’t need to go try to find it on the pilates bay because it’s for free right here. If you want to do something with your money give it to Ro Karen or your local animal shelter. I know, you won’t, because you’re so poor. Since I’ve not charged you anything, I’ll not entertain any complaints about how it doesn’t play on your ancient computer or it isn’t ogg vorbis or I haven’t provided you with source code so you can run it on your hipster coffee machine. I’ve already made a lot of snide comments about people’s inability to follow simple instructions in the previous years’ roundup archives, so if you want better jokes go read those.

As I did last year, if you send me a request I’ll mail you a disc with everything on it.

Note: number of requests for discs I had in 2010 was zero (0).

Invalid Opcode at 0027 with Spinrite

I’m only making this post because if you’re searching the intarweb for the answer to this like I did, this is probably it.

I was trying to use my copy of Spinrite 6 on someone’s computer to resolve their bad hard drive issues. This was a Dell XPS430. When you would try to start Spinrite from the cdrom drive you’d get this strange error:

Invalid Opcode at 0027 0004 0293 0073 0000 0000 F800 01E1 6800 728E FFF0 76F8 51E2

Which is not helpful. This turns out to be associated with the RAID controller on the XPS430. Spinrite can’t work with the drive(s) with the RAID controller active. Go into the BIOS setup (F2 at startup), and turn off the RAID controller. Then Spinrite will start normally and let you work on the drives. Remember when you’re all done to turn the RAID controller back on before you reboot back into Windows.

That’s it. Hope this helped you.

More on the Speakjet and TTS256 Chip

As fun as it is to use the Magnevation Speakjet shield for the Arduino, perhaps you want to do an application where you don’t want to have to program all those stupid codes, as I showed in an earlier post.

At that time I mentioned the TTS256 chip from Sparkfun, which is essentially a little text-to-speech dictionary chip made to work with the Speakjet. You pump in some regular boring text over the serial connection to the TTS256, it converts it to that phoneme stuff and presto, the chip speaks.

At the time I did that previous post I didn’t have a TTS256, but now I do. Sparkfun have a very nice tutorial on how to wire up the chip into your Speakjet shield. That tutorial is really good, and has demo code and so I will repeat none of it here.

I followed the instructions as shown and had no problems, but the difference to what I did is that rather than solder the speakjet onto the shield, I soldered on a 24-pin socket (technically two sockets, since I didn’t have a 24-pin, but the effect is the same). The advantage of doing things this way is that if you want to go back to the ‘old’ way of using the Speakjet – in direct phoneme mode – all you have to do is jumper two areas in the socket and it works as it did before you ruined it.

Seriously, always use a socket with a through-hole part if you can get away with it. Makes replacing the chip a dream when you blow it up.

I have the ‘newer’ version of the board which has the surface-mount version of the speakjet (the tutorial has the through-hole version), but the pins are the same so the locations of the solder points don’t change.

Also, the sparkfun pictures are good but aren’t so clear where the connections are, so I tried to take some clearer pictures.


Don’t lose your shit when you lose your shit.

Ever had your laptop stolen? That would suck, wouldn’t it. It’s pretty inconvenient to be without your facebooks and your twoofters, sure, but what’s really inconvenient is all your information getting into the hands of some thieving bastard.

Sure, in most cases people who steal your laptop are going to just sell it to some pawn shoppe for crack or linden dollars. In lots of cases they’re just bozos and take it home and start using it themselves. The problem is that if you’re like most people, your personal info is still on that machine for them to access.

I’m not thinking of stupid stuff like those ‘pictures’ of you and that guy’s wife, or all your l33t torr3ntz of Master Chef. I’m talking about stuff like your banking passwords, your email passwords. Use Firefox/Chrome/Internet Asploder? Do you have it ‘save passwords’? You’re screwed. Have your email program remember your password? You’re screwed. Lose your laptop and in a short time, a determined thief can clean you out.

What about your iPhone? Your Android phone? Same thing. There’s the inconvenience of having your shit stolen (or just lost), but the terror knowing that all those camera phone pictures of you and that guy’s dog wife are loose and in the wild.

So take some steps to keep yourself from freaking out.

You have to do these steps before you lose your stuff. Don’t do it after because that would be stupid.

Backups

I’ve been harping with you miserable fucks for years now to make backups, and you still don’t. This will also have the side benefit of saving your ass if your hard drive dies or you just accidentally drop your laptop off a bridge.

You have no excuse. Backup and Restore is built into Windows 7 now, and those insufferable mac people have had this for a while as well. You don’t have to do anything, you just need to set that shit up. Set that shit up already.

Disk Encryption

Yes, encrypt your damned hard drive. If you’ve got a portable machine that people can walk off with, you want to do this.

Using Windows? Then use Truecrypt or Bitlocker and enable the “whole disk encryption”. Using a Mac? Turn on Filevault for fuck’s sake. The Filevault in OSX Lion will encrypt the entire drive, and Filevault in 10.6 and lower will encrypt your home directory and make it safe. These are Free.

Yes, you can even do disk encryption in Linux. Don’t worry, nobody wants to steal your linux laptop.

The nice thing about using disk encryption like this is that it takes almost no effort on your part, you spend a few minutes clicking the mouse (I know that’s hard for you), and it’s done. Then all you have to do is remember your damned password.

Passwords

This one is kind of simple. If you have a computer, set it to require a password to log in. Sure, if you haven’t encrypted the disk it’s fairly trivial to bypass that, but look at who most thieves are: morons. They aren’t going to try to beat the password, they’ll just move on. It also keeps casual people from poking at your shit.

For your other passwords, use something like 1password, Lastpass, Keepass, or Supergenpass or even the built-in sync in Firefox and Chrome to manage your passwords. That way you have them synchronized off that laptop, and you can systematically go and change all your passwords – which you should do if your laptop gets stolen.

Scorched Earth

Here’s where you break out the heavy artillery. Remember you have to set these up before your shit gets stolen. If someone steals your iPhone/Android/Mac/PC, you want the ability to either

  • Get it back (unlikely)
  • Prevent them from using it

If you’ve encrypted the drive, don’t have an easily guessable password, and haven’t written it on a sticky note inside the case lid, that will probably do the job right there. The thieves’ only recourse will be to format the hard drive (destroying your data, keeping it out of their hands).

There are several solutions to tracking down your lost stuff, which is especially important for iPhones/Android phones, which can be pretty trivial to break into. For the iPhone it comes free with the phone: Find my iPhone is a service you had to pay for MobileMe to get, but is now free. Set this up right now. It lets you track the phone’s location (also good if you’ve just lost it behind the couch), put messages on the screen (“give me back my phone you knob”), or – most useful – wipe the phone from remote so nobody can get at the stuff on it. Then your phone just becomes another black market phone for drug dealers and terrorismists.

I don’t have an Android phone, but there are solutions for Android including Prey for Android. I’m sure you know a hundred better ones, and I don’t care.

For the laptop, there is the Prey Project, which is free for three machines – you can pay for more if you’re filthy rich and own so many computers. Prey will let you shut the machine down, get pictures from the webcam of the thief, location, etc. It’s free – so why the hell not? There are other solutions like Lojack, but I have no experience with them. I’m sure you’ve used a hundred better ones, and I don’t care.

Let’s face it: if you go to the cops with the exact location of the criminal, his picture in a mug shot, and him holding up a big sign saying “YO DAWG I STOLE THIS GUY’S LAPTOP”, that’s still not going to be enough to get cops to get off their donut-eating behinds to come out and do something about it. I have first-hand experience with this aspect of law enforcement. So the next best thing is going to be just being able to shut down and wipe the machine from remote to keep their grubby mitts out of your stuff.

The point is, setting up this stuff is easy, and is well worth it for the peace of mind you get when your shit gets ripped off.