Jeffrey's Log

Archives | Subscribe


Experiments with Phoenix-MDK

Published on: February 13, 2011

Share on      


Today I got a chance to do some hacks on Phoenix-MDK. There was a need of a bootloader for this board. Along with that, we should be able to program the board without hitting any reset switch. The first thing which came into my mind was the arduino boards. They had all the above mentioned features. So I started understanding how the arduino board works, which boot loader is used inside, how reset can be triggered through software etc.

The bootloader used in arduino’s are the optiboot which has a very small footprint (around 512kb) and it was using the serial protocol STK500 for its communication. So I took the optiboot and made some modifications. But it failed. I don’t know where I went wrong and also I bricked one ATMega32 chip.

I had one more ATMega32 chip with me. But this time I was really careful not to brick again a chip. It was really hard to find a bootloader. After a long search I found this page which really helped me a lot – http://wiki.edwindertien.nl/doku.php?id=software:bootloaders

The bootloader can be obtained from http://wiki.edwindertien.nl/lib/exe/fetch.php?media=software:atmegaboot-32.zip. Phoenix-MDK uses 8MHz crystal. So I had to modify a line in the makefile which contains the clock frequency to AVR_FREQ = 8000000L . Thats all. I gave a make and got the hex file.

Below are the steps for flashing the bootloader and using it.

1) Flashing the bootloader using parallel programmer

flashing the hex:

avrdude -c dapa -patmega32 -U flash:w:ATmegaBOOT_168_atmega32.hex

flashing the fuse:

avrdude -c dapa -patmega32 -U lfuse:w:0xff:m -U hfuse:w:0xda:m

2) Testing the bootloader

avrdude -b 19200 -P /dev/ttyUSB0 -pm32 -c stk500v1 -n

This should give a proper response.

3)Uploading a hex file using the serial bootloader

avrdude -b 19200 -P /dev/ttyUSB0 -pm32 -c stk500v1 -U flash:w:a.hex

For the above code to work on Phoenix-MDK, I also had to do some hardware hack. Now the DTR pin is connected to the reset pin so that reset can be done by software. I have to find a software way to reset the chip.


Comments

Comments can be emailed or tweeted to me. I would like to hear them and will try to reply.


Made using Jekyll, Twitter Bootstrap, Code Prettify and Font Awesome.

Copyright (C) 2008 - 2019 Jeffrey Antony.