Difference between revisions of "RoboVero"

From Gumstix User Wiki
Jump to: navigation, search
(roboveroConfig)
(resetConfig)
Line 168: Line 168:
 
=== resetConfig ===
 
=== resetConfig ===
  
 
+
This is a convenience/safety function that simulates the effect of a reset on pin select registers without disconnecting USB. '''resetConfig''' is called automatically when a Python Client Library program terminates.
 
+
  
 
=== Library functions ===
 
=== Library functions ===

Revision as of 10:12, 24 June 2011

RoboVero is a robotics expansion board for the Overo COM series.

Quickstart

Connect

All RoboVero boards ship with a peripheral driver library and command line interface preflashed. When you apply power, a red LED should illuminate immediately. This indicates that code is executing on the board. The LED stays on until a USB connection is established when it begins blinking at a heartbeat rhythm. The device should appear as /dev/ttyACM0. You can connect with kermit.

$ ls /dev | grep ttyACM
ttyACM0
$ kermit -l /dev/ttyACM0

C-Kermit 8.0.211, 10 Apr 2004, for Linux
 Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
C-Kermit> set carrier-watch off
C-Kermit> connect
<snip welcome message>
press enter to begin...

This gives you a simple command line interface to most of the NXP driver functions. You can find documentation for the functions included in ${HOME}/cortex-m3/LPC1700CMSIS.

Functions

list

You can call list to see all available functions.

[:)] list
<snip all functions>

Or for a more manageable subset, provide a start and the number of functions to display. Note that all arguments and return values are hexadecimal.


[:)] list 1 7
001 return
002 search
003 list
004 promptOn
005 promptOff
006 heartbeatOn
007 heartbeatOff
008 malloc
009 free
00a deref
00b roboveroConfig
00c resetConfig

The number beside the function name is its index in the function list. You can speed up function calls by using the index rather than the function name.

[:)] 3 1 c
001 return
002 search
003 list
004 promptOn
005 promptOff
006 heartbeatOn
007 heartbeatOff
008 malloc
009 free
00a deref
00b roboveroConfig
00c resetConfig

return

Your prompt indicates whether the previous operation succeeded.

[:)] somenonfunction
[:(] 

return is another mechanism for obtaining the return status.

[:)] return
0
[:)] somenonfunction
[:(] return
1
[:)] 

There are a couple of subtle points to understand here. First, return indicates the status of the command line, not of the function you are calling. For example, the function I2C_MasterTransferData might fail to transfer data on the I2C bus, and return will output 0 since the command line operation succeeded - the function was called. The second point is that return modifies the status variable. If you call a function that fails, and then accidentally call retrun the status of the previous operation is lost.

search

If you want to find the index of a function you can use search to find it.

[:)] search GPIO_SetValue
261 GPIO_SetValue

If you don't know the full name of the function you can search part of it.

[:)] search GPIO
24c GPIO_ClearInt
24d GPIO_GetIntStatus
24f GPIO_IntCmd
252 GPIO_ReadValue
25a GPIO_ClearValue
261 GPIO_SetValue
263 GPIO_SetDir
264 GPIO_Byte_TypeDef_malloc
265 GPIO_HalfWord_TypeDef_malloc
266 GPIO_HalfWord_TypeDef_FIODIRL
267 GPIO_HalfWord_TypeDef_FIODIRU
268 GPIO_HalfWord_TypeDef_FIOMASKL
269 GPIO_HalfWord_TypeDef_FIOMASKU
26a GPIO_HalfWord_TypeDef_FIOPINL
26b GPIO_HalfWord_TypeDef_FIOPINU
26c GPIO_HalfWord_TypeDef_FIOSETL
26d GPIO_HalfWord_TypeDef_FIOSETU
26e GPIO_HalfWord_TypeDef_FIOCLRL
26f GPIO_HalfWord_TypeDef_FIOCLRU

If you attempt to call a function that isn't found, search is called automatically.

[:)] GPIO_ClearIn
24c GPIO_ClearInt

promptOn/promptOff

These functions are used to enable/disable local echo and the command prompt. These are used by the Python Client Library. You will probably not use them unless you are writing your own interface for RoboVero (in C, bash, etc.).

[:)] promptOff
<types promptOn>
[:)]

heartbeatOn/heartbeatOff

If you want to disable the default heartbeat rhythm of the LED call heartbeatOff.

malloc

malloc allows you to allocate space in RoboVero RAM for data. The following command requests 16 bytes of memory and a pointer to heap space where the memory is allocated is returned.

[:)] malloc 10
10003900

free

Release a block of previously allocated memory back to the heap.

[:)] free 10003900

deref

Read or write the value stored at a given address. The first argument is the memory address, the second is the width (number of bytes) the value uses. If a third argument is provided the value is written, otherwise it is read.

[:)] malloc 4
10003900
[:)] deref 10003900 1
72
[:)] deref 10003900 2
4472
[:)] deref 10003900 4
a2094472
[:)] deref 10003900 4 0
[:)] deref 10003900 4
0
[:)] free 10003900

deref does not validate the memory address provided so you must exercise caution when using this function. A mistyped address could easily lead to a system fault requiring a reset.

roboveroConfig

roboveroConfig exists for users that want to quickly get using the RoboVero in its standard configuration. It automatically configures the pins according to their PCB labels and initializes peripherals. The intent is to reduce the overhead associated with using RoboVero. roboveroConfig is used in a number of the Python Client Library examples.

resetConfig

This is a convenience/safety function that simulates the effect of a reset on pin select registers without disconnecting USB. resetConfig is called automatically when a Python Client Library program terminates.

Library functions

A second group of functions wrap the LPC17xx CMSIS-Compliant Standard Peripheral Firmware Driver Library functions. Pass arguments to these functions as hexadecimal values and expect the same returned. For example, GPIO_SetValue and GPIO_ClearValue can be used to manually control the LED. First we need to disable the heartbeat.

[:)] heartbeatOff

Now we can turn the LED on. Since P3.25 controls the LED's cathode, we need to drive the pin low.

[:)] GPIO_ClearValue 3 2000000

This is equivalent to the following function call in C, which is used in the heartbeat function.

GPIO_ClearValue(3, (1<<25));

The command line interface does not resolve mathematical operations such as (1<<25) so anything beyond simple testing quickly becomes cumbersome using the command line. However, it is relatively simple to write a script that makes a series of function calls. This is precisely what the Python Client Library does, and a similar interface can be written in any language that supports serial communication.

Data functions

Interrupts

Interrupts are currently unimplement. Enabling an interrupt will most likely lead to very bad things.

Hardware

Error creating thumbnail: Unable to save thumbnail to destination

All you need to get started with RoboVero is a power source - a 5-15V battery or 5V power supply will do - and USB-A to Mini-B cable. Note that the RoboVero power supply is different from that of other expansion boards.

RoboVero is based on the NXP LPC1769 ARM Cortex-M3 microcontroller.

HubCommander

When an external machine is connected to the RoboVero USB Mini-B, it automatically takes control of the RoboVero USB subsystem.

Software

Prerequisites

You'll need to install git to retrieve some of the software for the toolchain.

$ sudo apt-get install gawk bison flex automake libtool libncurses5-dev zlib1g-dev libusb-dev eclipse eclipse-cdt unzip

Create a new folder in your home directory.

$ mkdir ${HOME}/cortex-m3

Toolchain

crosstool-NG

A cross compiler builds executable code for a platform other than the one on which the compiler runs. In our case, the toolchain (compiler, linker, debugger, etc.) will typically run on i386 or i686 and generate binaries for ARMv7-M. crosstool-NG is an application for building cross toolchains.

ARM Angstrom

Building the RoboVero toolchain for Overo takes hours and requires installing a number of non-standard packages. The easiest way to get started is to download the archive containing a pre-built toolchain and extract it to your home folder.

NOTE: This hasn't been tested with a clean build and may require additional packages.

# cd
# wget http://cumulus.gumstix.org/sources/robovero/x-tools.tar.gz
# tar -xzf x-tools.tar.gz

Your toolchain should appear in ${HOME}/x-tools. Process the the Exporting PATH section.

Other

Go to http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool to determine the current version of crosstool-NG

$ cd ${HOME}/cortex-m3
$ wget http://ymorin.is-a-geek.org/download/crosstool-ng/crosstool-ng-X.X.X.tar.bz2

Extract the archive

$ tar xjf crosstool-ng-X.X.X.tar.bz2
$ cd ${HOME}/cortex-m3/crosstool-ng-X.X.X

Install crosstool-ng

$ ./configure
$ make
$ make install

Make a new directory for the baremetal configuration file.

$ mkdir ${HOME}/cortex-m3/arm-eabi
$ cd ${HOME}/cortex-m3/arm-eabi
$ cp ${HOME}/cortex-m3/crosstool-ng-1.9.1/samples/arm-bare_newlib_cortex_m3_nommu-eabi/crosstool.config .config

Add gdb to the configuration and build the toolchain. The build will take around 30 minutes depending on your machine.

$ ct-ng menuconfig
Debug facilities  ---
 [*] gdb  ---
  [*]   Cross-gdb
$ ct-ng build

Exporting PATH

If the build succeeds your new toolchain will appear in ~/x-tools. Add to the PATH environment variable (where the system looks for binaries) by appending an export command to .bashrc. Open a new terminal and echo path to verify that the change has taken effect.

$ nano ${HOME}/.bashrc
export PATH="${HOME}/x-tools/arm-bare_newlib_cortex_m3_nommu-eabi/bin:$PATH"
[new terminal]
$ echo $PATH

LPC1700CMSIS

LPC1700CMSIS is a collection of source code and libraries to simplify writing firmware for the M3.

$ cd ${HOME}/cortex-m3
$ mkdir LPC1700CMSIS
$ cd LPC1700CMSIS
$ wget

http://ics.nxp.com/support/documents/microcontrollers/zip/lpc17xx.cmsis.driver.library.zip

$ unzip lpc17xx.cmsis.driver.library.zip

Test

Time to find out whether we can compile a project. Let's try to build the LPC1700CMSIS Driver Library.

$ cd ${HOME}/cortex-m3/LPC1700CMSIS/makesection
$ nano makeconfig
PROJ_ROOT         =${HOME}/cortex-m3/LPC1700CMSIS
CMCORE_TYPE       =CM3
DEVICE            =LPC17xx
MANUFACTURE       =NXP
TOOL              =gnu
DEBUG_MODE        =1
GNU_INSTALL_ROOT  =${HOME}/x-tools/arm-bare_newlib_cortex_m3_nommu-eabi
GNU_VERSION       =4.4.1
$ cd makerule/common
$ nano make.rules.environment

[remove path and .exe extension from tools - you might also need to change some backslashes]

$ cd ../LPC17xx
$ nano makefile.LPC17xx.gnu
TOOLCHAIN =arm-bare_newlib_cortex_m3_nommu-eabi
$ ${HOME}/cortex-m3/LPC1700CMSIS
$ make VERBOSE=yes

Take a look at the compiler messages to verify that arm-bare_newlib_cortex_m3_nommu-eabi-gcc and arm-bare_newlib_cortex_m3_nommu-eabi-ld are being invoked. If so, and you get no build errors, the toolchain is working. You can also try building one of the images in the Examples folder.

Debug Tools

FT2232

FT2232 is a serial protocol converter that provides JTAG connectivity to the Robovero and console port access to the Overo COM. We need to install the driver for JTAG to work.

Ubuntu

$ sudo apt-get install libftdi-dev

ARM Angstrom

# opkg install libftdi

Other

Go to http://www.intra2net.com/en/developer/libftdi/download.php to find the current libftdi release

$ cd ${HOME}/cortex-m3
$ wget http://www.intra2net.com/en/developer/libftdi/download/libftdi-X.X.tar.gz
$ tar xf libftdi-X.X.tar.gz
$ cd libftdi-X.XX/
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig

OpenOCD

Open On-Circuit Debugger (OpenOCD) provides debugging, in-system programming and boundary-scan testing for the Robovero. It connects the debug host (your development machine) to the target (cortex) through an adapter (FT2232). OpenOCD allows you to debug code running on the target with GDB.

ARM Angstrom

# wget http://cumulus.gumstix.org/sources/robovero/openocd_0.4-r0.6_armv7a.ipk
# opkg install openocd_0.4-r0.6_armv7a.ipk
# wget http://cumulus.gumstix.org/sources/lpc1769.cfg
# cp lpc1769.cfg /usr/share/openocd/scripts/target

Other

$ cd ${HOME}/cortex-m3
$ wget http://download.berlios.de/openocd/openocd-X.X.X.tar.bz2
$ tar xjf openocd-X.X.X.tar.bz2
$ cd openocd-X.X.X/
$ ./configure --enable-ft2232_libftdi
$ make
$ sudo make install
$ wget http://cumulus.gumstix.org/sources/lpc1769.cfg
$ sudo cp lpc1769.cfg /usr/local/share/openocd/scripts/target

Test

Plug in your device. And run OpenOCD to connect.

$ sudo openocd -f interface/openocd-usb.cfg -f target/lpc1769.cfg
Open On-Chip Debugger 0.4.0 (2011-01-06-19:17)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.berlios.de/doc/doxygen/bugs.html
500 kHz
Info : clock speed 500 kHz
Info : JTAG tap: lpc1768.cpu tap/device found: 0x4ba00477 (mfg: 0x23b, part: 0xba00, ver: 0x4)
Info : lpc1768.cpu: hardware has 6 breakpoints, 4 watchpoints

Firmware

The source for the firmware that ships with RoboVero is available via github. Follow these steps if you would like to contribute to the project or just use it as a reference.

$ cd
$ mkdir robovero
$ cd robovero
$ git clone git://github.com/robovero/firmware.git

The source will now appear in ${HOME}/robovero/firmware. Next, build and flash the firmware to your device. If your toolchain isn't at ${HOME}/x-tools you will have to modify the Makefile and PATH environment variable.

$ cd firmware
$ make

Start OpenOCD according to the above instructions if you haven't already. Open another terminal. We will flash using GDB.

$ wget http://cumulus.gumstix.org/sources/robovero/gdbconfig
$ x-tools/arm-bare_newlib_cortex_m3_nommu-eabi/bin/arm-bare_newlib_cortex_m3_nommu-eabi-gdb -x gdbconfig robovero/firmware/firmware
(gdb) load
(gdb) continue

If your LED starts to flash then your debug tools are working. You can press the RoboVero reset and the firmware will run without GDB.