Compiling the firmware
From Tuxisalive
English • Français
Contents |
Prerequires
Before compiling the firmwares, you must compile and/or install the AVR toolchain.
Read this article to know how install the toolchain : Setup the AVR toolchain
Getting the sources from SVN
If you don't have subversion (SVN), it's time to install it. (check your distro if you don't know how)
Then simply checkout the firmware from the repository, replace tuxfirmware with the name you want:
svn co http://svn.tuxisalive.com/firmware tuxfirmware
SVNWCRev
Each firmware includes the revision number at build time in the svnrev.h file. In order to extract it from SVN, we use a small utility called SVNWCRev available at http://svnwcrev.tigris.org/.
SVNWCRev is a port of the SubWCRev.exe tool of TortoiseSVN to Linux. It can be used to read the status of a Subversion working copy and optionally perform keyword substitution in a template file. This is often used as part of the build process as a means of incorporating working copy information into the object you are building. Typically it might be used to include the revision number in an "About" box. Here we use it to include the revision number and status in the hex file so that they can be retrieved through the tux API.
To compile the firmware, you'll have to install SVNWCRev. Download the tar file from the link above, extract it and follow the instructions in the 'INSTALL' file. You'll need the subversion and apr libs to be installed. Then copy the 'svnwcrev' executable in the '/usr/local/bin' directory or anywhere in your path. Basically, this should work:
wget http://svnwcrev.tigris.org/files/documents/3444/44067/svnwcrev-1.0.tar.gz tar -xzvf svnwcrev-1.0.tar.gz cd svnwcrev-1.0 cp config_mk.template config.mk make cp svnwcrev /usr/local/bin/
Notes :
- Ubuntu users should install subversion and the libsvn0-dev packages to be able to compile.
- Debian Etch users should take the more recent libsvn-dev package and edit config.mk to point to the right headers: APR_INCLUDE=/usr/include/apr-1.0
Compile the firmware
Well, now that everything is ready, here's the easy part. You should simply be able to build the 'core' or 'audio' firmware by typing 'make' inside the respective folders.
Go to the trunk folder of one of the firmware files and type 'make'. You should end up with a bootloader.hex and the hex and eep files of the firmware. (i.e. core.hex and core.eep) Those files are ready to be programmed with Tux Droid's bootloader.
The eep file is the eeprom data and is in ihex (intel hex) format as is the hex file. The eeprom can also be programmed with the bootloader. Program the new firmware
I'm planning to add a program target in the makefile itself to be able to do a 'make program' and get it uploaded directly in Tux. But for now, follow the instructions of the 'Updating the firmware' how-to.
Debugging your code
Currently there's nothing to help you debug your code. In the future, we would like to add some debug functions to be able to send some messages to the computer and display them in real time. That should be done soon.
If you're a newbie regarding AVR programming and want to learn that with Tux Droid, then my first suggestion would be to start from something that works and gradually add/change things and regularly check if Tux does what is supposed to. Then use what you can to add some debug code, use the blue led's or movements. Look at the resources given at the bottom of the page to get started.
Programming or debugging with specific hardware
If you're an experienced AVR developer and have your own programmer for the AVR, you can of course program all AVR's directly through the ISP connectors available on the mainboard but you'll have to open your Tux Droid. Needless to say you should be very careful with the ESD, the wires lying around, etc. and that you can do much damage we can't be responsible for. Tux can get crazy, your wife may be afraid and leave, your fridge can explode and your house can burn. But if you still want to get further, here are some tips that may be helpful to you.
ISP programming
The mainboard has 3 ISP connectors. The left hand bottom connector is for the 'core' CPU and doesn't need any special care. The top left connector is for the 'audio' CPU and the top right connector for the 'RF'.
The 'audio' and 'RF' CPU's share the spi port which is also used for ISP. You should then remove the RF board when you reprogram the 'audio' CPU. Some times it works without, most of the time not, and I could once kill the 'audio' CPU completely that way, probably getting a completely wrong programming of the fuses. So just remove the RF board when you program the 'audio' CPU should get you safe.
Normally you shouldn't reprogram the 'RF' CPU but if you want to, then it's even more difficult. You should first remove the RF board, then erase the audio CPU so that the spi lines won't be used, replace the RF board and program it. Then remove again the RF board to restore the program of the audio CPU. That's a bit tedious so if you want to do that often, just build yourself an adaptor where you can plug the RF board directly. ICD
To do In Circuit Debugging, you'll have to get specific hardware. The ATMega88 used on Tux Droid use the DebugWire protocol, not JTAG. You then need to have the expensive 'JTAG ICE mkII' or the new and cheaper 'AVRDragon' from Atmel.
Support of DebugWire under UNIX is still at an early stage and there are limitations. I personally didn't try it yet as it was not implemented when I started debugging. I will give it a try soon as that's certainly the way to go.
The best way I found so far to debug Tux Droid is to use a virtual machine running windows (like vmware) and debugging from AVRStudio. It can then be connected to the dongle under Linux and using the debugger from AVRStudio.
Resources
You'll find the library reference there, but also the important FAQ and additional information. You'll also find the avr-libc mailing lists on the main page.
This is the place to discuss AVR and ask your questions. The forums have thousands of user posts; I can usually find all my answers there simply by doing searches.
To get started, I would advise to check the examples given with AVR Libc. They are simple, though should also introduce you some advanced stuff. There's a very helpful documentation you should follow while you read the examples. And the FAQ will answer most of your questions and is a must read for everybody.
The examples documentation is at http://www.nongnu.org/avr-libc/user-manual/group__demos.html and the examples should already be installed at '/usr/local/avr/share/doc/avr-libc-*/examples'.
Originaly written by David Bourgeois for www.tuxisalive.com on the documentation section.

