Difference between revisions of "User:Pau pajuelo"

From IGEP - ISEE Wiki

Jump to: navigation, search
m
m
Line 1,163: Line 1,163:
 
}}  
 
}}  
  
ff
+
<br> __TOC__
  
   
+
<br>
{{Template:Navigation/IGEP Technology Guides/What can I do/Ending}}  
+
 
 +
= Overview  =
 +
 
 +
This is the 2/3 chapter of IGEPv2 Tutorial Guide.
 +
 
 +
We will learn some basic tasks such to send a file between IGEPv2 and your PC , handle the IGEPv2 Leds, update the pre-installed software to the latest release, etc.
 +
 
 +
<br>
 +
 
 +
= What can I do  =
 +
 
 +
== Handle the gpio-LED's  ==
 +
 
 +
'''Basic '''
 +
 
 +
In this tutorial, we are going to use the '''4 LED's available in the board''', which probably is the most simple feature in the board, but sometimes you may want LED's to be a way of checking the status of some of your applications.
 +
 
 +
You can easily '''turn LED's on and off''' using the 'echo' instruction.
 +
 
 +
Log into IGEPv2 (for example via SSH, as shown in the previous chapter), and run the following commands to turn LED's on:
 +
<pre>echo 1 &gt; /sys/devices/platform/leds-gpio/leds/d240\:green/brightness
 +
echo 1 &gt; /sys/devices/platform/leds-gpio/leds/d240\:red/brightness
 +
echo 1 &gt; /sys/devices/platform/leds-gpio/leds/d440\:green/brightness
 +
echo 1 &gt; /sys/devices/platform/leds-gpio/leds/d440\:red/brightness
 +
</pre>
 +
You can turn them down using the same command and write '0' instead of '1'.
 +
 
 +
<br> '''Know more '''
 +
 
 +
IGEPv2 LED's are controlled with it's platform device at /sys/devices/platform/leds-gpio/leds/
 +
 
 +
If you want to trigger the leds you can enable this mode and select the trigger source (none by default) to: mmc0, mmc1, timer, heartbeat and default-on.<br>
 +
 
 +
To enable any of this modes you just have to change a parameter in the directory of the led you want to control. You can see all the possibilities using the instruction 'cat':<br>
 +
<pre>$  cat /sys/devices/platform/leds-gpio/leds/d240\:green/trigger
 +
 
 +
[none] mmc0 mmc1 timer heartbeat default-on
 +
</pre>
 +
In the example above, we have checked the status of the trigger in led D240:green. Mode 'none' is selected.
 +
 
 +
To change it, for example, to the ''timer'' mode you can use 'echo':
 +
<pre>echo timer &gt; /sys/devices/platform/leds-gpio/leds/d240\:green/trigger
 +
</pre>
 +
In this case, we have set the trigger to the 'timer' mode. Now you can set the time for what the led is ON and the time it is OFF using:
 +
<pre>echo 250 &gt; /sys/devices/platform/leds-gpio/leds/d240\:green/delay_on
 +
echo 750 &gt; /sys/devices/platform/leds-gpio/leds/d240\:green/delay_off
 +
</pre>
 +
Now the selected led is configured with a timer consisting of 250 miliseconds ON and 750 miliseconds OFF.
 +
 
 +
<br>
 +
 
 +
== Send a file between your PC and IGEPv2 via SCP  ==
 +
 
 +
'''Basic '''
 +
 
 +
In a Linux host PC, you can use SCP (secure copy) via SSH to transfer files between IGEPv2 and your PC.
 +
 
 +
Now let's transfer a file called original.file in your host PC to IGEPv2 in /home/root/
 +
 
 +
In your Host PC open Terminal and type:
 +
 
 +
scp -r original.file root@&lt; IGEPv2 IP &gt;:/home/root/destination.file
 +
 
 +
You can repeat the process from the IGEPv2 console, and transfer a file from IGEPv2 to your Host PC.
 +
 
 +
<br>
 +
 
 +
== Update your pre-installed software  ==
 +
 
 +
=== Overview ===
 +
 
 +
#Download the latest firmware'''into an external computer'''
 +
#Uncompress the downloaded file
 +
#Create a MicroSD card in your external computer
 +
#Plug the MicroSD card to IGEPv2 and boot from it.
 +
 
 +
=== Requirements  ===
 +
 
 +
*a '''microSD card'''
 +
*a '''computer''' with microSD card reader (or with adapter)
 +
*a '''GNU/Linux distribution installed''' on the computer (a Linux partition or a virtual machine on Windows)
 +
**the main reason is that Windows does not detect multiple partitions on a microSD card
 +
 
 +
=== Basic  ===
 +
 
 +
We are now going to update the pre-installed software to the latest version.
 +
 
 +
{{#lst:How to create a SD-card with the latest software image|IGEPv2}}
 +
 
 +
<br>
 +
 
 +
== Flash the latest software image  ==
 +
 
 +
If you followed the previous section you have IGEPv2 with the latest firmware '''running from MicroSD card'''. But you might want to write the firmware to the flash memory, so '''you won't need the MicroSD card when booting''' the board.
 +
 
 +
The software provided by ISEE has a script that flashes the content of your MicroSD Card to the flash memory in your IGEPv2. You have to run this script, that is located at /opt/firmware directory.
 +
 
 +
Log into IGEPv2 and run the following commands:
 +
 
 +
cd /opt/firmware
 +
./flash.sh
 +
 
 +
This will last a few minutes. When it is ready, unplug the SD card from IGEPv2 and reboot the board:
 +
 
 +
reboot
 +
 
 +
You will have the new firmware running from IGEPv2 flash memory.
 +
 
 +
<br> '''Know more '''
 +
 
 +
IGEPv2 can run many other software distributions. Check the [[:Category:Software distributions]] to learn how to install other distributions.
 +
 
 +
<br>
 +
 
 +
== Basic instructions  ==
 +
 
 +
IGEPv2 is '''compatible with many Linux distributions'''. In this tutorial we are using Poky Linux, which is the pre-installed software from ISEE.
 +
 
 +
In case you are not familiar with Bash instructions, here comes some basic instructions to help you startup with the board.
 +
 
 +
First of all, '''log in to IGEPv2''' with a console from your host PC (via serial port or via SSH), as shown previous sections in this article. Remember the default settings:
 +
 
 +
login: root
 +
password: (none: press return)
 +
 
 +
Once you are logged in IGEPv2, run the following commands:
 +
 
 +
cd /
 +
ls
 +
 
 +
You have moved to the root directory, that is "/". The instruction "ls" lists all the existing files and directories in the current "path".
 +
 
 +
Now let's go to the directory /home/root/ with:
 +
 
 +
cd /home/root/
 +
 
 +
You can always check at which directory you are with the instruction:
 +
 
 +
pwd
 +
 
 +
Most instructions include a 'help' option that can be accessed by inserting the parameter --help. Check out the help page of 'echo' instruction, for example:
 +
 
 +
echo --help
 +
 
 +
You can try the instruction by yourself and type:
 +
 
 +
echo Hello
 +
 
 +
You have sent the text "Hello" to the standard output, that is the console you are interacting with.
 +
 
 +
But you can change and 'redirect' the output by using the character '&gt;'&nbsp;:
 +
 
 +
echo Hello world! &gt; /home/root/name.file
 +
 
 +
Now notice you have redirected the output to a file called name.file&nbsp;:
 +
 
 +
ls
 +
 
 +
You can append any file using '&gt;&gt;' instead of '&gt;'. You can print the content of the file to the standard output:
 +
 
 +
cat /home/root/name.file
 +
 
 +
'''Building a basic script'''
 +
 
 +
You can create a script that can run any instruction you want to use in Bash. The main advantage is that you do not have to compile the code, as is auto-interpereted by the system.
 +
 
 +
We are going to create a basic 'Hello World' script that is going to run the same command you have actually used before:
 +
 
 +
echo "echo Hello world!" &gt; /home/root/example.sh
 +
cat example.sh
 +
 
 +
Now you have created a file called example.sh, but by default it has no execute permissions (x):
 +
 
 +
ls -la
 +
 
 +
We are going to add permission to the file by:
 +
 
 +
chmod a+x example.sh
 +
ls -la
 +
 
 +
Now you can run the script:
 +
 
 +
./example.sh
 +
 
 +
You can edit this file (example.sh) with 'vi', the pre-installed text editor in IGEPv2.
 +
 
 +
vi example.sh
 +
 
 +
Press ESC and:
 +
 
 +
*&nbsp;:q! , to exit without saving
 +
*&nbsp;:w , to save
 +
*&nbsp;:wq , to quit and save
 +
*i , to insert text
 +
 
 +
'''Other simple &amp; useful instructions'''
 +
 
 +
*mkdir
 +
*rmdir
 +
*find
 +
*grep
 +
 
 +
You can stop any instruction by pressing CTRL+C
 +
 
 +
<br>
 +
 
 +
== Mount a MicroSD card  ==
 +
 
 +
'''Basic ''''
 +
 
 +
Log into IGEPv2 and run any of the following commands:
 +
 
 +
*Access to Generic FAT32 microSD:
 +
 
 +
mount -t vfat /dev/mmcblk0 /mnt/tmp/
 +
 
 +
*Access to Generic USB Flash disk:
 +
 
 +
mount -t vfat /dev/sda1 /mnt/tmp/
 +
 
 +
*Safety Remove microSD:
 +
 
 +
umount /mnt/tmp
 +
 
 +
*Access to IGEP demo microSD:
 +
 
 +
mount -t jffs2 /dev/mmcblk0 /mnt/tmp/
 +
 
 +
<br>
 +
 
 +
== How to use RS-485  ==
 +
 
 +
Follow the link to the extensive article: [[How to use RS485 on IGEP0020 board|How to use RS-485 on IGEPv2 board]]
 +
 
 +
<br>
 +
 
 +
== Get sound in (audio in)  ==
 +
 
 +
'''Basic '''
 +
 
 +
External Audio input devices, such as a powered microphone or the audio output of a PC or MP3 player, can be connected to the via a 3.5mm jack (Audio IN).
 +
 
 +
You can record audio in with the application Arecord, for example:
 +
 
 +
arecord -t wav -c 2 -r 44100 -f S16_LE -v audio-in.wav
 +
 
 +
Following output is expected on console:
 +
 
 +
Recording WAVE 'audio-in.wav'&nbsp;: Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
 +
Plug PCM: Hardware PCM card 0 'TWL4030' device 0 subdevice 0
 +
Its setup is:
 +
stream      &nbsp;: CAPTURE
 +
access      &nbsp;: RW_INTERLEAVED
 +
format      &nbsp;: S16_LE
 +
subformat  &nbsp;: STD
 +
channels    &nbsp;: 2
 +
rate        &nbsp;: 44100
 +
exact rate  &nbsp;: 44100 (44100/1)
 +
msbits      &nbsp;: 16
 +
buffer_size &nbsp;: 32768
 +
period_size &nbsp;: 2048
 +
period_time &nbsp;: 46439
 +
tick_time  &nbsp;: 7812
 +
tstamp_mode &nbsp;: NONE
 +
period_step &nbsp;: 1
 +
sleep_min  &nbsp;: 0
 +
avail_min  &nbsp;: 2048
 +
xfer_align  &nbsp;: 2048
 +
start_threshold &nbsp;: 1
 +
stop_threshold  &nbsp;: 32768
 +
silence_threshold: 0
 +
silence_size&nbsp;: 0
 +
boundary    &nbsp;: 1073741824
 +
 
 +
When ever you think you want to stop recording just press CTRL+C
 +
 
 +
<br>
 +
 
 +
== Get sound out (audio out)  ==
 +
 
 +
'''Basic '''
 +
 
 +
Connect an '''external output audio device''' to the 3.5mm jack Audio Out connector in IGEPv2, such as external stereo powered speakers.
 +
 
 +
The amplifiers for the headset output are disabled by default, so the first thing you'll do is enable these amplifiers with:
 +
 
 +
amixer set -D hw:0 'Headset' 0dB
 +
amixer set -D hw:0 'HeadsetL Mixer AudioL2' on
 +
amixer set -D hw:0 'HeadsetR Mixer AudioR2' on
 +
 
 +
Then you can easily play a *.wav sound with the application Aplay, for example:
 +
 
 +
aplay audio-in.wav
 +
 
 +
<br>
 +
 
 +
== Connect to the Serial Debug interface  ==
 +
 
 +
'''Basic '''
 +
 
 +
[[Image:DSC 0177.JPG|thumb|right|550px]]
 +
 
 +
In the preinstalled software, the serial port is configured as a '''Debug interface'''.
 +
 
 +
Therefore, if you connect an external device to the serial port you will be able to see the '''Linux Kernel traces''', as the system boots.
 +
 
 +
<br> Follow these steps:
 +
 
 +
*Connect an '''AT/Everex Cable''' to the '''10-pin serial header''' on IGEPv2 and a '''[http://en.wikipedia.org/wiki/Null_modem null modem] DB9 male-male''' serial cable between the board and your host machine.
 +
 
 +
*Refer to the article: '''[[How to setup the IDC10 cable|How to setup the IDC10 cable]]''' to setup the IDC10 cable.
 +
 
 +
*You can also use a Serial port in your host machine you might need a '''USB to Serial converter''' to communicate via this port.
 +
 
 +
*Run a serial console, or any program that can interact with the serial port in your host machine, such Minicom, PuTTy (Linux, Windows), Terminal (Windows), etc.
 +
 
 +
*Refer to this extended article about '''[[Using serial debug port to communicate]]''' to setup the right configuration of your serial console.
 +
 
 +
<br> Now, as you are connected to the '''serial debug port''', you will see the system traces as the board is starting up.
 +
 
 +
Finally you will see the boot prompt asking for login.
 +
 
 +
<br> [[Image:Poky-prompt-screenshot.png|thumb|center|550px]]
 +
 
 +
<br> {{Template:Navigation/IGEP Technology Guides/What can I do/Ending}}  
  
 
{{Table/IGEP Technology Devices
 
{{Table/IGEP Technology Devices

Revision as of 18:46, 7 August 2012

TODO:

Update peripheral tutorials

Categorize new tutorials

Upgrade ethernet gadget tutorial for new IGEP firmware and VM

Finish tutorials below

NOTES: Qt, Codeblocks and Eclipse are linked to main page:

Eclipse -> How to develop under Eclipse (copy manual) (refers at beginning VM and option to install Eclipse(under construction))

Qt -> How to develop under Qt (refers at begginin VM and option to install Qt (under construction))

Codeblocks (do it)


Adapt IGEPv2 to IGEPv2 Expansion

How to use SPI (prove with new firmware, under construction)

Overview

This How-To is meant to be a starting point for people to learn use SPI for IGEP devices as quickly and easily as possible. In this how-to, we run an example program that reads and writes registers from 3-axis accelerometer (LIS3DH) included on the board IGEP New York.

Requirements

There are some requisites to follow this guide:

  • IGEP SDK VM: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 2.3 "Setting up and running the VM")
  • IGEP Firmware: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 6.1 "Create IGEP firmware bootable micro-sd card")
  • IGEP COM MODULE and IGEP NEW YORK
  • SPI example program (link program)
  • MicroSD Card (at least 2Gbytes)

How Works

LIS3DH accelerometer: It is the accelerometer mounted in IGEP New York.

Omap3 SPI Peripheral: It is the hardware used to communicated with accelerometer and other SPI devices.

Omap2_mcspi: It is a bus driver than controls Omap3 SPI Peripheral.

Spi: It is a protocol driver that defines functions and strucs used in SPI bus.

Spidev: It is a device driver that export spi driver functionalities to userspace.

Lis3lv02d_spi: SPI glue layer for lis3lv02d

Lis31v02d: Device driver for LIS3DH accelerometer.

Exp_ilms0015: It is a startup program for IGEP New York. It attach lis31v02d with Spi driver.

Spi linux schematic.png


More information about Linux Kernel SPI at:

Prepare Micro SD Card

Generate Micro SD Card

Open a terminal and use the following steps to download and generate a Micro SD card.

wget http://downloads.isee.biz/denzil/binary/igep_firmware-yocto-1.2.1-1.tar.bz2 
tar jxf igep_firmware-yocto-*.tar.bz2
cd igep_firmware-yocto-* 

Insert a SD-Card media and use the igep-media-create script to copy the firmware.

./igep-media-create -–mmc <mmc> --image demo-image-sato-igep00x0.tar.bz2 --machine igep0030

where <mmc> - is the SD-Card device of your computer. For example, assuming the SD-card device takes '/dev/sdb' type:

./igep-media-create --mmc /dev/sdb --machine igep0030 --image demo-image-sato-igep00x0.tar.bz2 

This should give you a bootable SD-card with IGEP COM MODULE support.

NOTE: Use the following tutorial (upgrade it) to connect via Ethernet Gadget with IGEP COM MODULE

Custom Micro SD Card

"Include clone git commands"

Modify Linux Kernel Sources to attach Spidev to SPI driver

To read accelerometer registers from spidev, we need to attach spidev driver to spi driver at start up. So it is necessary to modify spi_board.

Go to $(Kernel path)/arch/arm/mach-omap2/exp-ilms0015.c and edit the next fields in bold words.

static struct spi_board_info lis3lv02d_spi_board_info __initdata = {

    .modalias = "spidev",

    //.modalias    = "lis3lv02d_spi",

    .bus_num    = -EINVAL,

    .chip_select    = -EINVAL,

    .max_speed_hz    = 1*1000*1000,

    .irq        = -EINVAL,

    .mode        = SPI_MODE_0,

   //.platform_data    = &lis3lv02d_pdata,

};

inline void __init ilms0015_lis3lv02d_init(int bus_num, int cs, int irq)

{

    struct spi_board_info *spi = &lis3lv02d_spi_board_info;

    if ((gpio_request(irq, "LIS3LV02D IRQ") == 0)

        && (gpio_direction_input(irq) == 0))

        gpio_export(irq, 0);

    else {

        pr_err("IGEP: Could not obtain gpio LIS3LV02D IRQ\n");

        return;

    }

    spi->bus_num = bus_num;

    spi->chip_select = cs;

    spi->irq = OMAP_GPIO_IRQ(irq),

    spi_register_board_info(&lis3lv02d_spi_board_info, 1);

}

...

void __init ilms0015_init(void)

{

    mux_partition = omap_mux_get("core");

    /* Mux initialitzation for ilms0015 */

    omap_mux_write_array(mux_partition, ilms0015_mux);

    /* 3-axis accelerometer */

    ilms0015_lis3lv02d_init(1, 2, 174);

    /* Export some GPIO */

    ilms0015_gpio_init();

}

Now spi_register_board_info has all information necessary to attach spidev driver instead lis3lv02d_spi.

Once we edit code, compile your modified Kernel, you can follow this tutorial for this purpose.

Enable ilms0015 support

“ilms0015” is the technical name of IGEP New York.

By default, poky-media-create (See: Poky firmware with Kernel 2.6.37.y) configured as igep0030, gives support only for IGEP Expansions Paris and Berlin. We need to configure igep.ini and gives support to IGEP New York:

 ; Machine configuration

    ;buddy=base0010 buddy.revision=B

    buddy=ilms0015

Test changes

Once you copy your new Kernel binaries and edit igep.ini. Power up your board, log in and check your changes:

root@igep00x0:/dev# lsmod

Module                  Size    Used by

rfcomm                48522   0

hidp                    13311   0

l2cap                   49001   4 rfcomm,hidp

bluetooth             67643   3 rfcomm,hidp,l2cap

libertas_sdio         13887   0

libertas                99318   1 libertas_sdio

option                 13044   0

usb_wwan              7196   1 option

usbserial              23870   2 option,usb_wwan

spidev                  4898   0 

root@igep00x0:/dev# ls /dev/spidev1.2

/dev/spidev1.2

“spidev1.2”: refers at McSPI1 bus 2. Now we can communicate to accelerometer using spi driver functions.

SPI Test program

Overview

This program is based in spidev_test and it was edited to run with LIS3DH accelerometer, program can be explained in four parts:

Connection properties: program lets change via parameters SPI configurations like: device, max speed, delay, bits per word, clock phase, clock polarity, etc. If you don't use any of this parameters program will use default options for LIS3DH communication.

Read mode: Reads a word from a register.

Write mode: Writes a word in a register.

Test mode: Reads X, Y and Z axes from accelerometer.

We recommend to read peripheral datasheet before use or modify program.

Compile program

The program source was compiled with Poky SDK but you can use other compilers like Linaro Toolchain:

arm-poky-linux-gnueabi-gcc spiexamplebeta2.c -o spiexampleb2  

Copy your final binary to rootfs.

Test program

Read WHO_AM_I register(0Fh)

LIS3DH has this dummy register (See 8.6 chapter) as a device identification. Its value is 0x33:

root@igep00x0:~# ./spiexampleb2 -R 0F 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 0F is: 33 
root@igep00x0:~#  

Read and Write CTRL_REG1 (20h)

This register is used to enable/disable: accelerometer and XYZ axes (See 8.8 chapter). The default value at startup is:

root@igep00x0:~# ./spiexampleb2 -R 20 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 20 is: 07 
root@igep00x0:~#  

It means that accelerometer was disabled and X, Y and Z axes was enabled. For example we can disable X axe typing:

root@igep00x0:~# ./spiexampleb2 -W 20 -V 06 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Register to write 20 with value 06 
root@igep00x0:~# ./spiexampleb2 -R 20      
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 20 is: 06 
root@igep00x0:~# 

Read accelerometer axes

Finally we are going to read gravity force: LIS3DH has ±2g/±4g/±8g/±16g dynamically selectable full scale (See chapter 8.11). The axes values are expressed in two’s complement in 16 bits (See chapters 8.16, 8.17 and 8.18). Lis3dhxyzaxes.png
root@igep00x0:~# ./spiexampleb2 -T 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Accelerometer TEST 
Values from X -64, Values from Y -15872 and Values from Z -256 
root@igep00x0:~# 

The next table shows results at different positions:

Position ±2g scale ±4g scale ±8g scale ±16g scale
NYtopimagetest.png
X = 832

Y = 1024

Z = 15680

X = 256

Y = 128

Z = 7872

X = 128

Y = 128

Z = 4032

X = 64

Y = 128

Z = 1280

NYbotimagetest.png

X = 256

Y = 704

Z = -17216

X = 256

Y = 256

Z = -8320

X = 64

Y = 128

Z = -4096

X = 128

Y = 128

Z = -1344

NYtophoritzontalimagetest.png

X = -15872

Y = 64

Z = -320

X = -7936

Y = 64

Z = -512

X = -3968

Y = 128

Z = -192

X = -1280

Y = 64

Z = -128

NYbothoritzontalimagetest.png

X = 16448

Y = 640

Z = 640

X = 8128

Y = 192

Z = 384

X = 4032

Y = 64

Z = 64

X = 1344

Y = 64

Z = 192

NYtopverticalimagetest.png

X = 896

Y = 16512

Z = -576

X = 320

Y = 8128

Z = -128

X = 192

Y = 4096

Z = -64

X = 128

Y = 1344

Z = -128

NYbotverticalimagetest.png

X = -64

Y = -15872

Z = -256

X = -512

Y = -7808

Z = -384

X = -64

>Y = -3840

Z = -384

X = -128

Y = -1216

Z = -128

BACKUP How to use SPI (prove with new firmware, under construction)

Overview

This How-To is meant to be a starting point for people to learn use SPI for IGEP devices as quickly and easily as possible. In this how-to, we run an example program that reads and writes registers from 3-axis accelerometer (LIS3DH) included on the board IGEP New York.

Requirements

There are some requisites to follow this guide:

  • IGEP SDK VM: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 2.3 "Setting up and running the VM")
  • IGEP Firmware: follow the IGEP SDK SOFTWARE USER MANUAL (chapter 6.1 "Create IGEP firmware bootable micro-sd card")
  • IGEP COM MODULE and IGEP NEW YORK
  • SPI example program (link program)
  • MicroSD Card (at least 2Gbytes)

How Works

LIS3DH accelerometer: It is the accelerometer mounted in IGEP New York.

Omap3 SPI Peripheral: It is the hardware used to communicated with accelerometer and other SPI devices.

Omap2_mcspi: It is a bus driver than controls Omap3 SPI Peripheral.

Spi: It is a protocol driver that defines functions and strucs used in SPI bus.

Spidev: It is a device driver that export spi driver functionalities to userspace.

Lis3lv02d_spi: SPI glue layer for lis3lv02d

Lis31v02d: Device driver for LIS3DH accelerometer.

Exp_ilms0015: It is a startup program for IGEP New York. It attach lis31v02d with Spi driver.

Spi linux schematic.png


More information about Linux Kernel SPI at:

Attach Spidev to SPI driver

Modify Linux Kernel Sources

To read accelerometer registers from spidev, we need to attach spidev driver to spi driver at start up. So it is necessary to modify spi_board.

Go to $(Kernel path)/arch/arm/mach-omap2/exp-ilms0015.c and edit the next fields in bold words.

static struct spi_board_info lis3lv02d_spi_board_info __initdata = {

    .modalias = "spidev",

    //.modalias    = "lis3lv02d_spi",

    .bus_num    = -EINVAL,

    .chip_select    = -EINVAL,

    .max_speed_hz    = 1*1000*1000,

    .irq        = -EINVAL,

    .mode        = SPI_MODE_0,

   //.platform_data    = &lis3lv02d_pdata,

};

inline void __init ilms0015_lis3lv02d_init(int bus_num, int cs, int irq)

{

    struct spi_board_info *spi = &lis3lv02d_spi_board_info;

    if ((gpio_request(irq, "LIS3LV02D IRQ") == 0)

        && (gpio_direction_input(irq) == 0))

        gpio_export(irq, 0);

    else {

        pr_err("IGEP: Could not obtain gpio LIS3LV02D IRQ\n");

        return;

    }

    spi->bus_num = bus_num;

    spi->chip_select = cs;

    spi->irq = OMAP_GPIO_IRQ(irq),

    spi_register_board_info(&lis3lv02d_spi_board_info, 1);

}

...

void __init ilms0015_init(void)

{

    mux_partition = omap_mux_get("core");

    /* Mux initialitzation for ilms0015 */

    omap_mux_write_array(mux_partition, ilms0015_mux);

    /* 3-axis accelerometer */

    ilms0015_lis3lv02d_init(1, 2, 174);

    /* Export some GPIO */

    ilms0015_gpio_init();

}

Now spi_register_board_info has all information necessary to attach spidev driver instead lis3lv02d_spi.

Once we edit code, compile your modified Kernel, you can follow this tutorial for this purpose.

Enable ilms0015 support

“ilms0015” is the technical name of IGEP New York.

By default, poky-media-create (See: Poky firmware with Kernel 2.6.37.y) configured as igep0030, gives support only for IGEP Expansions Paris and Berlin. We need to configure igep.ini and gives support to IGEP New York:

 ; Machine configuration

    ;buddy=base0010 buddy.revision=B

    buddy=ilms0015

Test changes

Once you copy your new Kernel binaries and edit igep.ini. Power up your board, log in and check your changes:

root@igep00x0:/dev# lsmod

Module                  Size    Used by

rfcomm                48522   0

hidp                    13311   0

l2cap                   49001   4 rfcomm,hidp

bluetooth             67643   3 rfcomm,hidp,l2cap

libertas_sdio         13887   0

libertas                99318   1 libertas_sdio

option                 13044   0

usb_wwan              7196   1 option

usbserial              23870   2 option,usb_wwan

spidev                  4898   0 

root@igep00x0:/dev# ls /dev/spidev1.2

/dev/spidev1.2

“spidev1.2”: refers at McSPI1 bus 2. Now we can communicate to accelerometer using spi driver functions.

SPI Test program

Overview

This program is based in spidev_test and it was edited to run with LIS3DH accelerometer, program can be explained in four parts:

Connection properties: program lets change via parameters SPI configurations like: device, max speed, delay, bits per word, clock phase, clock polarity, etc. If you don't use any of this parameters program will use default options for LIS3DH communication.

Read mode: Reads a word from a register.

Write mode: Writes a word in a register.

Test mode: Reads X, Y and Z axes from accelerometer.

We recommend to read peripheral datasheet before use or modify program.

Compile program

The program source was compiled with Poky SDK but you can use other compilers like Linaro Toolchain:

arm-poky-linux-gnueabi-gcc spiexamplebeta2.c -o spiexampleb2  

Copy your final binary to rootfs.

Test program

Read WHO_AM_I register(0Fh)

LIS3DH has this dummy register (See 8.6 chapter) as a device identification. Its value is 0x33:

root@igep00x0:~# ./spiexampleb2 -R 0F 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 0F is: 33 
root@igep00x0:~#  

Read and Write CTRL_REG1 (20h)

This register is used to enable/disable: accelerometer and XYZ axes (See 8.8 chapter). The default value at startup is:

root@igep00x0:~# ./spiexampleb2 -R 20 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 20 is: 07 
root@igep00x0:~#  

It means that accelerometer was disabled and X, Y and Z axes was enabled. For example we can disable X axe typing:

root@igep00x0:~# ./spiexampleb2 -W 20 -V 06 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Register to write 20 with value 06 
root@igep00x0:~# ./spiexampleb2 -R 20      
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Value from 20 is: 06 
root@igep00x0:~# 

Read accelerometer axes

Finally we are going to read gravity force: LIS3DH has ±2g/±4g/±8g/±16g dynamically selectable full scale (See chapter 8.11). The axes values are expressed in two’s complement in 16 bits (See chapters 8.16, 8.17 and 8.18). Lis3dhxyzaxes.png
root@igep00x0:~# ./spiexampleb2 -T 
spi mode: 0 
bits per word: 8 
max speed: 1000000 Hz (1000 KHz) 
Accelerometer TEST 
Values from X -64, Values from Y -15872 and Values from Z -256 
root@igep00x0:~# 

The next table shows results at different positions:

Position ±2g scale ±4g scale ±8g scale ±16g scale
NYtopimagetest.png
X = 832

Y = 1024

Z = 15680

X = 256

Y = 128

Z = 7872

X = 128

Y = 128

Z = 4032

X = 64

Y = 128

Z = 1280

NYbotimagetest.png

X = 256

Y = 704

Z = -17216

X = 256

Y = 256

Z = -8320

X = 64

Y = 128

Z = -4096

X = 128

Y = 128

Z = -1344

NYtophoritzontalimagetest.png

X = -15872

Y = 64

Z = -320

X = -7936

Y = 64

Z = -512

X = -3968

Y = 128

Z = -192

X = -1280

Y = 64

Z = -128

NYbothoritzontalimagetest.png

X = 16448

Y = 640

Z = 640

X = 8128

Y = 192

Z = 384

X = 4032

Y = 64

Z = 64

X = 1344

Y = 64

Z = 192

NYtopverticalimagetest.png

X = 896

Y = 16512

Z = -576

X = 320

Y = 8128

Z = -128

X = 192

Y = 4096

Z = -64

X = 128

Y = 1344

Z = -128

NYbotverticalimagetest.png

X = -64

Y = -15872

Z = -256

X = -512

Y = -7808

Z = -384

X = -64

>Y = -3840

Z = -384

X = -128

Y = -1216

Z = -128

How to install Qt Creator (under construction)

How to install Eclipse (under construction)

Getting started with IGEPv2 Expansion


Contents

Overview

This is the 1/3 chapter of IGEPv2 Expansion Tutorial Guide.

In this first chapter, we will learn how to connect some expansion peripherals.

Requirements (link items with isee shop)

In this tutorial we are going to use the following peripherals:

  • IGEPv2 with its power supply
  • a monitor compatible with VGA
  • a Powertrip 4.3" or Seiko 7" screen
  • a DB9 connector with External Serial peripheral (example: USB Serial convertor)
  • 4 pin connector for CAN Bus with another CAN Bus peripheral
  • SIM card (optional GPRS antenna)
  • Composite video cable with a composite video output peripheral
  • a PC with Linux or Windows

Getting started

Connect IGEPv2 Expansion with IGEPv2 Board

Basic

The IGEPv2 Expansion connects to the IGEPv2 Board through J990, JA41, JA42, JC30 and J960 connectors. Some IGEPv2 Expansion may include three jumpers, you should remove it because they are designed for test and lab purposes. Just take a look on the figure below:

Igepv2expconnectoigepv2.PNG
Igepv2expconnectoigepv2 2.PNG

Know more

The The IGEPv2 Expansion is the most complete board to expand the main features of the IGEPv2 Board:

  • Fully tested, highly reliable, scalable, efficient and high performing board that allows customers to focus on their end application.
  • Designed for industrial and commercial purposes.
  • LCD and Touch Interface (to be used with 7.0’’ Seiko RGB 24-bits TFT Display or 4.3’’ Powertip RGB 24-bits TFT Display)
  • GSM/GPRS Modem with SIM connector and RF Coaxial external antenna connector.
  • RS-232 Serial Interface on DB9 connector.
  • CAN bus interface.
  • Video decoder with 2 x RCA analog video inputs.
  • Camera interface.

TFT and Touchscreen

Basic

IGEP0022 PROTO RA DSC 0142.JPG
IGEPv2 Expansion integrates a LCD backlight driver (Texas instruments TPS61081) and touch screen controller (Texas instruments TSC2046), 4-wire touch screen controller which supports a low-voltage I/O interface which can be directly connected to a SEIKO 7” LCD or to a POWERTIP 4.3” LCD. Use J301 connector for POWERTRIP 4.3" or use J302, J303 and J304 connector for SEIKO 7".

Know more

IGEPv2 Expansion integrates LCD backlight driver (TPS61081) and touch screen controller (TSC2046), a 4-wire touch screen controller which supports a low voltage I/O interface from 1.5V to 5.25V.

Serial port

Basic
Igepv2expdb9connector.PNG

IGEPv2 Expansion integrates a DB9 RS232 connector.

Know more

This peripheral (UART1) can be used to debug system using kernel traces, getting a remote prompt, etc.


VGA monitor

Basic

Igepv2expvgaconnector.PNG
IGEPv2 Expansion integrates a VGA connector, the output VGA signal is equal to HDMI connector.

Know more

This output is controled by ADV7125KSTZ140 Integrated Circuit:

  • Triple 8-bit DACs
  • RS-343A-/RS-170-compatible output
  • Complementary outputs
  • DAC output current range: 2.0 mA to 26.5 mA
  • TTL-compatible inputs
  • Internal Reference (1.235 V)
  • HSYNC and VSYNC +5 V operation
  • 48-lead LQFP and LFCSP package

CAN bus

Basic

Igepv2expcanconnector.PNG
IGEPv2 Expansion integrates a 4 pin connector used for CAN communication. Connect any CAN bus device or network to the CAN bus connector.

Know more

This output is controled by MICROCHIP MCP2515:

  • Implements CAN V2.0B at 1 Mb/s
  • Receive buffers, masks and filters
  • Data byte filtering on the first two data bytes (applies to standard data frames)
  • High-speed SPI Interface (10 MHz): SPI modes 0,0 and 1,1

GSM/GPRS modem

Basic

IGEPv2 Expansion integrates a GSM/GPRS modem to make phone calls or to send SMS or to write and read data from it, etc. This peripheral needs:

Igepv2expcardreader.PNG
IGEP0022 Modem with antenna.png
SIM card GSM-GPRS antenna (optional)

Know more Modem chip Telit GE865 is a small GSM/GPRS Ball-Grid-Array BGA module with next main features:

  • Quad-band EGSM 850 / 900 / 1800 / 1900 MHz
  • GSM/GPRS protocol stack 3GPP Release 4 compliant
  • Output power

    - Class 4 (2W) @ 850 / 900 MHz
    - Class 1 (1W) @ 1800 / 1900 MHz

  • Control via AT commands according to 3GPP 27.005, 27.007
  • Control via Remote AT commands
  • Power consumption (typical values)

    - Power off: ‹ 62 uA
    - Idle (registered, power saving): 1.6 mA @ DRX=9

  • Serial port multiplexer 3GPP 27.010
  • TCP/IP stack access via AT commands
  • Sensitivity:

    - ≤- 107 dBm (typ.) @ 850 / 900 MHz
    - ≤- 106 dBm (typ.) @ 1800 / 1900 MHz

  • Extended temperature range

    - -40°C to +85°C (operational)
    - -40°C to +85°C (storage temperature)

  • RoHS compliant

Composite Video Decoder

Basic

Igepv2expvideocompositeconnector.PNG
IGEPv2 Expansion integrates two composite video connectors to decode analog input signal.

Know more

Analog input is decoded by TVP5151, its main blocks are:

  • Robust sync detector
  • ADC with analog processor
  • Y/C separation using four-line adaptive comb filter
  • Chrominance processor
  • Luminance processor
  • Video clock/timing processor and power-down control
  • Output formatter
  • I2C interface
  • VBI data processor
  • Macrovision detection for composite and S-video

Camera interface

Basic
Igepv2expcameraconnector.PNG
IGEPv2 Expansion integrates a 27 pin (J5) HIROSE Series FH26 (0.3mm pitch for flex circuit cable) for camera or image sensor input.

Know more

OMAP3 processor family has Camera Image Signal Processing (ISP) interface. ISP interface could to be connecting to CCD and CMOS image sensors.

Detailed features of ISP are:

  • CCD and CMOS Imager Interface
  • Memory Data Input
  • BT.601/BT.656 Digital YCbCr 4:2:2 (8-/10-Bit) Interface
  • Glueless Interface to Common Video Decoders
  • Resize Engine
  • Resize Images From 1/4x to 4x
  • Separate Horizontal/Vertical Control


----


You have successfully completed this chapter of the guide.


Igep forum.png If you have any question, don't ask to ask at the IGEP Community Forum or the IGEP Community Chat Irc.png


What can i do with igepv2 expansion



Overview

This is the 2/3 chapter of IGEPv2 Tutorial Guide.

We will learn some basic tasks such to send a file between IGEPv2 and your PC , handle the IGEPv2 Leds, update the pre-installed software to the latest release, etc.


What can I do

Handle the gpio-LED's

Basic

In this tutorial, we are going to use the 4 LED's available in the board, which probably is the most simple feature in the board, but sometimes you may want LED's to be a way of checking the status of some of your applications.

You can easily turn LED's on and off using the 'echo' instruction.

Log into IGEPv2 (for example via SSH, as shown in the previous chapter), and run the following commands to turn LED's on:

echo 1 > /sys/devices/platform/leds-gpio/leds/d240\:green/brightness
echo 1 > /sys/devices/platform/leds-gpio/leds/d240\:red/brightness
echo 1 > /sys/devices/platform/leds-gpio/leds/d440\:green/brightness
echo 1 > /sys/devices/platform/leds-gpio/leds/d440\:red/brightness

You can turn them down using the same command and write '0' instead of '1'.


Know more

IGEPv2 LED's are controlled with it's platform device at /sys/devices/platform/leds-gpio/leds/

If you want to trigger the leds you can enable this mode and select the trigger source (none by default) to: mmc0, mmc1, timer, heartbeat and default-on.

To enable any of this modes you just have to change a parameter in the directory of the led you want to control. You can see all the possibilities using the instruction 'cat':

$   cat /sys/devices/platform/leds-gpio/leds/d240\:green/trigger

[none] mmc0 mmc1 timer heartbeat default-on

In the example above, we have checked the status of the trigger in led D240:green. Mode 'none' is selected.

To change it, for example, to the timer mode you can use 'echo':

echo timer > /sys/devices/platform/leds-gpio/leds/d240\:green/trigger

In this case, we have set the trigger to the 'timer' mode. Now you can set the time for what the led is ON and the time it is OFF using:

echo 250 > /sys/devices/platform/leds-gpio/leds/d240\:green/delay_on
echo 750 > /sys/devices/platform/leds-gpio/leds/d240\:green/delay_off

Now the selected led is configured with a timer consisting of 250 miliseconds ON and 750 miliseconds OFF.


Send a file between your PC and IGEPv2 via SCP

Basic

In a Linux host PC, you can use SCP (secure copy) via SSH to transfer files between IGEPv2 and your PC.

Now let's transfer a file called original.file in your host PC to IGEPv2 in /home/root/

In your Host PC open Terminal and type:

scp -r original.file root@< IGEPv2 IP >:/home/root/destination.file

You can repeat the process from the IGEPv2 console, and transfer a file from IGEPv2 to your Host PC.


Update your pre-installed software

Overview

  1. Download the latest firmwareinto an external computer
  2. Uncompress the downloaded file
  3. Create a MicroSD card in your external computer
  4. Plug the MicroSD card to IGEPv2 and boot from it.

Requirements

  • a microSD card
  • a computer with microSD card reader (or with adapter)
  • a GNU/Linux distribution installed on the computer (a Linux partition or a virtual machine on Windows)
    • the main reason is that Windows does not detect multiple partitions on a microSD card

Basic

We are now going to update the pre-installed software to the latest version.



Flash the latest software image

If you followed the previous section you have IGEPv2 with the latest firmware running from MicroSD card. But you might want to write the firmware to the flash memory, so you won't need the MicroSD card when booting the board.

The software provided by ISEE has a script that flashes the content of your MicroSD Card to the flash memory in your IGEPv2. You have to run this script, that is located at /opt/firmware directory.

Log into IGEPv2 and run the following commands:

cd /opt/firmware
./flash.sh

This will last a few minutes. When it is ready, unplug the SD card from IGEPv2 and reboot the board:

reboot

You will have the new firmware running from IGEPv2 flash memory.


Know more

IGEPv2 can run many other software distributions. Check the Category:Software distributions to learn how to install other distributions.


Basic instructions

IGEPv2 is compatible with many Linux distributions. In this tutorial we are using Poky Linux, which is the pre-installed software from ISEE.

In case you are not familiar with Bash instructions, here comes some basic instructions to help you startup with the board.

First of all, log in to IGEPv2 with a console from your host PC (via serial port or via SSH), as shown previous sections in this article. Remember the default settings:

login: root
password: (none: press return)

Once you are logged in IGEPv2, run the following commands:

cd /
ls

You have moved to the root directory, that is "/". The instruction "ls" lists all the existing files and directories in the current "path".

Now let's go to the directory /home/root/ with:

cd /home/root/

You can always check at which directory you are with the instruction:

pwd

Most instructions include a 'help' option that can be accessed by inserting the parameter --help. Check out the help page of 'echo' instruction, for example:

echo --help

You can try the instruction by yourself and type:

echo Hello

You have sent the text "Hello" to the standard output, that is the console you are interacting with.

But you can change and 'redirect' the output by using the character '>' :

echo Hello world! > /home/root/name.file

Now notice you have redirected the output to a file called name.file :

ls

You can append any file using '>>' instead of '>'. You can print the content of the file to the standard output:

cat /home/root/name.file

Building a basic script

You can create a script that can run any instruction you want to use in Bash. The main advantage is that you do not have to compile the code, as is auto-interpereted by the system.

We are going to create a basic 'Hello World' script that is going to run the same command you have actually used before:

echo "echo Hello world!" > /home/root/example.sh
cat example.sh

Now you have created a file called example.sh, but by default it has no execute permissions (x):

ls -la

We are going to add permission to the file by:

chmod a+x example.sh
ls -la

Now you can run the script:

./example.sh

You can edit this file (example.sh) with 'vi', the pre-installed text editor in IGEPv2.

vi example.sh

Press ESC and:

  •  :q! , to exit without saving
  •  :w , to save
  •  :wq , to quit and save
  • i , to insert text

Other simple & useful instructions

  • mkdir
  • rmdir
  • find
  • grep

You can stop any instruction by pressing CTRL+C


Mount a MicroSD card

Basic '

Log into IGEPv2 and run any of the following commands:

  • Access to Generic FAT32 microSD:
mount -t vfat /dev/mmcblk0 /mnt/tmp/
  • Access to Generic USB Flash disk:
mount -t vfat /dev/sda1 /mnt/tmp/
  • Safety Remove microSD:
umount /mnt/tmp
  • Access to IGEP demo microSD:
mount -t jffs2 /dev/mmcblk0 /mnt/tmp/


How to use RS-485

Follow the link to the extensive article: How to use RS-485 on IGEPv2 board


Get sound in (audio in)

Basic

External Audio input devices, such as a powered microphone or the audio output of a PC or MP3 player, can be connected to the via a 3.5mm jack (Audio IN).

You can record audio in with the application Arecord, for example:

arecord -t wav -c 2 -r 44100 -f S16_LE -v audio-in.wav

Following output is expected on console:

Recording WAVE 'audio-in.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Plug PCM: Hardware PCM card 0 'TWL4030' device 0 subdevice 0
Its setup is:
stream       : CAPTURE
access       : RW_INTERLEAVED
format       : S16_LE
subformat    : STD
channels     : 2
rate         : 44100
exact rate   : 44100 (44100/1)
msbits       : 16
buffer_size  : 32768
period_size  : 2048
period_time  : 46439
tick_time    : 7812
tstamp_mode  : NONE
period_step  : 1
sleep_min    : 0
avail_min    : 2048
xfer_align   : 2048
start_threshold  : 1
stop_threshold   : 32768
silence_threshold: 0
silence_size : 0
boundary     : 1073741824

When ever you think you want to stop recording just press CTRL+C


Get sound out (audio out)

Basic

Connect an external output audio device to the 3.5mm jack Audio Out connector in IGEPv2, such as external stereo powered speakers.

The amplifiers for the headset output are disabled by default, so the first thing you'll do is enable these amplifiers with:

amixer set -D hw:0 'Headset' 0dB
amixer set -D hw:0 'HeadsetL Mixer AudioL2' on
amixer set -D hw:0 'HeadsetR Mixer AudioR2' on

Then you can easily play a *.wav sound with the application Aplay, for example:

aplay audio-in.wav


Connect to the Serial Debug interface

Basic

DSC 0177.JPG

In the preinstalled software, the serial port is configured as a Debug interface.

Therefore, if you connect an external device to the serial port you will be able to see the Linux Kernel traces, as the system boots.


Follow these steps:

  • Connect an AT/Everex Cable to the 10-pin serial header on IGEPv2 and a null modem DB9 male-male serial cable between the board and your host machine.
  • You can also use a Serial port in your host machine you might need a USB to Serial converter to communicate via this port.
  • Run a serial console, or any program that can interact with the serial port in your host machine, such Minicom, PuTTy (Linux, Windows), Terminal (Windows), etc.


Now, as you are connected to the serial debug port, you will see the system traces as the board is starting up.

Finally you will see the boot prompt asking for login.


Poky-prompt-screenshot.png


----


You have successfully completed this chapter of the guide.


Continue this tutorial guide: 3/3 - Start developing under IGEP Technology
Igep forum.png If you have any question, don't ask to ask at the IGEP Community Forum or the IGEP Community Chat Irc.png