Robostix gumstix ISP

From GumstixDocsWiki

Jump to: navigation, search

Contents

Programming the robostix from the gumstix

You can use the gumstix to download files into the robostix flash. One of the first things that you need to do is to create a jumper which connects Atmel 0 Tx to PXA ST Rx and Atmel 0 Rx to PXA ST Tx. Here's a photo (jumper visible in the top left)

You can also see the TTL-to-RS232 level converter that I use.

Precompiled files

For those of you that just want to use this capability and don't want to build anythng, I put together some tarballs. Note that the robostix_drv.ko file is specific to each version of the kernel.

Tarball Notes
robostix-2.6.11.tar.gz  
robostix-2.6.15.tar.gz  
robostix-2.6.17.tar.gz  
robostix-2.6.18.tar.gz  
robostix-2.6.18-1185.tar.gz For SVN revision 1185 thru 1285

NOTE: there are currently no pre-compiled binaries for buildroots from 1286 to present.

NOTE: there are currently no pre-compiled binaries for the verdex.


These tarballs also containing some binaries. You can use the rz command in conjunction with ZMODEM from your terminal program to transfer the tarball. The tarball contains the following files:

>tar tvzf robostix-2.6.15.tar.gz
drwxr-xr-x dhylands/dhylands 0 2006-02-04 18:18:48 lib/
-rwxr-xr-x dhylands/dhylands 529468 2006-02-04 18:17:06 lib/libstdc++.so.6.0.3
lrwxr-xr-x dhylands/dhylands 0 2006-02-04 18:18:48 lib/libstdc++.so -> libstdc++.so.6
lrwxr-xr-x dhylands/dhylands 0 2006-02-04 18:18:13 lib/libstdc++.so.6 -> libstdc++.so.6.0.3
drwxr-xr-x dhylands/dhylands 0 2006-02-04 18:22:41 rs/
-rwxr-xr-x dhylands/dhylands 190010 2006-02-04 18:19:39 rs/uisp
-rwxr-xr-x dhylands/dhylands 9814 2006-02-04 18:20:09 rs/robostix
-rw-r--r-- dhylands/dhylands 10576 2006-02-04 18:20:09 rs/robostix_drv.ko
-rw-r--r-- dhylands/dhylands 12712 2006-02-04 18:22:41 rs/Flash-LED.hex

If you're using 2.6.11 (SVN revision 773 or earlier) then you need to manually create the /dev/robostix entry, otherwise it will be created automatically when you insmod robostix_drv.ko.

# cd /
# tar xzf robostix.tar.gz
# mknod /dev/robostix c 240 0 (not be required if /dev/robostix already exists)
# cd /rs
# insmod robostix_drv.ko
Robostix Driver: SVN: 1040 Compiled: Jul  7 2006 at 22:22:30
# ./uisp
Atmel AVR ATmega128 is found.

Error messages

If you get the following message from running uisp

# ./uisp
Probably the AVR MCU is not in the RESET state.
Check it out and run me again.

then you probably forgot to install the jumpers connecting the STUART port to UART-0. This can also happen if the robostix isn't powered directly (i.e. the power adapter needs to be plugged into the robostix and not another daughtercard).

If get the following message:

# ./uisp
An error has occurred during the AVR initialization.
* Target status:
Vendor Code = 0xff, Part Family = 0xff, Part Number = 0xff
 
Check if the programmer is properly connected. 
The wiring may be incorrect or target might be 'damaged'.

if only the left jumper is installed and the right jumper isn't.


Running uisp from the MMC card

If you only have 4Mb of flash, then you probably won't have space to install the C++ runtime library as part of the root. Following these steps will allow uisp to be run from the mmc card:

mount /mnt/mmc
cd /mnt/mmc
...copy in robostix.tar.gz....
tar xzf robostix-2.6.15.tar.gz
cp lib/libstdc\+\+.so.6.0.2 lib/libstdc\+\+.so.6 (note that we changed the name slightly)
export LD_LIBRARY_PATH=/mnt/mmc/lib
export PATH=$PATH:/mnt/mmc/rs
mknod /dev/robostix c 240 0 (only required with the 2.6.11 kernel)
insmod /mnt/mmc/rs/robostix_drv.ko
./uisp

Normally, libstdc++.so.6 is symbolic link to libstdc++.so.6.0.2 but since the mmc card is FAT, symbolic links aren't supported. So by renaming the library to match what uisp is expecting, we don't need the symbolic links. Setting LD_LIBRARY_PATH tells uisp where to search for loadable libraries.


Running uisp from the RAM disk

If you only have 4Mb of flash, then you probably won't have space to install the C++ runtime library as part of the root. Following these steps will allow uisp to be run from the RAM disk:

cd /tmp
...copy in robostix-2.6.15.tar.gz...
tar xzf robostix-2.6.15.tar.gz
export LD_LIBRARY_PATH=/tmp/lib
export PATH=$PATH:/tmp/rs
mknod /dev/robostix c 240 0 (not be required if /dev/robostix already exists)
insmod /tmp/rs/robostix_drv.ko
./uisp


Building uisp from source (build 774 and onwards)

uisp and the appropriate patches have been merged into buildroot. So all you need to do is enable it.

cd gumstix-buildroot
make menuconfig
Under "Package Selection for the target --->", scroll down the list and select uisp
Exit, saving your changes

If you haven't built buildroot yet, then just type

make

If you have built buildroot, then we need to ensure that the C++ compiler gets built. Selecting uisp will automatically select the C++ compiler, but since the compiler is already built it won't generate the C++ portion. Do:

rm toolchain_build_arm_nofpu/gcc-*-final/.configured
make

Building uisp from source (build 773 and earlier)

To build everything from source, you'll need to do the following (this has not yet been integrated into buildroot):

cd to the directory containing gumstix-buildroot
svn co http://svn.gumstix.com/gumstix-buildroot/branches/projects/robostix robostix
cd robostix/gumstix
cp uisp.mk ../../gumstix-buildroot/make
cp uisp-robostix.patch ../../gumstix-buildroot/sources

You'll need to edit gumstix-buildroot/Makefile: Remove the '#' from the beginning of this line:

INSTALL_LIBSTDCPP:=true

Find:

# For audio
TARGETS+=bplay madplay aumix

and after that add:

# For robostix
TARGETS += uisp

Since uisp depends on C++, if you don't already have C++ as part of your environment you'll need to remove build_arm and toolchain_build_arm and rebuild everything.

Building the robostix driver and command line tool

cd robostix/gumstix
make

This will build robostix and a loadable module named robostix_drv.ko. You'll need to copy these to the gumstix (I use ZMODEM along with the rz command). Make sure that the /dev/robostix device exists (only required under 2.6.11 and earlier):

mknod /dev/robostix c 240 0

and load the module:

insmod robostix_drv.ko

The robostix command line program supports a number of commands for controlling the robostix.

robostix reset pulse

will pulse the reset line on the robostix. Note that when the gumstix boots up, the robostix is held in reset.

WARNING

The

robostix power off

command will power off the robostix and the '245 voltage converter, which causes the console to become non-functional. If you really want to try using the power command, try this (all on one line):

robostix power off; sleep 5; robostix power on

Installing Driver and Command Line Tool Permanently

Once you've had your fun testing the robostix utility, you can install it and the driver permanently. First create a file called modules.cat that looks like this:

# Driver for robostix control
robostix_drv

Then place it in a folder with the robostix binary, robostix_drv.ko and S10robostix in a folder with this shell script on the gumstix (through serial, USB, your favorite method, etc.):

#/bin/sh
# 
# Run this in same directory as 
# robostix binary, robostix_drv.ko and S10robostix
mkdir /lib/modules/`uname -r`/kernel/drivers/robostix
mv robostix /sbin
mv S10robostix /etc/init.d
mv robostix_drv.ko /lib/modules/`uname -r`/kernel/drivers/robostix
insmod /lib/modules/`uname -r`/kernel/drivers/robostix/robostix_drv.ko
depmod -a
modprobe robostix_drv
cat modules.cat >> /etc/modules

Now when you restart the gumstix, the robostix driver should be loaded and ready to go. To make sure it worked, just type lsmod | grep robostix_drv.

Programming the Fuses

The robostix ships with the Atmel default fuse settings, which means that it runs at 1 MHz and it runs in ATMega103 compatability mode, which essentially means that programs won't work properly. So you need to set the fuse.

To program the fuses using uisp on the gumstix, use the following command:

uisp --wr_fuse_l=0xbf --wr_fuse_h=0xc9 --wr_fuse_e=0xff

There are now a couple of scripts in SVN for programming the fuses.

pgm-fuse-standalone is suitable for downloading programs using uisp. pgm-fuse-bootloader is designed for use with the i2c-BootLoader.

Downloading to the Robostix

To write a program to the robostix:

uisp --erase --upload if=Flash-LED.hex


Using the gumstix/robostix to program other AVRs

By making a custom cable, you can use uisp on the gumstix to program other AVRs as well. The photo below shows the cable I made (the other end of the cable has a a 10 pin female header with all 10 pins connected. Pin 1 (brown wire) connects to the STUART TxD, and pin 9 (white wire) connects to the STUART RxD. I added a 10k resistor between ground and the ATMega UART-0 RxD line just to make sure it wouldn't accidentally pick up a stray signal.


The 10 pin cable I used has resistor color codes. Brown is pin 1, red is pin 2, etc. Pins 1 and 9 need to NOT be connected through to the ISP connector. A picture of the 10 pin ISP connector (looking at the male pins) is shown here:

Image:AVR-ISP-Pinout.png


This is a photo of the cable I use for programming my ATMega8. It works with all standard AVR ISP programmers.

The color coding is as follows:

Pin Signal Color
1 MOSI Blue
2 Vtarget Red
3, 4, 6, 8, 10 Gnd Black
5 Reset Orange
7 SCK Violet
9 MISO Gray


Finally, I have a photo of the setup I used for testing. I used the Parallax Professional Development Board which has a bunch of handy features on it.

I also connected the I2C lines up from the gumstix/robostix to the ATMega8. Black is Ground, Gray is SDA, and Orange is SCL.

IMPORTANT The fuse settings mentioned elsewhere are probably for the Robostix, which is an ATMega 128 with an external 16 MHz crystal. You'll want to double check your fuse settings for your particular AVR processor.

Personal tools