Difference between revisions of "What can I do with IGEP SMARC iMX6"

From IGEP - ISEE Wiki

Jump to: navigation, search
m (Install firmware in eMMC)
Line 121: Line 121:
 
Then you can easily play a *.wav sound with the application Aplay, for example:
 
Then you can easily play a *.wav sound with the application Aplay, for example:
  
  $ aplay /media/root/rootfs/usr/share/sounds/alsa/Side_Left.wav
+
  $ aplay /usr/share/sounds/alsa/Side_Left.wav
  
 
== Get sound in (audio in) ==
 
== Get sound in (audio in) ==
Line 358: Line 358:
 
Then you can easily play a *.wav sound with the application Aplay, for example:
 
Then you can easily play a *.wav sound with the application Aplay, for example:
  
  $ aplay -D plughw:1,0 /media/root/rootfs/usr/share/sounds/alsa/Side_Left.wav  
+
  $ aplay -D plughw:1,0 /usr/share/sounds/alsa/Side_Left.wav  
  
 
== Secondary HDMI (DVI connector on J501) ==
 
== Secondary HDMI (DVI connector on J501) ==

Revision as of 13:19, 1 August 2016


Overview

This is the 2/3 chapter of the Getting Started with IGEP SMARC iMX6 Tutorial Guide.

In this second chapter, we will learn some basics tasks. Upon completion, you will be ready to continue with chapter 3/3 that explains more advanced tasks.



What can I do

You must logged in the board.

Handle the GPIO-LEDS

The board has two user bicolor (green/red) leds available that can be controlled. In its simplest form, you can control of LEDs from userspace. LEDs appear in /sys/class/leds and you can turn on and off with following commands:

echo 1 > /sys/class/leds/igep\:red\:led1/brightness
echo 1 > /sys/class/leds/igep\:red\:led0/brightness
echo 0 > /sys/class/leds/igep\:red\:led1/brightness
echo 0 > /sys/class/leds/igep\:red\:led0/brightness
echo 1 > /sys/class/leds/igep\:green\:led1/brightness
echo 1 > /sys/class/leds/igep\:green\:led0/brightness
echo 0 > /sys/class/leds/igep\:green\:led1/brightness
echo 0 > /sys/class/leds/igep\:green\:led0/brightness

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/class/leds/igep\:red\:led0/trigger

[none] mmc0 mmc1 timer heartbeat default-on

In the example above, we have checked the status of the trigger in led red\led0. Mode 'none' is selected.

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

echo timer > /sys/class/leds/igep\:red\:led0/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/class/leds/igep\:red\:led0/delay_on
echo 750 > /sys/class/leds/igep\:red\:led0/delay_off

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

The base has two user (red/blue) leds available that can be controlled. Can't use them in the same time. In its simplest form, you can control of LEDs from userspace. LEDs appear in /sys/class/leds/base and you can turn on and off with following commands:

echo 1 > /sys/class/leds/base\:blue\:led0/brightness
echo 1 > /sys/class/leds/base\:red\:led0/brightness
echo 0 > /sys/class/leds/base\:blue\:led0/brightness
echo 0 > /sys/class/leds/base\:red\:led0/brightness

How to use S1200 pushbutton

The board has one pushbutton. You can see with following commands:

cd /dev/input
cat event0

Next step: push the button.

How to use UART (RS485)

under construction

CAN BUS

To be able to communicate the board via CAN bus, we will use can0 interface and the J1002 connector. We can communicate with another IGEP0046 or an IGEP0030 (via J9001 in IGEP BERLIN), but also with a wide variety of CAN sensors and devices. In this example, we use an IGEP0046 and an IGEP0030 on a BASE0010 IGEP BERLIN. The connections are as depicted below:
CAN BUS CONNECTION IGEP0046.PNGCAN BUS CONNECTION IGEP0046 BASE0010.PNG

  • We must, first of all, set the interface up in each device. We can do it with ip commands:
ip link set can0 up type can bitrate 125000

Where can0 is the interface we will use

  • Then we must choose who will send data and who will receive it; for the one to receive we will use the following line:
candump can0

Where can0 is the interface we will use

  • For the one to send CAN data, we will use the following command:
cansend can0 -i 0x123 0xaa 0xbb 0xcc 0xdd

Where can0 is the interface we will use, -i 0x123 is used to identify the device as 0x123, and 0xaa 0xbb 0xcc 0xdd, the data to be sent.

  • We should get this in the CAN receiver:
<0x123> [4] aa bb cc dd
  • To stop receiving data, press Ctrl+C in the listening device.

Get sound out (audio out)

Connect an external output audio device to the 3.5mm jack Audio Out connector in the board, 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 'PCM' 0dB
$ amixer set -D hw:0 'HP DAC' 0dB

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

$ aplay /usr/share/sounds/alsa/Side_Left.wav

Get sound in (audio in)

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: Direct Snoop PCM
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  : 15876
 period_size  : 1764
 period_time  : 40000
 tstamp_mode  : NONE
 period_step  : 1
 avail_min    : 1764
 period_event : 0
 start_threshold  : 1
 stop_threshold   : 15876
 silence_threshold: 0
 silence_size : 0
 boundary     : 2080899072

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

Get microphone in (audio in)

Connect an external microphone in the MIC-N connector.

Enable for the input microphone:

$ amixer -c 0 sset 'Right PGA Mixer Mic3R' on
$ amixer -c 0 sset 'Left PGA Mixer Mic3L' on
$ amixer -c 0 sset 'Right PGA Mixer Line1R' off
$ amixer -c 0 sset 'Left PGA Mixer Line1L' off

You can record microphone in with the application arecord, for example:

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

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

Install firmware in eMMC

In order to access the eMMC and be capable of flashing it, we can make use of igep-flash script:

  • Launch the script from terminal specifying the image you want to flash in eMMC. The script itself searches for the device to flash, so no more parameters are needed:
igep-flash --image /opt/firmware/isee-image-dev-imx6*-igep0046.tar* --skip-nandtest

Where /opt/firmware/isee-image-dev-imx6*-igep0046.tar* is the image you want to flash (in this case, the one supplied from ISEE with the official firmware), and --skip-nandtest is an option to skip checking for bad blocks (this accelerates the process, and it's optional if you don't mind bad blocks on eMMC)

  • LEDs near U1200 should flash in orange while the eMMC is being written. They will flash in green when process successfully finishes.
  • We can also use the UMS (U-boot Mass Storage gadget).
  • Plug a microUSB to USB cable from J602 USB OTG connector to your computer. Boot the board from the microSD card and abort autoboot pressing a key when U-boot is waiting before loading the kernel. Then, start UMS with the following command:
ums 0 mmc 1

Where 0 is the USB device number 0 (USB OTG, in this case), mmc is the kind of storage device to be read (mmc or sata), and 1 is the storage device number, in this case mmc1 (onboard eMMC).

  • If correctly done, U-boot should print something similar to the next line, and a mass storage device should appear in your computer.
UMS: disk start sector: 0x0, count: 0xe90000
  • To stop UMS, press Ctrl+C and the mass storage device in your computer should disappear.

Boot from SATA

As specified in SMARC the booting device can be chosen by a combination of jumpers. To boot from carrier SATA, a SATA disk must be present in J1103 mSATA connector, and no jumpers should be connected in J1202, leaving BOOT0, BOOT1 and BOOT2 pulled down to GND. For more information, refer to SMARC Hardware Specification Guide.

Boot from eMMC

As specified in SMARC the booting device can be chosen by a combination of jumpers. To boot from module eMMC Flash, jumpers should be connected to BOOT1 and BOOT2 in J1202, leaving BOOT0 pulled down to GND. For more information, refer to SMARC Hardware Specification Guide.

How to use EEPROM

EEPROM can be read and write via /sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0050/eeprom:

  • Write EEPROM:
echo "data" > /sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0050/eeprom 
  • Read EEPROM:
cat /sys/devices/soc0/soc.0/2100000.aips-bus/21a8000.i2c/i2c-2/2-0050/eeprom
  • Following output is expected on console:
data
  • EEPROM is where UBoot environment variables are stored, so if you see something else than what you wrote, it's part of those variables.

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

How to use SPI NOR

Can be read and write files into SPI NOR:

  • Create a directory:
mkdir Documents 
  • Create a file in the directory:
cd Documents/
  • Write something in the file:
echo "data" > prova
  • Write the file into SPI NOR:
mtd_debug write /dev/mtd0 0 1 ./Documents/prova
  • Read the file:
mtd_debug read /dev/mtd0 0 1 prova


IO expansion

under construction

Wifi

In this example, we will connect to an Access Point.

  • First of all, we must disable Soft Blocking on the wlan0 interface via rfkill:
rfkill unblock 0
  • Then we can set the interface up:
ifconfig wlan0 up
  • We can scan for Access Points if we don't know its exact SSID:
iw wlan0 scan
  • Then we proceed to connect to our Access Point:
  • In case our Access Point is WPA secured, we can use wpa_supplicant to connect. For this purpose, we should configure /etc/wpa_supplicant.conf file:
network={
        ssid="IGEP_example"
        proto=WPA2
        key_mgmt=WPA-PSK
        psk="password"
}
To start the supplicant, we specify the interface, the configuration file and the driver to be used. In this case:
wpa_supplicant -Dnl80211 -i wlan0 -c wpa_supplicant.conf
  • On the other hand, if it is a WEP secured Access Point, you must enter the next command. If your AP doesn't have a password, omit the key part:
iw wlan0 connect IGEP_example key 0:12345
  • Then you can configure your device as you would normally do.
  • After a few seconds, the link should be established. We can now check the connection pinging a known server, for example:
ping www.google.com
  • If you want to set an Access Point up with the Wilink8 chip, you should use hostapd.
hostapd /etc/hostapd.conf &
  • After some seconds, the Access Point should be up and working. Its SSID is "test" if using the official firmware. You can now connect to the board via wifi without the need of an external AP or network.

HDMI resolution

In order to configure HDMI resolution, we must pass the correct parameters to the kernel using UBoot.

  • Stop autoboot by pressing a key when prompted to access terminal and type:
printenv
  • Then change hdmi resolution by changing video_args_hdmi:
setenv video_args_hdmi setenv video_args $video_args video=mxcfb${fb}:dev=hdmi,1920x1080M@60,if=RGB24

Where 1920 is horizontal resolution in pixels, 1080 is vertical resolution in pixels, and 60 is the refresh rate in Hz.

  • In userspace, you can check available resolutions:
cat /sys/devices/soc0/fb.19/graphics/fb0/modes
  • You can also show current resolution:
fbset

Which would return something like this:

mode "1280x720-60"
    # D: 74.250 MHz, H: 45.000 kHz, V: 60.000 Hz
    geometry 1280 720 1280 720 16
    timings 13468 220 110 20 5 40 5
    hsync high
    vsync high
    rgba 5/11,6/5,5/0,0/0
endmode
  • Supported iMX6 resolutions are:


Resolution Refresh Rate
1920x1080p 60 Hz
50 Hz
30 Hz
25 Hz
24 Hz
1440x576p 50 Hz
1440x480p 60 Hz
1440x288p 50 Hz
1440x240p 60 Hz
1280x720p 120 Hz
100 Hz
60 Hz
50 Hz
720x576p 50 Hz
720x480p 60 Hz
640x480p 60 Hz
59 Hz

HDMI audio

Connect the HDMI connector to a monitor with speakers.

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

$ aplay -D plughw:1,0 /usr/share/sounds/alsa/Side_Left.wav 

Secondary HDMI (DVI connector on J501)

under construction

Modem USB

  • In order to connect to the GSM network, you need to connect a modem in the J1100 connector and insert a SIM card in J1102. Then, when powering up the board, kernel should recognise the modem and list it under /dev/ as a list of ttyUSB devices. We are using a Quectel UC20 Modem, in this case.
  • From userspace, we must use a serial console to communicate with the modem via AT commands:
microcom -s 115200 /dev/ttyUSB2
  • Once the serial console is set, we can interact with the modem. In this example, we check the modem status, ask if the SIM card is activated or needs a pin code to be entered, enter the pin number and check signal level:
AT
OK
AT+CPIN?
+CPIN: SIM PIN

OK
AT+CPIN=1234
OK

+CPIN: READY

+QUSIM: 1

+QIND: SMS DONE

+QIND: PB DONE
AT+CSQ
+CSQ: 99,99

OK

Where 1234 is your SIM card's pin number.

  • +CSQ: 99,99 denotes an undetectable signal. If we use an antenna, we can get better coverage. Here you can find a table with the relationship between CSQ value and dBm, as well as a guide to recognise how strong a signal level is.
  • You can find more Quectel UC20 compatible AT commands here.


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