VAR-SOM-AM33 Linux Unit Testing: Difference between revisions

From Variscite Wiki
Line 273: Line 273:
</pre>
</pre>


</br>Explanation:
</br>Explanation:</br>
1) interface - in that case will be wlan1, since wlan1 will take the role of AP</br>
1) interface - in that case will be wlan1, since wlan1 will take the role of AP</br>
2) channel - should be the same as the commericial AP channel that the station (wlan0)is connected too (since AP and Station need to be in the same channel)</br>
2) channel - should be the same as the commericial AP channel that the station (wlan0)is connected too (since AP and Station need to be in the same channel)</br>

Revision as of 09:29, 26 February 2015

Unit Testing

CPU info

root@am335x-evm:~# cat /proc/cpuinfo
Processor       : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 598.35
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2

Hardware        : VAR-SOM-AM33
Revision        : 0000
Serial          : 0000000000000000
root@am335x-evm:~# cat /proc/version
Linux version 3.2.0-AM335XPSP_04.06.00.11.VAR_R13 (uri@pluto) (gcc version 4.7.3 20130226 
(prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.03-20130313 - Linaro GCC 2013.03) ) #1 T
ue Oct 15 10:06:14 IST 2013

RTC

To set the RTC first set the date from Linux shell, type:

$ date 2013.08.27-15:43

Then set the real time clock from Linux shell, type:

$ hwclock --systohc

Power down your board wait 15 seconds and power up. Check your system with date and the time should be up to date.

Audio record/play

$ aplay /usr/share/sounds/alsa/Front_Center.wav
$ arecord -f cd -d 10 -D hw:0,0 test.wav
$ aplay test.wav 

WLAN

VAR-SOM-AM33 V2.X only:
When using VAR-SOM-AM33 v2.x, SOM has a WL183x module. In that case you should configure the WL183x module as follows (only in the first boot):

$ cd /usr/bin/wlconf/
$ ./configure-device.sh [WL18xx chip]
Then choose the correct number of antennas on board and choose (n) to generate a clean configuration file from .ini


For example:

root@varsomam33:/usr/bin/wlconf# ./configure-device.sh wl1835
Device is capable of supporting 2 antenna in 2.4Ghz band
how many antennae are fitted? [1/2] : 1
Error: Module wlcore_sdio is not currently loaded
A wl18xx-conf.bin file already exists, do you want to modify it (y) or generate a clean one from .ini (n)
modify it? [y/n] : n

General usage:
List SSIDs, from Linux shell type:

$ ifconfig wlan0 up
$ iw wlan0 scan

Connecting to an encrypted network:

Find your network from the above scan command.

$ wpa_passphrase <YourAP> <YourPassword> >wpa.conf
$ ps | grep wpa_supplicant
*kill the wpa_supplicant process if exist.
$ wpa_supplicant -Dnl80211 -iwlan0 -c./wpa.conf -B
$ udhcpc -iwlan0
$ ifconfig
  • WL12xx calibration tool

Calibration of TI WL12xx wireless device is required and is saved into the NVS file. The NVS file is then used by the wl12xx driver. For more details please read NLCP Calibration Process

100Mbit Ethernet

On Target:

$ ifconfig
$ iperf -s -u

On Host:

$ iperf -c 192.168.1.189 -u -b100M -w4KB

Gbit Ethernet

On Target:

$ ifconfig
$ iperf -s -u

On Host:

$ iperf -c 192.168.1.189 -u -b1000M -w4KB

OpenGL demo (supported CPUs)

Run the demo script at Linux command prompt after the VAR-DVK-AM33 EVB boots up

/etc/init.d/335x-demo 

ADC controller

please follow TI wiki pages: http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide

USB OTG as host

By default the OTG is configure to be "peripheral". You can switch it to "host" if you change the dr_mode in the device tree.

Please see details on the Wiki page below: http://variwiki.com/index.php?title=VAR-SOM-AM33_Linux_SDK_7_Configurations

Once the USB-OTG port has been configured as host, simply connect a USB Mouse or DOK to the OTG port.

USB OTG as device

Plug a USB cable to a Linux or a Windows host.

Follow www.linux-usb.org/gadget/file_storage.html and build the backing_file.

On the Target:

$ modprobe g_mass_storage file=./backing_file

On the Host:
Wait for a mass-storage device to be detected.

Bluetooth

  • Bring BT device up:
$ hciconfig hci0 up
  • Scan for BT devices and ping:
$ hcitool scan 
$ l2ping 98:03:D8:C7:1A:96

Then work with any other standard bluetooth API and commands.

CAN Bus

  • Connect CANL, CANH and GND pins of two VAR-SOM-AM33 boards (located on J17).
  • Power-up both boards.
  • Type the following into the shell of both boards for configuration the CAN bus device:
$ ip link set can0 type can bitrate 50000 triple-sampling on
$ ip link set can0 up
  • Type the following to the shell of board 1 (which is used for testing receiving over can0 device):
$ candump can0
  • Type the following to the shell of board 2 (which is used for testing sending data packets over can0 device):
$ cansend can0 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
  • At this point, board 1 will receive the data packet sent from board 2:
<0x001> [8] 11 22 33 44 55 66 77 88

RS-232 port

  • Enable RS232 UART ttyO1 I/F on the VAR-SOM-AM33:
echo 20 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio20/direction
echo 0 > /sys/class/gpio/gpio20/value
  • Start minicom and connect to a UART device:
minicom -D/dev/ttyO1 -b115200 -8

SPI interface

  • The VAR-SOM-AM33 supports SPI interface over am335x SPI-1 bus.
  • To enable the SPI bus, the developer should apply the following HW modifications on the VAR-AM33CustomBoard Rev1.2:

1) Remove resistors R9 and R10 (from CustomBoard carrier).
2) Remove U21 component (from CustomBoard carrier).

  • Download the kernel out-of-tree, and update the DTS:
$ gedit arch/arm/boot/dts/var-som-am33.dts

and update the following lines(change #if 0 to #if 1) - From:

&spi1 {
	status = "okay";

#if 0	/* NOTE: In order to use SPI on VAR-SOM-AM33 CustomBoard -

To

&spi1 {
	status = "okay";

#if 1	/* NOTE: In order to use SPI on VAR-SOM-AM33 CustomBoard -
  • Rebuild the var-som-am33.dtb and replace it.
  • Then, to test, build the SPI test application for ARM (and copy it to the target rootfs):
$ cd Documentation/spi/
$ make spidev_test
$ sudo cp spidev_test /media/rootfs/sbin
  • Start the var-som-am33 board and run the test (SPI-Rx and SPI-Tx lines should be shorted for this test), as follows:
root@varsomam33:~# spidev_test -D /dev/spidev1.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

FF FF FF FF FF FF
40 00 00 00 00 95
FF FF FF FF FF FF
FF FF FF FF FF FF
FF FF FF FF FF FF
DE AD BE EF BA AD
F0 0D
root@varsomam33:~#

Please see a more detailed explanation on the AM335x SPI interface on http://processors.wiki.ti.com/index.php/Linux_Core_SPI_User%27s_Guide

Configuring WIFI as access point

Configuring hostapd.conf

First, we will back up the existing hostapd.conf file by invoking:

$ mv /etc/hostapd.conf /etc/hostapd.conf.bak

Create a new hostapd.conf with the following content:

$ vi /etc/hostapd.conf

Copy/paste the following configuration file into /etc/hostapd.conf and save it:

interface=wlan0
driver=nl80211
channel=11
hw_mode=g
preamble=1
dtim_period=2
beacon_int=100
logger_syslog=-1
logger_syslog_level=2
logger_stdout=-1
logger_stdout_level=2
dump_file=/tmp/hostapd.dump
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
supported_rates=60 90 120 180 240 360 480 540
basic_rates=60 90 120 180 240
ssid=SoftAP_Role
max_num_sta=5
macaddr_acl=0
auth_algs=3
ieee80211d=0
uapsd_advertisement_enabled=1
wep_rekey_period=0
own_ip_addr=127.0.0.1
wpa_group_rekey=0
wpa_strict_rekey=0
wpa_gmk_rekey=0
wpa_ptk_rekey=0
#ap_table_max_size=255
#ap_table_expiration_time=60
eap_server=1
disassoc_low_ack=1
ap_max_inactivity=4294967295


Explanation:
1) interface - in that case will be wlan1, since wlan1 will take the role of AP
2) channel - should be the same as the commericial AP channel that the station (wlan0)is connected too (since AP and Station need to be in the same channel)
3) hw_mode=g - to support bg band
4) ieee80211n=1 - to support 802.11n band ssid - the AP SSID

Configuring udhcpd.conf

First, we will back up the existing udhcpd.conf file by invoking:

$ mv /etc/udhcpd.conf /etc/udhcpd.conf.bak

Create a new udhcpd.conf with the following content: - opt router: is the Router IP address and have to be the same as was defined by ifconfig command, in that example it is 10.4.30.34

$ vi /etc/udhcpd.conf

Copy/paste the following configuration file into /etc/udhcpd.conf and save it:

# Sample udhcpd configuration file (/etc/udhcpd.conf)
# The start and end of the IP lease block
start 		10.4.30.40	#default: 192.168.0.20
end		10.4.30.48	#default: 192.168.0.254
# The interface that udhcpd will use
interface   wlan0		#default: eth0
#Examles
opt	dns	8.8.8.8  8.8.4.4 # public google dns servers
option	subnet	255.255.255.0
opt	router	10.4.30.34
option	lease	864000		# 10 days of

operate WLAN as AP (Run hostapd)

hostapd -B /etc/hostapd.conf -P /var/run/hostapd.pid

Expected results:

root@varsomam33:~# hostapd -B /etc/hostapd.conf -P /var/run/hostapd.pid
Configuration file: /etc/hostapd.conf
wlcore: down
wlcore: PHY firmware version: Rev 8.2.0.0.146
wlcore: firmware booted (Rev 8.4.0.0.26)
Using interface wlan0 with hwaddr 00:01:33:88:44:72 and ssid 'SoftAP_Role'

Assign IP address to the wlan port, note that it has to be the same one as defined in the "udhcpd.conf" file in field "opt router"

$ ifconfig wlan0 10.4.30.34 netmask 255.255.255.0 up

Add NAT and DHCP server capability to the AP:

echo 1 > /proc/sys/net/ipv4/ip_forward
udhcpd /etc/udhcpd.conf
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

Enable NAT for internet sharing

Assumption: Internet connection is available on port eth0 and we want to share it with wlan0 incoming access point connections.

We type the following to enable internet sharing, in this case:

$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Please see more details on http://processors.wiki.ti.com/index.php/WiLink8_WLAN_Demo:_Linux#AP_.28create_AP_with_no_security.29