DART-SD410 Android Examples: Difference between revisions

From Variscite Wiki
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PageHeader|DART-SD410 - Using Peripherals}} __toc__
{{PageHeader|DART-SD410 - Using Peripherals}} __toc__


This WIKI describes how to use some simple peripheral devices available on VAR-DT410CustomBoard.
This WIKI describes how to use some simple peripheral devices available on VAR-SD410CustomBoard.
=Using User LED=
=Using user LED=
User LED1 (D6) connected to GPIO21 of the CPU.
User LED1 (D6) connected to GPIO21 of the CPU.
The LED1 is defined in the apq8016-var-dt410.dtsi file under gpio-leds section.
The LED1 is defined in the apq8016-var-sd410.dtsi file under gpio-leds section.
<pre>
<pre>
general1 {
general1 {
Line 39: Line 39:


= Using GPIO =
= Using GPIO =
User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-dt410.dtsi file under gpio-leds section.</br>
User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-sd410.dtsi file under gpio-leds section.</br>
This allow user acces to this LED as GPIO device.
This allow user acces to this LED as GPIO device.
To change the state of the LED via serial console type:
To change the state of the LED via serial console type:
Line 117: Line 117:


= Using RTC =
= Using RTC =
There are two RTC devices defined in the system. One is inside DART-SD410 PMIC chip and the second is on VART-DT410CustomBoard.<br/>
There are two RTC devices defined in the system. One is inside DART-SD410 PMIC chip and the second is on VART-SD410CustomBoard.<br/>
The main RTC device is DS1307 that is assembled on VART-DT410CustomBoard.
The main RTC device is DS1307 that is assembled on VART-SD410CustomBoard.
It can be accessed via console in the following manner:
It can be accessed via console in the following manner:
<pre>
<pre>
Line 149: Line 149:
Wait for 5 minutes, plug the power in and verify RTC is still running.<br/>
Wait for 5 minutes, plug the power in and verify RTC is still running.<br/>


= Recording and Playing Sound file =
= Recording and Playing sound file =
To record simple wav file from the headset use the following scenario:
To record simple wav file from the headset use the following scenario:
* Plug in standard cellphone headset into Headset Jack (J15) We used Samsung headset.
* Plug in standard cellphone headset into Headset Jack (J15) We used Samsung headset.
Line 177: Line 177:
</pre>
</pre>


= Capturing Screen snapshot =
= Capturing screen snapshot =
To save the screen contents to a file use:
To save the screen contents to a file use:
<pre>
<pre>
Line 185: Line 185:
</pre>
</pre>


= Recording Screen =
= Recording screen =
To record a video file with screen activity use:
To record a video file with screen activity use:
<pre>
<pre>
Line 193: Line 193:
The file screen.avi is created in the /sdcard folder
The file screen.avi is created in the /sdcard folder
</pre>
</pre>
= Switching Screen =
= Switching screen =
Switching screens is done via Fastboot.
Switching screens is done via Fastboot.
To switch follow the scenario:
To switch follow the scenario:
* Connect USB cable between Host PC and VAR-DT410CustomBoard (J20)
* Connect USB cable between Host PC and VAR-SD410CustomBoard (J20)
* Press on Back button (SW8)
* Press on Back button (SW8)
* Cycle the power or press Reset button (SW1)
* Cycle the power or press Reset button (SW1)
Line 211: Line 211:
</pre>
</pre>


= Capturing Camera image =
= Capturing camera image =
Capture the camera image can be done using GUI or via console.<br/>
Capture the camera image can be done using GUI or via console.<br/>
To capture the Camera image from console use the following:<br/>
To capture the Camera image from console use the following:<br/>
Line 232: Line 232:
</pre>
</pre>


= Testing Internet connection =
= Testing internet connection =
The wired Ethernet controller connected to DART-SD410 USB port.<br>
The wired Ethernet controller connected to DART-SD410 USB port.<br>
To use it the USB Device connector (J20) should not be connected.<br>
To use it the USB Device connector (J20) should not be connected.<br>
Line 244: Line 244:
The output will show the ping responces
The output will show the ping responces
</pre>
</pre>
= Rotating LVDS screen =
= Rotating LVDS screen =
There is no sensors on the VAR-DT410CustomBoard so automatic screen rotation is not available.<br>
There is no sensors on the VAR-SD410CustomBoard so automatic screen rotation is not available.<br>
To rotate LVDS display the property 'persist.panel.orientation' can be changed.<br>
To rotate LVDS display the property 'persist.panel.orientation' can be changed.<br>
<pre>
<pre>
Line 254: Line 255:
# setprop persist.panel.orientation 270
# setprop persist.panel.orientation 270
</pre>
</pre>
= Measuring current consumption =
VAR-SD410CustomBoard allow current consumption measurement by removing resistor R56 and connecting ampere-meter instead.<br>
The current consumption is highly depends on the applications running on the Dart-SD410.<br>
Normally the on-board Ethernet controller prevents the Android to go into memory retention mode, so the serial terminal is accessible all the time.<br>
In order to allow the Android enter memory retention state the Ethernet controller should be removed by:
<pre>
$ su
# echo 1 > /sys/bus/usb/devices/1-1.3/remove
This will remove the driver of Ethernet controller device and power down the LAN7500 chip.
# echo mem > /sys/power/state
This will force the Android to enter memory retention mode.
This step is optional, Android will enter memory retention mode by itself when it will be Idle
</pre>
Pressing PWR button will resume the system and the Ethernet controller chip will be connected back to the system.
= Reseting the system =
The system reset can be done via:
*Serial console by entering:
<pre>
$ reboot
</pre>
*By pressing PWR button for 0.5sec.<br> The Power menu will appear and pressing on Power Off option will reboot the system.
*Pressing the PWR button for 3sec will forcefully reset the CPU.
*Power down the DART-SD410 should be done by disconnecting the power supply.

Latest revision as of 13:52, 19 April 2016

DART-SD410 - Using Peripherals

This WIKI describes how to use some simple peripheral devices available on VAR-SD410CustomBoard.

Using user LED

User LED1 (D6) connected to GPIO21 of the CPU. The LED1 is defined in the apq8016-var-sd410.dtsi file under gpio-leds section.

general1 {
	gpios = <&msm_gpio 21 0>;
	label = "led1";
	linux,default-trigger = "none";
	default-state = "off";
	retain-state-suspended;
};

You can access the LED device via serial console by:

$ su 
# cd /sys/class/leds/led1
# echo 1 > brightness
Writing any value other then 0 will turn the led on
# echo 0 > brightness
The led will turn off

You can view available triggers by typing:

# cat trigger
The output will be:
[none] boot-indication usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid wlan-indication-led

Set the trigger to mmc0 device by typing:

# echo mmc0 > trigger

Test it by reading mmc0 device:

# dd if=/dev/block/mmcblk0 of=/dev/null bs=128 count=1000000

Using GPIO

User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-sd410.dtsi file under gpio-leds section.
This allow user acces to this LED as GPIO device. To change the state of the LED via serial console type:

$ su
# cd /sys/class/gpio
# echo 1022 > export
This line creates a new directory gpio1022
The number 1022 calculated as 120 + 902. 120 is the GPIO number, 902 is static offset for CPU gpio.
So changing any other GPIO will lead to 902 + GPIO number.
# cd gpio1022
# echo out > direction
# echo 1 > value
The led will turn on
#echo 0 > value
The led will turn off

To read the current state type:

# cat value
The output will be 0

You can change active state to active low.

# echo 1 > active_low
# echo 0 > value
The led is active low, writing 0 will turn on the led.
# echo 1 > value
The led is active low, writing 1 will turn off the led.

The Boot Select switch (SW3) connected to CPU GPIO81 to read its value use:

# cd /sys/class/gpio
# echo 983 > export
# cd gpio983
# cat value
If the switch is in OFF position the output is 0.
If the switch is in ON position the output is 1.

To see all allocated GPIOs in the system type:

# cat /sys/kernel/debug/gpio
The output will be:
GPIOs 577-608, platform/qcom,smp2pgpio-ssr-smp2p-4-out.19, master-kernel:
GPIOs 609-640, platform/qcom,smp2pgpio-ssr-smp2p-4-in.18, slave-kernel:
GPIOs 641-672, platform/qcom,smp2pgpio-ssr-smp2p-1-out.13, master-kernel:
GPIOs 673-704, platform/qcom,smp2pgpio-ssr-smp2p-1-in.12, slave-kernel:
GPIOs 705-736, platform/qcom,smp2pgpio-smp2p-4-out.16, smp2p:
GPIOs 737-768, platform/qcom,smp2pgpio-smp2p-4-in.14, smp2p:
GPIOs 769-800, platform/qcom,smp2pgpio-smp2p-1-out.10, smp2p:
GPIOs 801-832, platform/qcom,smp2pgpio-smp2p-1-in.8, smp2p:
GPIOs 833-864, platform/qcom,smp2pgpio-smp2p-7-out.6, smp2p:
GPIOs 865-896, platform/qcom,smp2pgpio-smp2p-7-in.4, smp2p:
GPIOs 897-900, spmi/qpnp-pin-ffffffc0319b4c00, pm8916-gpio:
 gpio-899 (qcom,hub-reset-gpio ) out hi
 gpio-900 (qcom,sw-sel-gpio    ) in  lo
GPIOs 901-901, spmi/qpnp-pin-ffffffc0319b4800, pm8916-mpp:
GPIOs 902-1023, platform/1000000.pinctrl, msm_tlmm_gpio:
 gpio-914 (ft5x06_reset_gpio   ) out hi
 gpio-915 (ft5x06_irq_gpio     ) in  hi
 gpio-922 (adv7533_hpd_irq_gpio) in  lo
 gpio-923 (led1                ) out lo
 gpio-933 (adv7533_irq_gpio    ) in  hi
 gpio-934 (disp_rst_n          ) in  hi
 gpio-940 (7864900.sdhci cd    ) in  lo
 gpio-1009 (volume_up           ) in  hi
 gpio-1010 (home                ) in  hi
 gpio-1011 (back                ) in  hi
 gpio-1022 (sysfs               ) out lo
 gpio-1023 (USB_ID_GPIO         ) in  hi

From this table you can see that offsets are:

  • CPU gpio is 902
  • PMIC gpio is 897
  • PMIC mpp is 901

Using RTC

There are two RTC devices defined in the system. One is inside DART-SD410 PMIC chip and the second is on VART-SD410CustomBoard.
The main RTC device is DS1307 that is assembled on VART-SD410CustomBoard. It can be accessed via console in the following manner:

$ su
# cd /sys/class/rtc/rtc0
# cat date
Output similar to 2000-01-01
# cat time
Output similar to 00:00:36

To set the timezone use:

# setprop persist.sys.timezone "America/Chicago"

To set the time and date use:

# date -s 20160119.122100
The format is YYYYMMDD.HHmmss

To read back from the RTC0 device use:

# cat date
Output is 2016-01-19
# cat time
Output is 18:21:04
Pay attention that RTC stores time without timezone offset

You can use CR1225 lithium cell to run the RTC clock, insert it into battery holder JBT1.
Set the time and remove the power.
Wait for 5 minutes, plug the power in and verify RTC is still running.

Recording and Playing sound file

To record simple wav file from the headset use the following scenario:

  • Plug in standard cellphone headset into Headset Jack (J15) We used Samsung headset.
  • use the following commands to test:
$ su
Set the mixer parameters to enable headset record
# tinymix 'MultiMedia1 Mixer TERT_MI2S_TX' 1
# tinymix 'DEC1 MUX' 'ADC2'
# tinymix 'ADC2 MUX' 'INP2'
# tinymix 'MultiMedia1 Mixer TERT_MI2S_TX' 1
Record an audio file
# tinycap /sdcard/test.wav
In the end of recording press ^c
The file test.wav will be created in /sdcard folder

To play the recorded file use:

# tinymix 'PRI_MI2S_RX Audio Mixer MultiMedia1' 1
# tinymix 'RX1 MIX1 INP1' 'RX1'
# tinymix 'RX2 MIX1 INP1' 'RX2'
# tinymix 'RDAC2 MUX' 'RX2'
# tinymix 'HPHL' 'Switch'
# tinymix 'HPHR' 'Switch'
# tinymix 'MI2S_RX Channels' 'Two'
# tinyplay /sdcard/test.wav

Capturing screen snapshot

To save the screen contents to a file use:

$ su
# screencap -p /sdcard/screen.png
The file screen.png is created in the /sdcard folder

Recording screen

To record a video file with screen activity use:

$ su
# screenrecord /sdcard/screen.avi
In the end of record press ^c
The file screen.avi is created in the /sdcard folder

Switching screen

Switching screens is done via Fastboot. To switch follow the scenario:

  • Connect USB cable between Host PC and VAR-SD410CustomBoard (J20)
  • Press on Back button (SW8)
  • Cycle the power or press Reset button (SW1)
  • On the host PC use:

To switch to HDMI

$ sudo fastboot oem select-display-panel adv7533_1080p
$ sudo fastboot reboot

To switch to LCD

$ sudo fastboot oem select-display-panel
$ sudo fastboot reboot

Capturing camera image

Capture the camera image can be done using GUI or via console.
To capture the Camera image from console use the following:
Start Camera application

$ su
# am start -a android.media.action.STILL_IMAGE_CAMERA

Send KEYCODE_CAMERA event (take the picture)

# input keyevent 27 

Send KEYCODE_BACK event (exit Camera application)

# input keyevent 4

All this can be done in one line

# am start -a android.media.action.STILL_IMAGE_CAMERA && sleep 1 && input keyevent 27 && input keyevent 4

Testing internet connection

The wired Ethernet controller connected to DART-SD410 USB port.
To use it the USB Device connector (J20) should not be connected.
For testing use the following scenario:

  • Disconnect USB Device connector (J20)
  • Connect Ethernet cable into RJ45 Jack (J22)
  • On serial console type:
$ su
# ping google.com
The output will show the ping responces

Rotating LVDS screen

There is no sensors on the VAR-SD410CustomBoard so automatic screen rotation is not available.
To rotate LVDS display the property 'persist.panel.orientation' can be changed.

$ su
# setprop persist.panel.orientation 0
This will rotate the screen and put it into landscape mode
To return to portrait mode use
# setprop persist.panel.orientation 270

Measuring current consumption

VAR-SD410CustomBoard allow current consumption measurement by removing resistor R56 and connecting ampere-meter instead.
The current consumption is highly depends on the applications running on the Dart-SD410.
Normally the on-board Ethernet controller prevents the Android to go into memory retention mode, so the serial terminal is accessible all the time.
In order to allow the Android enter memory retention state the Ethernet controller should be removed by:

$ su
# echo 1 > /sys/bus/usb/devices/1-1.3/remove
This will remove the driver of Ethernet controller device and power down the LAN7500 chip.
# echo mem > /sys/power/state
This will force the Android to enter memory retention mode.
This step is optional, Android will enter memory retention mode by itself when it will be Idle

Pressing PWR button will resume the system and the Ethernet controller chip will be connected back to the system.

Reseting the system

The system reset can be done via:

  • Serial console by entering:
$ reboot
  • By pressing PWR button for 0.5sec.
    The Power menu will appear and pressing on Power Off option will reboot the system.
  • Pressing the PWR button for 3sec will forcefully reset the CPU.
  • Power down the DART-SD410 should be done by disconnecting the power supply.