Monday, 28 November 2011

My quest to program a ATTiny85 with my Arduinon UNO using ISP

While doing the Arduino advanced course at house4hack a while ago, the Ubuntu 11.10 (oneric) guys could not manage to program their ATTiny85 chips although the windows and Ubuntu 10.04 (Lucid) guys managed fine. Today I spent a lot of time trying to get it to work and FINALLY did. Below is the main errors I saw and how to fix it.

Binary sketch size: 688 bytes (of a 8192 byte maximum)

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

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

avrdude: stk500_disable(): unknown response=0x12

"I think I found one myself.
the problem is that the init request is sent 3 times but only one answer is expected, the following patch should fix":

bilibao@nbarizzi2:~/ELE/arduino-0022$ diff -u examples/ArduinoISP/ArduinoISP.pde /home/bilibao/sketchbook/fixed/fixed.pde
--- examples/ArduinoISP/ArduinoISP.pde  2010-12-24 23:12:25.000000000 +0100
+++ /home/bilibao/sketchbook/fixed/fixed.pde    2011-01-12 01:10:41.373212997 +0100
@@ -54,7 +54,7 @@
  pinMode(9, OUTPUT);
  pulse(9, 2);
+int initSent=0;
int error=0;
int pmode=0;
// address for reading and writing, set by 'U' command
@@ -399,7 +399,8 @@
  uint8_t ch = getch();
  switch (ch) {
  case '0': // signon
-    empty_reply();
+    if(! initSent) empty_reply();
+    initSent = 1;
  case '1':
    if (getch() == CRC_EOP) {

I applied the patch above manually and hurray I got a different error!

Binary sketch size: 688 bytes (of a 8192 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x15
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x11
avrdude: stk500_cmd(): programmer is out of sync

Get the following version of the ArduinoISP and apply the patch from solution 1 again.
(found the solution here)

My tiny is now happily blinking away, at last.
I sommer reported this as a bug too, so it may stand a chance of getting fixed.

Saturday, 26 November 2011

soldering 101 today

We had a cool soldering course at house4hack today.
Even though I did some soldering before, I'm quite impressed by how much I improved today. (sorry for the fuzzy g1 photos) Before:

Wednesday, 16 November 2011

ORA-00001: unique constraint violated

(Pasted here for posterity so probably not an interesting read unless you actually have the same problem and found this while googling) One of my colleagues Leendert Visscher had this weird problem today with a Oracle+JPA+JBOSS getting a
java.sql.BatchUpdateException: ORA-00001: unique constraint violated

Even after making sure all the sequences were fine eg. like checking that quering a nexval and making sure it will not conflict with existing values, the error still persisted :(

The solution was to rebuild the index?!! FTW

We found it after getting the hint while googling a bit.

Friday, 14 October 2011

My kindle thoughts and experiences

Lots of people at work asked me about this, so while I'm writing it down, I might as well blog it..
I bought a Kindle Keyboard, Wi-Fi, 6" E Ink Display for myself last year over Christmas - got it delivered for free to a contact in the US that came back to South Africa that time, saved +-R800. Last month I helped my grandma buy a Kindle DX, Free 3G, 3G Works Globally, Graphite, 9.7" Display with New E Ink Pearl Technology - ordered it on the Monday got it on the Thursday +-R400 delivery (double that with import duty:( ).
Here are some of my opinions about what to buy.

9"big DX vs 6"small

  • 6" - nice and portable - fits in your cargo-pants-pocket/purse/small bag
  • 9" - better for reading pdfs - the letters are quite small on the 6" but if you rotate it 90 degrees it is still readable
  • 9" - double the price for 2.5 times the screen area (IIRC)
  • Because my grandma is a bit visually impaired (mainly got it to listen to audio books from I made some adjustments to hopefully help her. We decided to get the bigger Kindle for her because it has ever so slightly bigger buttons, but they are better positioned and I could hack it a bit.


I would not buy something that does not say e-ink i.e. black&white, no backlight, can read in the sun, looks exactly like paper and is an absolute joy to read.

Leather cover with built-in light

  • Its almost as expensive as the kindle itself.
  • Worth it in my opinion.
  • Uses the kindles own battery - never stuck with flat battery at the wrong time.
  • great for reading under the covers
  • With any cover you must be careful how you open it because if you open it on the wrong side you can crack your Kindle. I added some paper clamps and took off the levers for my grandma to avoid any nasty accidents (saw this tip on the interwebz):

Only buy from Amazon

Local importers pay the same price as you do and then add commission

Check the R/$ price before you buy

The 2 times I checked the Dx prices it varied from +-R3800 to R4200, just after I bought it the R/$ rocketed up another 40cent which whould have been another R400!

Buy international version if you are not in the US

When I bought mine, I had to go to the special international kindle page, maybe that changed..

3G or not?

  • 3G version is 40% more expensive :(
  • Its handy to be able to buy books over 3G when away from any ADSL with wirless.
  • I think 3G coverage is done by MTN in RSA, so if you have bad 3G reception where you live then maybe it is not worth it..
  • I'm not that sorry that I didn't go for the 3G one, because I do most of my syncing and buying from home in any case.


If you have not noticed it so far, I absolutely LOVE my kindle, I can almost not read anything else. Other cool features:
  • Has awesome text-to-speach for books bought from Amazon (DRM:( .awz) and free (.mobi) books
  • Can play audio books bought from, you can buy them directly from a wifi device but not from a 3G device!!?!
  • Can play mp3s for you in the background
  • Can play podcasts or mp3 audio books - just copy them into the audible folder on the device
  • Includes a free dictionary and you can look up any word while reading.
  • Make notes, bookmarks, underlinings (can even see commonly underlined stuff if you are too lazy to do it yourself:)
  • Calibre is the awesomest crossplatform e-book management tool ever! and works great with my Kindle.

Wednesday, 21 September 2011

I just could not sit it anymore

Len Weincier opened my eyes to the possibility of a standing desk a couple of months ago and I've been pondering it ever since.
Recently I found myself in much pain when having to sit and work for extended periods of time (Since my baby son started sleeping in his own room about a month back I can't work in his room lying on my back any more).
It is so distracting that I'd rather stop working and go to bed.

Well tonight I could not sit it any more and I decided to try it out. I was thinking about all the things I'll need to move around if I want space in front of a wall in my study and how much work it will be, then it dawned on me I have everything I need to build a prototype and try it out.
My standing desk version 1.0 (to my wife's dismay I'm sure when she sees this in the morning):

Long-running preparations:
  • Learned to touch type (with the help of learning to type using the Colemak keyboard layout)
  • Got a proper usb keyboard to try this out.

Next steps:
  • I'm still googling to find out if its a good idea in the long term, but for now this seems much nicer.
  • Get some stickers to put on the index finger home keys. I saw Gary van der Merwe had them and I think it will help me a lot because this new keyboard has really tiny dots for feeling the where your index fingers should go.
  • See if I can come up with a better design with a higher spouse approval factor. It would be cool to have something that can easily convert between standing and sitting to avoid over-standing it.
  • Get a LCD screen so I don't have to balance my laptop so tenderly.
  • I can already see that my touchtyping skills will go to a next level with this because my hands are now under my laptop and thus it is much harder to steel a quick glimps (especially for seldomly used keys)

Thursday, 18 August 2011

JPA not instantiating mapped collections.

I struggled a while now to figure out why I am getting a NullPointerException
when trying to access a mapped collection:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cmTypedef")

private List cmParamdefs;

I instantiated a object, then em.merge() it but still I got a NPE.
I really thought that merge would populate all the fields.

Then I tried to make it Eager:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cmTypedef",

fetch = FetchType.EAGER)
private List cmParamdefs = new ArrayList();
Still no luck :(

So merge didn't do the trick, but trying everything I saw that if I do

after the merge, then like magic the collection is populated..

Finally I remember I had this issue before and the simple solution I have so far is
to manually instantiate the collection:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cmTypedef")

private List cmParamdefs = new ArrayList();

I'm not sure if this is the best practice, but it works and is simple..

Friday, 20 May 2011

I cancelled my uncapped ADSL account at Afrihost today (ADSL in South Africa)

I'm being throttled so badly (down to +-7KBps on a 512kbps=80KBps line) that I had to turn on my prepaid account so I could view some web pages while downloading a couple of megs. I had to stop bittorrent too :( I only downloaded 40.9GB so far this month and I don't know why they need to throttle me after hours..

Some other user experiences:

That settled it, now I just had to decide: mweb or openweb?
In the end I'm going for mweb because it is cheaper.

Compare prices:

I see mweb throttles bittorrent quite badly :(

MWEB Uncapped ADSL claims questioned

I don't see much difference between the throttling of p2p stuff between mweb and afrihost:

Bonus 1: You get 2 months free when signing up for 6 months at mweb:

Bonus 2: Telkom are upgrading their 512kbps lines to 1024kbps lines for free:
...mmmm maybe I should get the faster isp account too for an additional R70...
(will need to double check that my line is in deed 1024kbps...)

Monday, 9 May 2011

Bazaar on

(sorry if you get this twice, blogspot made it disappear..)

I've bean looking for a place to host a modular project which is being version controlled with Bazaar. I would have loved to use Launchpad, but I can't because of the following:
  1. Launchpad only allows one level of branches (no hierarchy). My project is made up of a lot of sub-projects: I have a main branch which controls the sub-projects as bzr-externals.
  2. Launchpad does not have a nice project wiki or any custom web content.
I saw that now supports Bazaar, but I was a bit worried when I saw on their wiki that they only support Bazaar version 1.10 . It turns out that it is thankfully only an outdated doc:
[me@shell-21002 ~]$ bzr --version
Bazaar (bzr) 2.1.1
Python interpreter: /usr/bin/python 2.4.3
Python standard library: /usr/lib64/python2.4
Platform: Linux-2.6.18-...
(I don't seem to have rights to correct the wiki and I could not google the current version, so I'm documenting it here for you.)

I did test that I could upload nested branches. But unfortunately the code browsing tool on Sourceforge (loggerhead) does not display the nested branches :( Hopefully that is fixable..
Update: Alexandre Garnier kindly noted that there is a bug report for it.

Thursday, 28 April 2011

Uncapped 512 kbps liberating

Last week I decided I want faster internet so I upgraded my Telkom line to 512kbps (from 384kps) after a quick phone call and waiting a couple of days for the activation. In general my surfing experience didn't improve much but the odd download does come down much quicker, and concurrent downloads doesn't interfere that much with each other any more. I know people in other countries probably laugh at these oxwagon speeds in 2011, but c'mon this is Africa.

I finally took the plunge last night and went over to uncapped internet. Afrihost makes for a great impulse buy since they charge pro-rata for the first month and have instant activation for existing customers. I don't think I'll ever  be able to go back. I'm already torrenting and and downloading big stuff like the latest ubuntu and XP service packs (for family m'kay you can't choose them..) that I usually would avoind or get through other means.

Tuesday, 15 March 2011

maven 3 - its time

After getting some weird issues with my builds I tried out maven 3 again to see if it magically fixed things. It didn't fix that issue, but I'm quite impressed with maven 3 so far:
  • It can build subprojects in parallel which gives me quite a performance boost.
  • The other big thing for me is that "lots of bugs are fixed now", which is a bit hard to measure right away but will probably ensure a more enjoyable experience.
Richard Kolb asked for some benchmarks so here they are. It is probably a lot more beneficial for my 17 module project to build it in parallel.
  • It was done on my Intel i7 Q749 @ 1.73GHz with SSD
  • The second run of each hopefully avoids delays while "checking for updates" 
  • Java version: 1.6.0_24
  • OS name: "linux" version: "2.6.35-27-generic" arch: "amd64" Family: "unix"
  • It includes a GWT widget compile 
  • Ran mvn clean install in the maven reactor with 17 subprojects
== Apache Maven 2.2.1 (rdebian-4) ==
4 minutes 15 seconds
3 minutes 18 seconds
3 minutes 22 seconds

== Apache Maven 3.0.3 (r1075438; 2011-02-28 19:31:09+0200) (serial) ==

=== apache-maven-3.0.3/bin/mvn -T6 clean install (using 6 threads) ===

=== apache-maven-3.0.3/bin/mvn -T6 clean install (using 8 threads) ===

so I save about a minute (or 28%) when runing thing in parallel

I had to upgrade some maven plugins to allow things to be treadsafe with the help of this page:

Monday, 28 February 2011

Toshiba Qosmio X500-12V

I got my new lappy a couple of months ago, so I better post already or hold my peace.
I'm quite impressed, although I haven't tried to get everything working yet still need to play with multitouch and the fingerprint reader . Suspend to disk didn't work and I haven't tried to suspend to ram yet, but it is booting so fast that I don't really need that.

I got a solid state and conventional harddrive, where the solid state disk performs about twice as good as the conventional one (was hoping for better, but it is ok).
SSD: 152.64 MB/sec
HDD: 89.22 MB/sec

* I Managed to migrate my previous installation  (Ubuntu maverick) from my other laptop, moving around directories into special partitions (having most of the main os on the SSD but pointing /var/cache /var/log /var/tmp to the HDD)
* I had to fight a bit with grub and X to get it to work on the new hardware, but it was worth it in the end.
* I now get much better wireless reception:). (previously my connection died all the time:(
* The nvidia drivers works nicely which makes desktop effects work well - I can invert my desktop colours at last!
* Vista in a virtualbox works seamlessly for me now.
* bzr tests runs in 5 minutes now in stead of 18.
* gwt extensions compile in a minute now and does not lock up my laptop; previously it ran for over 5 minutes during which I could barely read e-mail because the system was so busy.
* Eclipse starts and stops a LOT quicker yay!
* Sound is really good (with the 3 watt harman/kardon 1by3's).
* Got the card reader working with some tweaking: