STRUIX Projects‎ > ‎

4: Multiprogramming the STRUIX stack

Sorry Windoze users.  Unfortunately, this tutorial is for Linux (and cygwin?) platforms.  It may also work for MAC, so give it a try.
 
This tutorial explains how to wirelessly program all the CPU's in your stack assembly.  While you are developing your multiprocessor application, it becomes a bit of a chore to manage the programming of each CPU.  Here we will use XBee's connected to individual CPU's to allow your development system to program the entire stack at once, or just a specific processor.

Refer to the Adding an XBee and Building applications outside the Arduino IDE tutorials for supporting info and download files.

In this basic example, 3 CPU's, with XBee pads connected, and a power pad are stacked.  Both the power buss and TWI/I2C busses are connected the entire length of the stack as shown in the photo on the right.  Here, the XBee's are only for wirelessly programming each CPU, although they could be used for intercommunication with other components - or reporting status to the development system.  We are focused on ease of application development and testing for now.  The main channel of interprocessor communication is through the TWI/I2C buss.

The example application is exactly the same as The Basic STRUIX Multiprocessor Stack example - just tweaked up a bit to build outside the Arduino IDE.  See these examples for more information.

  1. DOWNLOAD RUBY::XBEE FOR STRUIX.
    In the attachements sectio below, there is a ZIP file with the files for ruby::Xbee.  Ruby::Xbee is a set of ruby scripts for configuring XBee's on the fly.

    It was originally developed by Landon Cox but is either no longer supported or has forked to other versions.

    In any case, this version of ruby::Xbee has been tweaked to allow for a software reset of the XBEE, but otherwise is the same as the original.  Unpack the ZIP file to your home directory.  Installation  & configuration instructions are included in the ZIP file.


  2. DOWNLOAD THE EXAMPLE FILES:
    An ZIP file with the example files is located in the attachments section at the bottom of this page.
    Unpack the main folder in the ZIP file to your home directory.  There are multiple files & folders in the main folder and the file structure is important, so don't just unzip them into a single folder.


  3. EXAMINE THE FILE STRUCTURE & MODIFY THE MAKEFILES:
    You will notice (for this example) there are 3 folders containing applications for each of the 3 CPU's.  In each application folder there is a separate makefile for each program.  Each of the individual makefiles may need configuring for your setup.  Refer th the Building Applications Outside the Arduino IDE example for instructions on making adjustments.  Make your tweaks, then continue on.

    In the main folder, there are two shell scripts - 'build.sh' and 'upload.sh'.  Each does what they imply:
    'build.sh' calls each makefile in the application. 
    'upload.sh' will then upload each program to it's associated processor in the stack.


  4. CONFIGURE YOUR XBEE's
    You will need 4 XBee radios for this example - one for each of the 3 processors and one for the development system.

    If you haven't already downloaded the X-CTU '.pro' files and configured your XBee's, do so now.  Unfortunately X-CTU only runs under Windows OS.  Refer to the 'Adding an XBee' an example and download the '.pro' files.


  5. ASSEMBLE  & POWER UP THE STACK
    The STRUIX stack in this example is shown in the photo on the right.  Install the configured XBee's as you go.

    When you are finished, check your connections and power up the stack.  Power draw on this stack will be just shy of 200mA.


  6. BUILD THE APPLICATION:
    Start a terminal session and change directories to the example project folder.  On the example system, the comand is:
    user@Speedy-QuadCore ~ $ cd STRUIX_Command_Line_Example/

    user@Speedy-QuadCore ~/STRUIX_Command_Line_Example $

    Then run the 'build' script to compile the application.
    user@Speedy-QuadCore ~/STRUIX_Command_Line_Example $ ./build.sh

    # Here is the "preprocessing".
    # It creates a .cpp file based with the same name as the .pde file.
    # On top of the new .cpp file comes the WProgram.h header.
    # At the end there is a generic main() function attached,
    # plus special magic to get around the pure virtual error
    # undefined reference to `__cxa_pure_virtual' from Print.o.
    # Then the .cpp file will be compiled. Errors during compile will
    # refer to this new, automatically generated, file.
    # Not the original .pde file you actually edit...
    test -d applet || mkdir applet
    echo '#include "WProgram.h"' > applet/STRUIX_EXAMPLE_Slave_2.cpp
    cat STRUIX_EXAMPLE_Slave_2.pde >> applet/STRUIX_EXAMPLE_Slave_2.cpp
    echo 'extern "C" void __cxa_pure_virtual() { while (1) ; }' >> applet/STRUIX_EXAMPLE_Slave_2.cpp
    cat /home/mdlougheed/arduino-0022/hardware/arduino/cores/arduino/main.cpp >> applet/STRUIX_EXAMPLE_Slave_2.cpp


       text       data        bss        dec        hex    filename
          0       2546          0       2546        9f2    applet/STRUIX_EXAMPLE_Slave_2.hex

    # Here is the "preprocessing".
    # It creates a .cpp file based with the same name as the .pde file.
    # On top of the new .cpp file comes the WProgram.h header.
    # At the end there is a generic main() function attached,
    # plus special magic to get around the pure virtual error
    # undefined reference to `__cxa_pure_virtual' from Print.o.
    # Then the .cpp file will be compiled. Errors during compile will
    # refer to this new, automatically generated, file.
    # Not the original .pde file you actually edit...
    test -d applet || mkdir applet
    echo '#include "WProgram.h"' > applet/STRUIX_EXAMPLE_Slave_1.cpp
    cat STRUIX_EXAMPLE_Slave_1.pde >> applet/STRUIX_EXAMPLE_Slave_1.cpp
    echo 'extern "C" void __cxa_pure_virtual() { while (1) ; }' >> applet/STRUIX_EXAMPLE_Slave_1.cpp
    cat /home/mdlougheed/arduino-0022/hardware/arduino/cores/arduino/main.cpp >> applet/STRUIX_EXAMPLE_Slave_1.cpp


       text       data        bss        dec        hex    filename
          0       2546          0       2546        9f2    applet/STRUIX_EXAMPLE_Slave_1.hex

    # Here is the "preprocessing".
    # It creates a .cpp file based with the same name as the .pde file.
    # On top of the new .cpp file comes the WProgram.h header.
    # At the end there is a generic main() function attached,
    # plus special magic to get around the pure virtual error
    # undefined reference to `__cxa_pure_virtual' from Print.o.
    # Then the .cpp file will be compiled. Errors during compile will
    # refer to this new, automatically generated, file.
    # Not the original .pde file you actually edit...
    test -d applet || mkdir applet
    echo '#include "WProgram.h"' > applet/STRUIX_EXAMPLE_Master.cpp
    cat STRUIX_EXAMPLE_Master.pde >> applet/STRUIX_EXAMPLE_Master.cpp
    echo 'extern "C" void __cxa_pure_virtual() { while (1) ; }' >> applet/STRUIX_EXAMPLE_Master.cpp
    cat /home/mdlougheed/arduino-0022/hardware/arduino/cores/arduino/main.cpp >> applet/STRUIX_EXAMPLE_Master.cpp


       text       data        bss        dec        hex    filename
          0      12224          0      12224       2fc0    applet/STRUIX_EXAMPLE_Master.hex

    user@Speedy-QuadCore ~/STRUIX_Command_Line_Example $


  7. UPLOAD THE APPLICATION:
    Run the 'upload' script to upload each sub-application to the stack.
    user@Speedy-QuadCore-QuadCore ~/STRUIX_Command_Line_Example $ ./upload.sh

    xbeeconfigure
    Wait for Guard Time Timeout...
    Attention...
    Setting destination address
    Setting channel
    Channel: E
    Saving configuration to XBee flash
    Resetting XBee

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.02s

    avrdude: Device signature = 0x1e950f
    avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "applet/STRUIX_EXAMPLE_Slave_2.hex"
    avrdude: input file applet/STRUIX_EXAMPLE_Slave_2.hex auto detected as Intel Hex
    avrdude: writing flash (2546 bytes):

    Writing | ################################################## | 100% 1.66s

    avrdude: 2546 bytes of flash written

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    xbeeconfigure
    Wait for Guard Time Timeout...
    Attention...
    Setting destination address
    Setting channel
    Channel: D
    Saving configuration to XBee flash
    Resetting XBee

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.02s

    avrdude: Device signature = 0x1e950f
    avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "applet/STRUIX_EXAMPLE_Slave_1.hex"
    avrdude: input file applet/STRUIX_EXAMPLE_Slave_1.hex auto detected as Intel Hex
    avrdude: writing flash (2546 bytes):

    Writing | ################################################## | 100% 1.68s

    avrdude: 2546 bytes of flash written

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    xbeeconfigure
    Wait for Guard Time Timeout...
    Attention...
    Setting destination address
    Setting channel
    Channel: C
    Saving configuration to XBee flash
    Resetting XBee

    avrdude: AVR device initialized and ready to accept instructions

    Reading | ################################################## | 100% 0.02s

    avrdude: Device signature = 0x1e950f
    avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
             To disable this feature, specify the -D option.
    avrdude: erasing chip
    avrdude: reading input file "applet/STRUIX_EXAMPLE_Master.hex"
    avrdude: input file applet/STRUIX_EXAMPLE_Master.hex auto detected as Intel Hex
    avrdude: writing flash (12224 bytes):

    Writing | ################################################## | 100% 8.04s

    avrdude: 12224 bytes of flash written

    avrdude: safemode: Fuses OK

    avrdude done.  Thank you.

    user@Speedy-QuadCore-QuadCore ~/STRUIX_Command_Line_Example $



  8. LISTEN FOR THE APPLIACTION:
    You can now use ruby::XBee to listen for the output of the example program.
    user@Speedy-QuadCore ~/STRUIX_Command_Line_Example $ ~/ruby-xbee-1.0/xbeelisten.rb

    Device01
    Device#2
    Device01
    Device#2
    Device01
    Device#2
    Device01
    Device#2
    Device01
    Device#2

 


Č
ċ
ď
Project Struix,
Jul 17, 2011, 12:16 PM
ċ
ď
Project Struix,
Jul 17, 2011, 12:16 PM
Comments