Difference between revisions of "New Flight Computer"

From AD7ZJ Wiki
Jump to navigation Jump to search
Line 40: Line 40:
 
== Software ==
 
== Software ==
  
The software is written primarily in C++, with the exception of the basic startup routines to initialize the hardware and setup the C++ runtime.  I use a port of GCC for arm, put together by CodeSourcery (now MentorGraphics).  The 'lite' version is fine, all you get by paying for the other versions is an IDE and the startup routines - we're going to do everything with a makefile anyways, which is really superior to a project file for an IDE anyways (at least in my opinion :).  Eclipse can easily run make to begin the build process so it works out well.   
+
The software is written primarily in C++, with the exception of the basic startup routines to initialize the hardware and setup the C++ runtime.  I use a port of GCC for arm, put together by CodeSourcery (now MentorGraphics).  The 'lite' version is fine, all you get by paying for the other versions is an IDE and the startup routines - we're going to do everything with a makefile, which is really superior to a project file for an IDE anyways (at least in my opinion :).  Eclipse can easily run make to begin the build process or you can run it from the command line if you prefer.   
  
 
=== Build Environment & Procedures ===
 
=== Build Environment & Procedures ===
Since the software is built using a makefile, the build environment setup is very simple.  I use Ubuntu Desktop as the host platform. The CodeSourcery compiler is available for windows as well however, so with a few tweaks to the makefile it should also build under Cygwin.  I like to use the Eclipse editor since it has integrated in-circuit debugging capability with GDB and OpenOCD.  Install the codesourcery version (??) lite package and ensure it gets added to your $PATH environment variable.  Run 'make' in the directory to start the build.   
+
Since the software is built using a makefile, the build environment setup is very simple.  I use Ubuntu Desktop as the host platform. The CodeSourcery compiler is available for windows as well however, so with a few tweaks to the makefile it should also build under Cygwin.  I like to use the Eclipse editor since it has integrated in-circuit debugging capability with GDB and OpenOCD.  Install the codesourcery version 4.5.2 lite package and ensure it gets added to your $PATH environment variable.  Run 'make' in the directory to start the build.   
  
The code can be fetched from github
+
The code can be cloned from github:
 
* Arm7 Library: https://github.com/AD7ZJ/arm7lib
 
* Arm7 Library: https://github.com/AD7ZJ/arm7lib
 
* Application Software: https://github.com/AD7ZJ/ANSR-Flight-Computer
 
* Application Software: https://github.com/AD7ZJ/ANSR-Flight-Computer

Revision as of 06:52, 9 November 2012

This is the new flight computer we are in the process of developing. This page serves to document the current progress.

High Level System Requirements

  • Documentation
    • Complete documentation including development tool requirements and installation process.
    • User’s manual showing how to utilize all hardware and software features of the system.
  • Single board for flight computer and beacon use
  • AX.25 packet capability for data transmission
  • On-board landing prediction based on wind data gathered during ascent
    • Auto flight start detection to begin logging for prediction
  • Logging
    • Mass storage support for easy access to flight data
    • Internal and external temp sensors
    • Ability to add additional sensors externally would be nice
    • Log battery voltage
  • At least one servo driver
  • Ability to receive DTMF/packet commands in flight
    • (clear logging, begin logging, beacon reset, GPS reset, frequency change)
  • Ability to configure volatile parameters via menu or file
    • Call Sign
    • Beacon time slotting
    • Customization of the status string

Hardware

New flight computer main board

The hardware is based around the NXP (formerly Phillips) LPC2148 - a microcontroller built on the ARMv7 architecture. Benefits are low cost, generous amounts of flash memory and RAM, and plenty of I/O. The chip is driven off a 12 MHz crystal which is multiplied up to 24 MHz by the onboard PLL. This particular processor can run at up to 60 MHz.

Peripherals

A CML Micro CMX678 bell 202 modem IC is used to generate the AFSK AX.25 packet that modulates the radio. This talks to the uC using one of the built-in SPI ports (SPI0). Setup of this IC is pretty simple, and the bitstream is simply shifted out to it via SPI commands.

An SD card is hooked up to the second built-in SPI port. The SD standard allows for a slower (but simpler) SPI interface to the cards. The trick to this is implementing the FAT filesystem in software, but thanks to the ChanFS FAT library this has been made pretty easy.

A Trimble Copernicus GPS engine is connected to one of the built-in UARTs. This outputs standard NMEA strings and is itself configured over the same serial port.

Schematics

The schematics and board layout is done in Eagle, which can be found under the 'Hardware' folder in the Git repository (need to add link)

Software

The software is written primarily in C++, with the exception of the basic startup routines to initialize the hardware and setup the C++ runtime. I use a port of GCC for arm, put together by CodeSourcery (now MentorGraphics). The 'lite' version is fine, all you get by paying for the other versions is an IDE and the startup routines - we're going to do everything with a makefile, which is really superior to a project file for an IDE anyways (at least in my opinion :). Eclipse can easily run make to begin the build process or you can run it from the command line if you prefer.

Build Environment & Procedures

Since the software is built using a makefile, the build environment setup is very simple. I use Ubuntu Desktop as the host platform. The CodeSourcery compiler is available for windows as well however, so with a few tweaks to the makefile it should also build under Cygwin. I like to use the Eclipse editor since it has integrated in-circuit debugging capability with GDB and OpenOCD. Install the codesourcery version 4.5.2 lite package and ensure it gets added to your $PATH environment variable. Run 'make' in the directory to start the build.

The code can be cloned from github:

You'll want to build the library first as the application needs it as a dependency. Run 'make' in the directory to start the build. Assuming it builds successfully, you should have a file called libarm7lib.a in the project directory.

Now the application software can be built. The makefile currently expects the libary in the relative directory ../arm/arm7lib however that is easy to change if necessary.

Debugging

The application is setup for debugging using the Eclipse IDE which natively works with GDB, and the Zylin plugin to interface with OpenOCD. First thing is to make sure you have OpenOCD installed. Then install the Zylin Eclipse plugin from within Eclipse by going to Help->Install New Software... and click Add. Enter something like "Zylin" for the name, and then for the location put http://opensource.zylin.com/zylincdt Click OK and it should then find the Zylin Embedded CDT - proceed with the install of this. Eclipse will need to restart after this.

It is easiest to setup OpenOCD as an external tool to run from within Eclipse - this saves you from typing in the command line arguments each time you want to run it. To do this, from the C++ perspective click Run->External Tools->External Tool Configurations... Create a new configuration and put in the full path to the OpenOCD bin's location as well as for the working directory. In my case, the location is /usr/bin/arm-toolchain/bin/openocd and the working dir is /usr/bin/arm-toolchain/bin. For arguments, put in -f /home/elijah/projects/arm7_app/openocd.cfg Obviously this has to be adjusted to suit your system, but the important thing is to get it pointed at the openocd.cfg file. This can be a path relative to your workspace dir.

Next thing to do is setup the debug configuration. This should be already setup in the project's config file, but for future reference here is how to do it. Switch to the debug perspective to do this, click on the arrow next to the bug, and select Debug Configurations... There should be an option in the menu on the left for Zylin Embedded (Native). Create a new configuration under this, and start filling out the boxes as follows:

  • C++ Application: FlightComputer.elf This is the file that will be loaded into GDB for symbol info.

Under the debugger tab:

  • Set the debugger dropdown to 'Embedded GDB'
  • Set GDB Debugger: /home/elijah/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gdb Obviously adjust this to the full path of wherever you installed the CodeSourcery toolchain.

Under the Commands tab:

  • In the initialization commands put 'target remote localhost:3333' without the quotes
  • In the run commands box, put the following:

monitor reset halt
monitor wait_halt
monitor gdb_breakpoint_override hard
monitor poll
monitor arm7_9 fast_memory_access enable
monitor arm7_9 dcc_downloads enable
monitor flash probe 0
monitor flash write_image erase /home/elijah/projects/arm7_app/FlightComputer.bin
monitor reset halt

Software Documentation

Useful References

http://www.gnu.org/software/libc/manual/html_node/Rounding-Functions.html#Rounding-Functions

http://openocd.sourceforge.net/doc/html/General-Commands.html

http://openocd.sourceforge.net/doc/html/CPU-Configuration.html

http://openocd.sourceforge.net/doc/html/Flash-Commands.html

http://gitref.org/basic/