Burning Arduino Bootloader

January 11, 2013 1 comment

EDIT: I had written this a while back but never published. There must’ve been more things I wanted to write, but it’s been over a year and I simply forgot what I wanted to add. So here you go…


If you bought one of many Arduino clones out there, chances are, the bootloader is not burned into the chip. If that’s the case, you can’t use it out of the box with the Arduino IDE and you won’t be able to upload those sketches. Now, you can only burn the bootloader firmware using the ICSP programmer such as avrispmkII.

It was a bit of a pain to get it working. In the end, I had to drive the avrispmkII from linux machine using the Makefile provided with the latest Arduino v1.0 download. Under the directory hardware/arduino/bootloaders/atmega, I had to make some minor changes to the source code ATmegaBOOT_168.c.

The changes required in this file can be found at this following url: http://code.google.com/p/arduino/issues/detail?id=152. Basically, you modify the #if defined preprocessor directive to use the macros that are defined.

Once the source is modified, just run “make atmega328_isp“, which will compile the bootloader source code, create the hex, and then proceed to upload the .hex file into atmega328 chip using the ICSP programmer. The Makefile issues these avrdude commands to setup the fuse bits and then upload the hex.

# fuse settings
avrdude -c stk500v2 -p atmega328p -P usb -b 115200 -e -u -U lock:w:0x3f:m -U efuse:w:0x05:m -U hfuse:w:0xDA:m -U lfuse:w:0xFF:m

# burns the bootloader and then locks it
avrdude -c stk500v2 -p atmega328p -P usb -b 115200 -U flash:w:ATmegaBOOT_168_atmega328.hex -U lock:w:0x0f:m

The second command takes a while to run. And it also complains with errors like:

avrdude: stk500v2_recv_mk2: error in USB receive

You just have to wait and let it finish.

Once that’s done, you’ll have the bootloader burned onto the atmega328p chip, and will be able to use the Arduino IDE to upload the sketches onto it.

Categories: Uncategorized

LED Display Over Bluetooth With Android

December 9, 2011 13 comments

Old Clock Redux

bluetooth moduleI came across this neat bluetooth module called HC-06. It can be found as cheap as $6 on ebay, and gives you convenient UART access to bluetooth wireless capabilities.

My 3yr old has this home-made LED clock in his room. I thought it was time for an upgrade since the clock was very minimalistic. Its only function was to keep track of time and display it on the LED panel. And considering it was my first “completed” project with avr (atmega168), I thought I could make it better this time around.

I wanted to make use of bluetooth capability somehow, and thought it would be neat to send a text message to the display. In addition, I decided change up a few things:

  • receive bluetooth text message up to 64 chars and scroll it across the panel
  • set the time via bluetooth
  • consolidate 2 push buttons into 1 for manual time adjustment
  • make some noise with the piezo I put in there
The upgrade seems to have worked out nicely. I can send messages to it from my Android phone or from a Linux PC with bluetooth dongle attached. I used iteadstudio’s bluetooth assistant app to send text to the display.
A Simple Demonstration
Again, the source code is available at:
Categories: uC and Electronics

ANT+ Between MSP430 (also Arduino) and Android

November 27, 2011 33 comments

ANT+ what?

ant+ logoSmartphones are equipped with dizzying array of wireless communication capabilities.   Some of these features just go totally unnoticed. One such wireless communication protocol is called ANT+.

A friend of mine wanted to make a working prototype of an idea he had using ANT+ technology. While there are other mcu’s (read atmega/arduino) already had some libraries and code written for communicating against ANT+, it wasn’t enough for me.

  • Most of the existing code only worked as a slave, where it just tried to receive data sent by Garmin Heart Strap.
  • This slave implementation was only on either arduino or PC (python and C)

What I was more interested in was to leverage the ANT+ radio to not just receive data, but also send data. I wanted the mcu to interact with the world and use ANT+ to transmit data to my cellphone, for example. I couldn’t find any suitable implementations, and figured msp430 needs to have more “hacks” to add to its list.

So here goes. I bought two different Sparkfun products for ANT+. Both TI and Nordic has chips with ANT+ capabilities. The Sparkfun ones use nRF24AP1, and comes in 2 varieties.

I used the lesser chip that comes with the Launchpad to drive the ANT+ breakout as the master node. The usb stick will serve as the slave and used as debugging tool. Once the initialization hand shakes and data transmission is sorted out, I can test on the Android platform.

As of this writing, only Sony Ericsson makes phones with chips that can talk ANT+. I found Xperia X8 to be a good low-end unlocked Android phone just for general purpose hacking, with the full ANT+ capabilities onboard. In order to enable ANT+ wireless, you need to download these apps:

Here’s the video of my test setup running.
And all the relevant source code and documentation is hosted on github:

Read more…

Categories: Uncategorized

Nokia LCD + WiiNunchuck with MSP430

January 3, 2011 12 comments

I bought myself couple of msp430 Launchpad’s when they first came out. At $4.30 with free shipping from TI, it’s one heck of a deal for what comes in the package. I wanted to use the lesser of the two mcu’s that comes in the package to do something cool. I first worried about 2kB flash size being an issue, but I was wrong. The 16bit architecture yields smaller compiled text and it packs enough space to do build some serious applications. The number of peripherals and features these mcu’s support are rather generous and I found these mcu’s quite pleasant/fun to work with.

Having the option to develop in linux was important to me. With msp430-gcc and mspdebug, I had all the toolchain necessary to start coding for these little suckers. So I wanted to see if it was possible to make a simple hand-held gaming device with just one chip. This required a small LCD screen and a user input device like Wii Nunchuck.

The source code that produces that runs the setup above is available here:  http://www.remnantone.com/pkgs/msp430/noklcd.zip

The code is just barebones. It contains just enough to communicate with the LCD and Wii Nunchuck. Read through after the break for more details.

Read more…

Categories: Uncategorized

Flashing uC’s with GoodFET

November 23, 2010 Leave a comment

I got myself one of GoodFET40 PCB’s the other day. The pcb is thin! But not only that, it requires you to surface mount some parts. Now, I haven’t done SMD soldering before so I enlisted help of one of my buddies. It didn’t go so well the first time, but I did manage to get the GoodFET firmware installed.

Once soldering is done, you first need to load goodfet firmware onto the main chip. For GoodFET40′s, it uses MSP430F2618. This chip allows you to load the firmware via Bootstrap Loading (BSL). I am not entirely sure how this works, but it seems to require a password to have it enabled so that you can bit-bang the firmware into the chip bytes or words at a time.

./goodfet.bsl --fromweb

This command will require you to have pre-installed:

- pyserial
- pysqlite
- curl

I’ve also tried

# --fromweb retrieves the precompiled hex from the web and stashes it to /tmp
./goodfet.bsl -e -p /tmp/.goodfet.hex

Now, once your GoodFET is programmed, you can test by

./goodfet.monitor test

If all goes well, you shouldn’t see any error or warning messages. For me, the results of the test were inconsistent between 2 different Ubuntu versions. (UPDATE: Kenneth has found a solution for errors I was getting on Ubuntu 10.04.)  I am not sure if this due to FTDI drivers being different or some quirky differences in python serial library. I had intermittent timeouts. (The goodfet code seems to have defined timeout at 2 seconds).

In any case, once you have 1) hardware built 2) goodfet firmware loaded, it’s time to program your target chips.

Read more…

Categories: uC and Electronics

Led Matrix Canvas

November 19, 2010 33 comments

I wanted something “flashy” that grabs my attention when I am working. I am flooded with constant influx of emails, internal chat windows, and many terminal screens full of code. Sometimes it’s hard to get my attention when critical things happen in the trading environment and I notice it too late.

I had 2 of sure electronics 16×24 led matrix boards laying around. So I set out to create a led matrix “canvas” out of these 2 display boards. I didn’t want just a simple led display board. I wanted to build something flexible that can make the best out of our precious LED “real estate”. I envisioned something that I can easily control from a host PC. To make matters more complex, I not only wanted scrolling text messages, but render monochrome animations and images through it.

I didn’t think it’d be feasible to implement _all_ the functionalities I wanted into teensy firmware.  One may argue that this is possible ( Peggy seems to have implemented lots of features into firmware), but I thought it’d be cooler to leave the complex image/animation processing on the host PC-side. I’ve decided to make teensy code concentrate on deciphering the drawing “commands”, and offload content generation on the host PC.

When you do a google search of led matrix boards, you can find tons of neat projects out there. However, many of them lack explanation or sufficient documentation on them. I am not sure if folks might find this project interesting or useful at all. I certain learned a lot from it, and herein I describe the details of this project hoping that it can be of use to someone who’s aiming to do something similar.

For the Impatient

Here’s the demo video of the project.

Parts/tools used:

  • Teensy 2.0
  • 2 x Sure Electronics LED Boards
  • 2 female headers
  • 2 male headers (2×5)
  • Protoboard for wiring parts together
  • C lib for communicating with ht1632 driver on led matrix board
  • C lib for usb_serial
  • C code to parse commands and control led matrix
  • Python code to translate imgs, text, and 3D cube into commands
  • PySerial lib to sent over serial device : /dev/ttyACM0

And here’s the source code for download. If you are on a linux box, you can simply run “make” in the project directory.

Now, if you want to know the details, continue reading below.

Read more…

Categories: uC and Electronics

My First Complete AVR Project

November 18, 2010 1 comment

I’ve only dabbled at microcontrollers for about 1.5 yrs. Throughout this time it was mostly light tinkering, nothing serious. But my wife gave me a challenge. Build a digital clock with the parts I already owned – something our son can read.

So I created one, and was fortunate enough to get noticed by hackaday.com.  Here is the link


And the original post at nerdkits.com.




Categories: Uncategorized

Get every new post delivered to your Inbox.