Medusa MK-2 Programming Resource Page

(work in progress...please revisit this site frequently for the latest updates)

Welcome to the Medusa MK-2 programming resource page. The goal of this website is to help MK-2 users get started with the programming environment. It provides the details on the tools used and the software supported. Although our software infrastructure is still in development, this page provides information on how to setup the GNU programming environment for the 2 microcontrollers used on the MK-2 node. We also provide snapshots of the 2 operating systems we run on our nodes PALOS and uCos-II.

MK-2 Tutorial Slides

MK-2 Schematics and Hardware Information

If you are setting a development environment under Windows, you first need to install cygwin. After cygwin is installed, the following tools need to be installed.

  1. GNU avr-gcc compiler, the most current precompiled version for Windows can be found on the AVR Freaks website. You can also get a local copy from here
  2. For the ARM/THUMB processor GNU arm compilers, precompiled toolchain for ARM/THUMB for Windows & Linux 

    Uncompress the appropriate archive file in the directory of your choice:

    gunzip gnutools_windows.tar.gz; tar -xvf gnutools_windows.tar

    This will create a gnutools directory. Edit your makefiles point to this directory.

  3. If you are using one of the Macraigor JTAG you need to install the LibRemote Software provided by Macraigor from www.ocdemon.com (we are currently using the RAVEN JTAG for our development).

  4. Download and compile the operating systems PALOS for the ATMega128L and uCos-ii for the AT91FR4081.

 

ATMega128L Processor

The goal of this processor is to perform the baseband processing for the radio and to manage the sensors. Our current implementation uses the PALOS embedded operating system.

Compiler:  avr-gcc

Existing code: PALOS  (Power Aware Lightweight Operating System). To compile PALOS for MK-2 run

make -f Makefile_MK-2

PALOS Tutorial - Slides contributed by Dr. Sung Park, the author of PALOS

AT91FR4081 ARM/THUMB Processor

Compiler: arm-elf-gcc

Precompiled toolchain for ARM/THUMB for Windows & Linux

Operating System: uCos-II

Running your code on the AT91FR4081 processor

There are several methods for running your code on the ARM/THUMB processor. You can either run your code in SRAM or you can burn your code in flash. We are currently working on a monitor/bootloader program that will allow users to connect to the processors using gdb via the serial port. Another alternative for writing code into flash is to use a JTAG interface. We have been using the Raven and Wiggler JTAG interfaces from Macraigor. Macraigor provides pre-build toolchains for the arm and thumb together with gdb and the required hooks for on-chip debugging. These tool chains can be found here.

Connecting to the JTAG Interface

To download and run your code on the MK-2 use the following sequence:

  1. Lauch the OCD debug server  OcdLibRemote -c ARM7  -d RAVEN -s 6  (-s is the speed, varies between different computers select s to be between 1 and 8 where 1 is the fastest and 8 is the slowest). This is a tcp server that connects the gdb debugger to your JTAG device. The default port for this server is 8888.
  2. In a separate window, run the debugger  arm-elf-insight 
  3. Under the Run menu choose Run-> Connect to target.  In the target option select Remote/TCP and ensure that the port is the same as that of OcdLibRemote server i.e 8888. After selecting this and pressing OK, if everything went well you will get a message stating that the connection was successful.
  4. After completing step 3, you should be able to browse the registers and memory of the target (use the view menu of insight). Before loading programs to the MK-2 THUMB RAM, the debugger needs to initialize the device. Open the console window by selecting View->console. Enter the following commands at the arm-gdb console  
            #enable writing to flash
            monitor char 0xfff0000c = 0x01
            #EBI_CSR0
            monitor long 0xffe00000 = 0x01002535
            #EBI_CSR1
            monitor long 0xffe00004 = 0x02002121
            #REMAP Done
            monitor long 0xffe00020 = 0x00000001
            #2MBytes per CS
            monitor long 0xffe00024 = 0x00000006
            monitor reg cpsr 0xd3

  5. Inside Insight open the file you wish to debug File->open filename.elf
  6. Run the program Run->run (Here you will see the program start downloading to the target)
  7. Note that the program will be loaded to memory but will not start running. To start the program issue a continue command
  8. Now you can debug the program, cont, step, next etc.. Have fun!

Note that the uCOS-ii zip file contains the gdb.ini file required to initialize your debugger

GHS Flash Programmer - Internal use only (ask Andreas for details asavvide@ee.ucla.edu). More on flash programming soon....

An alternative method for programming the flash is to use the Atmel Flash Loader Program. This program allows writing to flash using a serial program connection. The problem with this way of programming is that the new program will overwrite the on-chip uploader.  This means that the device can only be programmed once.

Additional Software

AT91 Peripheral Libraries ported to GNU environment - (Provided by Atmel) - this includes sample code and projects and the drivers for the AT91 series peripherals. Makefiles and Software - Note: These libraries have not yet been tested!

Contributors

The NESL members currently involved with development on the MK-2 node

Yen Cheng Kuan - Ultrasonic accessory boards, localization

David Jea - ARM/THUMB Operating System (ucos-ii) and SensorWare

Simon Han - SensorWare, Palos

Norman Su - Palos, Ceiling testbed setup

Andreas Savvides - MK-2 design, ultrasonic distance measurement, ad-hoc localization

 

Last updated by Andreas Savvides  on 05/18/2003 11:33:12 PM