Arduino Duemilanove as ISP: ST500K protocol errors due to Serial Reset

Posted by: gdelmatto  :  Category: Hacks

Years ago I wrote about using the Arduino Micro as an ISP for use with a standalone ATMEGA micro controller.

I used this again every now and then, but got to the point where I wanted sort of a more permanent setup. As I had a spare Duemilanove and some prototype boards lying around, all I had to get was a DIP28 ZIF socket and start soldering.

Here’s the Layout:

ATMEGA Pin 20 and 7 -> 5V
ATMEGA Pin 22 and 8 -> GND
RESET: ATMEGA Pin 1 -> Protoboard Pin 10
SCK: ATMEGA Pin 13 -> Protoboard Pin 13
MISO: ATMEGA Pin 12 -> Protoboard Pin 12
MOSI: ATMEGA Pin 11 -> Protoboard Pin 11
Yellow LED Anode -> Protoboard Pin 8
Red LED Anode -> Protoboard Pin 6
Green LED Anode -> Protoboard Pin 3
All LED Cathodes -> GND (attach a 150 Ohm resistor)
On the Protoboard, connect RSET and 5V through a 120 Ohm pull-up resistor


With this setup, I opened the ArduinoISP sketch included with Arduino IDE.
In my old tutorial I recommended downloading the sketch from Github, this has become obsolete.
The one include with recent versions Arduino IDE is far more advanced.

I had just these minor things changed in the sketch:

With this loaded onto the Duemilanove I could finally use it it burn standalone micros like a charm.

So, I took the solution upfront. This works for me.

The problem I had up to this point was a very unpleasant behaviour while burning the bootloader onto the micro, where I consistently got errors like these:

/Applications/ -C/Applications/ -v -patmega328p -cstk500v1 -P/dev/cu.usbserial-AH01GO57 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDA:m -Ulfuse:w:0xE2:m

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:01:35
Copyright (c) 2000-2005 Brian Dean,
Copyright (c) 2007-2014 Joerg Wunsch

Using Port : /dev/cu.usbserial-AH01GO57
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x15
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x15
AVR Part : ATmega328P
Chip Erase delay : 9000 us
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 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 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 : STK500
Description : Atmel STK500 Version 1.x firmware
avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14
avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x02
avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x10
Hardware Version: -1449398444
Firmware Version: -1073745528.444305
Topcard : STK502
Vtarget : 1.8 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: stk500_initialize(): (b) protocol error, expect=0x10, resp=0x01
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x10
avrdude done. Thank you.
Error while burning bootloader.

While I never observed this misbehaviour when using the Arduino Micro, the Duemilanove constantly refused to burn to the chip.

Unfortunately, there seems to be gazillions of people observing the very same error, but afar from “check the cabling”, “check blahblah”, there seems to be not much help on this matter. On the other hand, there are obsiously people, who never encountered this issue. Or it is device or implementation dependenant respectively.

Only after hours of searching and reading, I found some people mentioning similar issues with serial programmers and how they got away with disabling serial signals. That very moment I remembered reading about Arduino doing Reset on Serial many years ago.

I don’t know, why this is not mentioned already in of the Arduino as ISP context (it should, I thinkg). At least there is official documentatio on how to disable reset on serial.
There’s multiple solutions, from soldering, to just sticking restistors. Since I didn’t want to tamper with the Arduino PCB, I’ve just added a removable resistor between RST and 5V. Since I didn’t have a 120 ohm resistor at hands, I had to combine a 100 and a 20 ohm resistor to achieve the same effect.

Weehee! With the resistor in place, it finally works the way it should.



Transform Cobalt Raq3 into a Raspberry Pi-powered Media Center

Posted by: gdelmatto  :  Category: Debian GNU/Linux, Hacks, Hardware, Operating Systems, Programming, Scripting

Anyone remember these adorable blueish 1U servers made by Cobalt Networks?


While I was never in true love with the Cobalt OS itself, I actually liked the Cobalts Raq enclosure.
So much that I salvaged one while cleaning out a data center last summer. I decided to grant it a second live as a media center box running OSMC.
And of course it’s powered by a Respberry Pi. Nowadays there’s simply no way around those nice little boxes 😉
Read more…

Use Arduino Micro as ISP with ATmega on a breadboard

Posted by: gdelmatto  :  Category: Hacks, Hardware, HowTo's

**** UPDATED 2018/04/27 ***

Arduino is super cool, I really love that thing, but …

Who would really want to put a fully-featured Arduino board into each and every project, at least when they’re built to more like a permanent setting?
I guess nobody. Honestly, an Arduino is not expensive to buy, but to expensive, if you want to put dozens of them in place.

So, why not put just the ATmega chip, which drives every Arduino at its heart, inside and leave all the rest away?

This is what this post The RRRRRRRRRRBBA, a $3 Arduino talks about: Just provide power to the ATmega and get rid of all the bells and whistles. You can even spare the oscillator and the resistors.

Well, this is exactly what I wanted. But since I didn’t have the proper gear at hands to flash the ATmega chip, I first had to look into another topic, namely how to turn your existing Arduino into an ASP (in-system programmer).

Here’s some of the pages I came along:

Arduino ISP
Arduino to Breadboard
The Arduino Micro schematic
Arduino Leonardo as ISP
Arduino Micro as ISP and atTiny84A

But I soon found that doing so with an Arduino Micro, the only one I had available at that time, is not as straight forward as with other Arduino boards.
So I did this writeup to cover my findings on this.
Read more…

Perl/SOAP::Lite: Rewrite response XML for ASP.NET compatibility

Posted by: gdelmatto  :  Category: Hacks, Perl, Programming

So you finally hacked up your nifty SOAP::Lite web service only to find that it works fine with SOAP::Lite or PHP clients, but ASP.NET terribily fails?
Yes, I should mention, that you must of course write up a WSDL first, especially for .NET, I’ll cover that topic in a follow-up.

This post however refers to a hack that I have done to SOAP::Lite to allow for dynamic response rewriting for different SOAP client implementations.
Read more…

Tricking Squeezebox Server into downloading firmware files from local server

Posted by: gdelmatto  :  Category: Hacks, HowTo's

Gosh … I’ll never (as in _never_) cease my home internet again before moving out of the flat. Here’s another workaround to trick my Squeezebox Server into downloading firmware files from a local server – just because of lack of internet connection. Dooooh!
Read more…

Baking Recipe to fix broken MacBook LogicBoard

Posted by: admin  :  Category: Hacks, Hardware

What a shame: After four years of service my 3rd generation MacBook Pro broke last wednesday – obviously a well-known issue with the Nvidia GPU. Strangely enough, this really is easily to be fixed with your kitchen’s baking oven…

Read more…

Replacing stock mini PCIe WiFi by DW1390 WiFi on eeePC 1000H

Posted by: admin  :  Category: Hacks, Hardware

This february I had my 30th birthday. My boss surprised me with an eeePC 1000H as an unexpected as well as also a very cool gift 🙂

Ok, I must admit, that I took a glimpse at the tiny netbooks more than once. My dream was to actually run it with OS X instead of Windows or Linux.

So, just the next-day my netbook was OS X-ified (a topic, which I’ll cover later on), only to notice some more or less annoying issues.
Read more…

ras_init.vbs: Override And Restore Routes With Windows RAS

Posted by: admin  :  Category: Hacks

When initiating a PPP/PPTP connection through Windows RAS you will usually end up with an altered network default route which will redirect all and every traffic through PPP/PPTP.

There are many cases however where such a behaviour is simply not desired, considering Windows RAS providing you with no way to circumvent this, you’re on your own for once more.

I wrote this script, ras_init.vbs, out of the requirement to restore my default route for normal connections and route only specific hosts and networks through PPP/PPTP.

ras_init.vbs is released under the terms of the GNU GPL, version 2. Any feedback is appreciated.

Note: Some time in the past the code of release 0.3 has been lost. As this script is not actively maintained any more, I will not invest time to redo the bugfixes.
The script would need to undergo a major rewrite, maybe in PowerShell, to work on Vista/Windows 7/Server 2008 anyway.

Change Log:

r0.3 2007/06/06

  • fixed a bug with wrong RAS_Routes array enumeration
  • changed script to figure out language settings on its own
  • addedd support for RAS_Name, RAS_User and RAS_Pass attributes to include whitespace characters
  • added support for Windows Vista (requires administrative privileges though)

r0.2 2006/06/16

  • add support for interactive/non-interactive mode

r0.1 2006/06/13

  • initial release
  • tested on Windows 2000/XP
  • searches through all interfaces and looks for the expected RAS subnet address
  • removes RAS default route and replace it by your local default route
  • optionally set up host/network routes for routing through RAS

FreeBSD patch: enable fsck in mdmfs

Posted by: admin  :  Category: Hacks, jails

This patch is actually a follow-up development to my article on implementing filesystem allocation limits on FreeBSD jails.

My previous article basically lined out how to place jails inside a vnode-backed memory device to enforce filesystem allocation limits. This became possible through a new flag introduced to mdmfs in FreeBSD-CURRENT which allowed to skip 'newfs' (which requires mdmfs actually to be called mount_md to work properly).

This solution is quiet handy as it will automagically mount the container volumes as required. But since we do not live in a perfect world - and computers ain't perfect either - crashes do happen. File system corruption on volumes will prevent jails to startup as their (virtual) root device will fail to mount.
This is where this patch comes in. It will enable mdmfs to optionally run an fsck on given volumes.

To apply the patch, create a new temporary build directory first:

#mkdir /root/mount_md
#cd /root/mount_md

Then get the original source code from CVS. Maybe it’s easiest to get this particular release through WebCSV at

Save this file to your previously created build directory.

If you have wget at hands you can also download it directly.

#wget -user-agent='Mozilla/5.0' '' -output-document=/root/mount_md/mount_md.c

Download and apply the patch: mount_md.c.diff

#wget -user-agent='Mozilla/5.0' '' -output-document=/root/mount_md/mount_md.c.diff

#patch < /root/mount_md/mount_md.c.diff

Compile the source:

#gcc /root/mount_md/mount_md.c -o /root/mount_md/mount_md

Then copy the file to some location you like, eg. /usr/sbin.

#cp /root/mount_md/mount_md /usr/sbin/mount_md
Make sure you call the file as given in the example. It won’t work otherwise.

Special care must be taken that you DO NOT replace your existing mdmfs binary file by this new version. DO NOT overwrite it. Do not rename this patch to mdmfs. Use the names provided in this example instead.

Setup Jail’s fstab

Now check out your jail's fstab and look for this line:

md /var/jails/ md rw,-P,-F/mnt/r5_vol1/jails/

Change it as follows:

md /var/jails/ md rw,-P,-F/mnt/r5_vol1/jails/,-Tufs


md /var/jails/ md rw,-P,-F/mnt/r5_vol1/jails/,-tufs

The difference in the two lies in the '-T' or '-t' argument. Both enable fsck before mounting the volume, hence '-T' runs 'fsck -y' while '-t' does not.

You need also to provide the filesystem type with either option for fsck to work properly.

Policy Filter for ClamSMTP (pf-clamsmtp)

Posted by: admin  :  Category: Hacks

pf-clamsmtp is a perl-written policy filter for use with Postfix and clamsmtp primarily written for one purpose: pass messages to the clamsmtp virus filter only if they don’t exceed a given size.
Read more…