avr-libc – Realloc bug

January 30th, 2009 § Comments Off on avr-libc – Realloc bug § permalink

A few months ago I proposed a refactor for the Arduino RepRap firmware. I was quick to code it up and build test cases on the desktop, then ported to the Arduino… Where it failed miserably. There the code languished as I spent time on it here and there. I attempted getting SimulAVR working, but it doesn’t support the Arduino chipsets (thought about adding support). I tried AVR Studio in a bootcamp’d windows install, but it kept hanging when debugging this problem. As a last resort, I ported the avr-libc memory apis to the initial desktop refactor, and was able to see the problem clear as day. I spent some time reducing the repro to the smallest form:

void testMalloc()
    size_t* array = (size_t*)malloc(4 * sizeof(size_t));
    array = NULL;

    array = (size_t*)realloc(array, sizeof(size_t));
    array = (size_t*)realloc(array, 2 * sizeof(size_t));
    array = (size_t*)realloc(array, 3 * sizeof(size_t));
    realloc(array, 4 * sizeof(size_t));

There is a bug in the free list manager in Realloc, specifically when growing a buffer into the next free entry. I was convinced I had a bug in a fairly large codebase, and whittled it down to this reproduction. I’m now playing with a couple of fixes, but need to figure out how to get a ‘blessed’ fix into lib-avr.

Stepping through the malloc into the free results in:

00000010 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000

Over the first realloc:

00000008 00000000 00000000 00000004
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000

Over the third:

0000000c 00000000 00000000 00000004
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000

And finally:

00000010 00000000 00000000 00000004
00000000 FFFFFFFC 00000000 00000000
00000000 00000000 00000000 00000000

At this point the free block pointer (__flp) points to the second line, with a size of 0xfffffffc. The next allocation fails.

Arduino for TextMate posted (beta)

January 12th, 2009 § Comments Off on Arduino for TextMate posted (beta) § permalink

I’ve added a page for the Arduino for TextMate plugin. Download from the dedicated page.

When we last left our hero…

January 11th, 2009 § Comments Off on When we last left our hero… § permalink

The problem with multitasking is that your time is divided amongst all the projects you have going on. Not only divided, but context switching has overhead. Because of this, and the limited shop time, I haven’t made much progress on any one area to warrant separate posts, so I’ll recap.

Cold Garage


The Cool Tools blog had a recommendation for the Dyna-Glo pro heater. Their usage was similar to mine, so I decided to try it. I have to say – while it heats up the place in no time, it is loud and smelly. But the garage is now usable until I can insulate it and install something more permanent… (Although my father says “There is nothing more permanent than that which is temporary”)

Grid Beam Bench (and experimental cartesian bot?)

At Maker Faire last year, I came across a neat display about Grid Beam. Basically this is a large scale wood erector set which involves 2×2 sticks of standard lengths, with a repeating hole pattern. These beams are joined using furniture connector bolts. By joining 3 beams together, you create a very strong ‘tri’-joint, which not only is self squaring, but creates a very rigid body. In fact, it seemed more rigid than the plastic and aluminum joints I currently use. Could I use a wood frame for the cartesian bot?

A book was released a few months ago; Half of which is an anthology of grid beaming, the other half goes into a little detail about assembly. You can get it from New Society publishers: 


Using the lathe and mill has been slowly destroying my detail bench, where I do the electronics work and debugging. Task switching between metal work and detail work also slows down the whole process, so I decided to build a ‘dirty’ bench for the metal and wood work. It seemed like a perfect opportunity to try out Grid Beam building techniques.

My first foray into Grid beam stick construction were failures. There is no margin for error while cutting the holes, as errors propagate down the stick pulling them out of square very quickly. In order to drill accurate holes, I built a jig:


This is mostly a standard drill press jig. The main difference is in the holder – there is a custom delrin tapered plunger, which aligns and holds the beam prior to drilling. I’ve only drilled these sample beams for testing, so we’ll see how the hold thing goes together. I’ll post separately on this progress.

Arduino Plugin for TextMate

The arduino plugin for textmate has been taking much more time than it should. I’ve almost completely rewritten it in order to clean up the code, refactor based on ‘learnings’ about Cocoa, add multiple Arduino support, and allow the serial monitor to stick around while compiling and uploading. Many of the issues I’ve encountered were specific to TextMate (such as NSConnection issues), and some Leopard problems (NSConnection doesn’t like being created on two different threads). However, I’m tracking down the last issue (If you shutdown the serial monitor, you cannot restart it without restarting textmate. NSConnection doesn’t seem to have a way of saying is the server still alive). Expect a beta by end of the weekend.

RepRap firmware refactor

I had worked on a design and implementation of Arduino design patterns which I will leverage in the Refactor. However, I hit a bug which doesn’t reproduce on the desktop test client, so I believe it is a specific problem with the Libc on the Arduino. That project was put on hold until I got the hardware debugger.  I have it now, and it will be the first thing I work on after I release the new Arduino plugin.

Hercules Extruder

With Shop time limited, this has bubbled down the list. Since my implementation depends on the Firmware refactor, it didn’t seem a high priority.

The Prometheus Fusion Perfection blog has developed a laser cut Herk extruder. It looks VERY sweet:

Laser cut Herk

(If that person emails me their address, I’ll send a milled stainless steel barrel and extruder head.)

Laser cut Hercules Extruder

December 21st, 2008 § Comments Off on Laser cut Hercules Extruder § permalink

The Prometheus Fusion perfection blog has started working on a Laser cut Hercules Extruder. It looks pretty cool. I hope that the plastic can withstand the pinch forces involved with this. Keep an eye on it. 

(I’d love to give credit to the author of it, want to send me your name? I couldn’t find it on your blog).

Pillars of Hercules

November 28th, 2008 § Comments Off on Pillars of Hercules § permalink

Here’s an updated Sketchup (for the new version 7) for the Hercules extruder.

The compact design of this extruder lends itself to stacking. By stacking two extruders, you can print with multiple materials. Why would you need two materials? A printed object at the very least needs a ‘raft’ – a lower fidelity flat area to which the object prints.

The first layer is in contact with the elevation system, which is of a different material than the object. This causes the first layer to behave unpredictably. Further layers become more consistent and allow higher fidelity strands to be laid. Objects with overhangs also need support material. In order to separate the support and raft material from the final object, you can print with different materials such as HDPE for the raft and ABS for the object. You could theoretically use two different temperatures for the raft and object materials.

I call this stacked extruder Pillars of Hercules

Here’s the sketchup of the Pillars of Hercules extruder

(I have no intention of building this anytime soon, it was just a fun exercise while crashed on the couch sick as a dog).

Tetrix available for pre-order!

November 28th, 2008 § Comments Off on Tetrix available for pre-order! § permalink

Saw this kit at Make Faire in May – Metal Technix. Plastic gear trains have their limits, I can’t wait to see what people build with this stuff. The cool thing about this metal kit is the technix connectors which allow you to interface with the plastic lego components.

Arduino for TextMate 2.0 (coming soon)

November 22nd, 2008 § Comments Off on Arduino for TextMate 2.0 (coming soon) § permalink

I’ve been working on an update to the ‘microcontroller’ plugin for TextMate. I’m putting the finishing touches on the release, and want it to bake. So far, it has the following changes:

  • Dropped the Make Controller and renamed to Arduino. This was done because I use Arduino exclusively, The Make controller doesn’t work on Leopard (without some nasty hacks) and it complicated the code-base.
  • The Serial monitor was rewritten. It is now a cocoa console app, uses cocoa remoting to allow the TextMate plugin to control the serial monitor – such as releasing the device during a compile and upload or changing the port speed
  • Support for multiple port speeds
  • Support for multiple Arduino (Arduinos? Arduinii? more than 1 Arduino)
  • Sanguino support
  • Stability improvements and bug fixes
  • Independence from Arduino releases
  • Exclusive support for the Objective Development AVRMacPack

Further, I’ll be creating a top level page for the plugin, and maybe releasing an ANSI graphics update to the arduino sources – allowing the arduino to provide rich graphics via the console.

Herk Extruder 1.1

November 19th, 2008 § Comments Off on Herk Extruder 1.1 § permalink

After accidentally destroying the motor controller and motor, I needed to rebuild the extruder. This is the result:

After the failure of the captured gear drive, I went back to the original pinched pulley mechanism – upgraded to the larger higher torque motor. One of the things I wanted to enable with this mechanism were:

  • Improve the tension pulley stability.
  • Enable adjustments between the tension pulley and motor spindle in order to test different pulley sizes
  • Enable adjustments to the extruder barrel – both vertically and horizontally

I achieved the first point by making the tension pulley mounted directly to the backplane. The motor itself adjusts horizontally opposed to the tension pulley. This arrangement also allows me to test larger drive pulleys.

The barrel needs to adjust horizontally to match up with the center point of the pinch pulley mechanism as I test different sizes. I also wanted to adjust vertically to close the gap between the barrel top and the pulley pinch point.

The remaining plate is used for mounting to the cross slide, and enables me to implement a dovetail mount at a later date.

Now that the machining is done, I’ll wire it up. Additionally, I’ve been working on the software to drive it. (FYI: New TextMate microcontroller plugin drop is coming, with lots of new features and bug fixes)

(Please ignore the machining errors – still learning how to mill)

Captured Gear Drive Conclusion – Too Complicated

November 11th, 2008 § 1 comment § permalink

Developing the skills to build the captured gear drive took much longer than I had anticipated. When I began the development, I was new to machining, and had never cut a gear before.

The capture gears were difficult to machine. I stack cut the gears using a 24 pitch involute cutter on a 1.08″ blank. I then used a .125″ ball mill and milled a slot into each gear, then parted on the lathe. The parting was fairly problematic as the gear teeth caused too much chatter and ended up binding frequently.

I’m going to say that the captured gear drive experiment was a failure. The main failure is the difficulty in creating the specialized components, and getting the slot to the correct depth to enable the gears to mesh, as well as gripping the cord correctly.

I’m not convinced that the gear drive is better than the direct pulley drive.

Herk Barrel Mount

November 9th, 2008 § Comments Off on Herk Barrel Mount § permalink

Having moved past the pinion gear, I focused on the extruder barrel mount. It is fairly simple in design – a block of aluminum, bored to accept the barrel, slit, then drilled and tapped.

Where Am I?

You are currently browsing the 3D Printing category at OoeyGUI.