https://www.mediawiki.compulab.com/w/index.php?title=CM-T43:_Yocto_Linux:_User_Space&feed=atom&action=historyCM-T43: Yocto Linux: User Space - Revision history2024-03-29T08:59:20ZRevision history for this page on the wikiMediaWiki 1.31.0https://www.mediawiki.compulab.com/w/index.php?title=CM-T43:_Yocto_Linux:_User_Space&diff=3397&oldid=prevGrinberg: /* GPIO */2017-07-16T15:31:34Z<p><span dir="auto"><span class="autocomment">GPIO</span></span></p>
<p><b>New page</b></p><div>== Overview ==<br />
The example run-time Yocto Linux filesystem image for the CompuLab CM-T43 System-on-Module / Computer-on-Module is based on Texas Instruments Arago project.<br />
<br />
The Automatic Installation page provides a brief introduction on how to install the run-time Yocto Linux image.<br />
<br />
== Using Yocto Linux on CM-T43 ==<br />
<br />
=== Connection and Logging In ===<br />
Use the following username to login:<br />
<br />
<pre><br />
root@cm-t43: root<br />
</pre><br />
<br />
To login into the Linux system, you may use a serial console (ttyO0) at 115200 bps, or connect through the network.<br />
<br />
=== Networking ===<br />
CM-T43 can operate in two modes: dual MAC mode, or as a 3 port ethernet switch. The default mode of operation is dual MAC mode.<br />
A user guide for both operation modes can be found in the [http://processors.wiki.ti.com/index.php/Linux_Core_CPSW_User%27s_Guide Linux Core CPSW User's Guide] article in the TI wiki.<br />
To configure networking, edit {{filename|/etc/network/interfaces}}, {{filename|/etc/resolv.conf}}, {{filename|/etc/hostname}} and {{filename|/etc/hosts}}. For more information about Linux network configuration read [http://www.debian.org/doc/manuals/reference/ch05.en.html Network setup] chapter in the [http://www.debian.org/doc/manuals/reference/index.en.html Debian Reference].<br />
<br />
==== Switching to 3-port switch mode ====<br />
To enable 3-port switch mode, the device tree blob must be modified to remove the dual_emac property before Linux boots. This can be done using the following U-Boot commands:<br />
<pre><br />
# fdt addr <address fdt was loaded to><br />
# fdt rm /ocp/ethernet@4a100000 dual_emac<br />
</pre><br />
<br />
=== Wayland display server ===<br />
The Arago root filesystem image contains fully featured display server system Wayland/Weston.<br />
Wayland is a protocol that specifies the communication between a display server (called Wayland compositor) and its clients, as well as a reference implementation of the protocol.<br />
The Wayland project includes a demo Wayland compositor, called Weston. It's fast, small, and runs on embedded and mobile devices.<br />
On start-up Wayland and the Texas Instruments Matrix is started.<br />
Connect USB mouse and keyboard for interaction with Wayland and the Texas Instruments Matrix.<br />
*Use the following commands to stop the matrix:<br />
<pre><br />
/etc/init.d/matrix-gui-2.0 stop<br />
</pre><br />
*Use the following commands to start the matrix:<br />
<pre><br />
/etc/init.d/matrix-gui-2.0 start<br />
</pre><br />
*Use the following commands to stop the Weston:<br />
<pre><br />
/etc/init.d/weston stop<br />
</pre><br />
*Use the following commands to start the Weston:<br />
<pre><br />
/etc/init.d/weston start<br />
</pre><br />
<br />
=== Display options ===<br />
CM-T43 evaluation platform has three video output interfaces: LCD, DVI, and LVDS. Default configuration of Yocto Linux for CM-T43 uses LCD as primary video output.<br />
<br />
=== USB Dual-Role-Device ===<br />
<br />
CM-T43 has USB DWC3 based controller. It features USB 2.0 Dual-Role-Device (DRD) subsystem with integrated HS/FS (USB2.0) PHY.<br />
CM-T43 DRD port is USB host and USB device (gadget) capable. USB Device Gadget drivers are compiled as modules with default CM-T43 kernel configuration.<br />
Current Linux kernel support of DWC3 features does not allow dynamic role (host/device) switching during runtime. By default, ''host'' role is assigned to CM-T43 DRD port.<br />
<br />
Device mode can be enabled by running the following U-Boot commands before boot:<br />
<pre><br />
# fdt addr <address fdt was loaded to><br />
# fdt resize<br />
# fdt set /ocp/omap_dwc3@48380000/usb@48390000 dr_mode peripheral<br />
</pre><br />
<br />
==== Testing Device (gadget) mode ====<br />
<br />
Default CM-T43 kernel configuration enables {{filename|g_serial}}, {{filename|g_mass_storage}}, {{filename|g_ether}}, {{filename|g_audio}}, and {{filename|g_hid}} gadget drivers.<br />
More gadget drivers can be enabled in the kernel configuration.<br />
<br />
* Connect USB OTG micro B-cable (ID pin Float) to P3 USB DRD port of SB-SOM baseboard.<br />
* Connect other side Standard-A connector to Linux Host PC USB Host port.<br />
<br />
===== Emulate a serial link =====<br />
<br />
* Load gadget driver on CM-T43 Eval board:<br />
<pre><br />
root@cm-t43:~# modprobe g_serial<br />
[ 56.306729] g_serial gadget: Gadget Serial v2.4<br />
[ 56.311433] g_serial gadget: g_serial ready<br />
[ 56.758367] g_serial gadget: high-speed config #2: CDC ACM config<br />
</pre><br />
<br />
* Ensure the connection is established on the Host PC:<br />
<pre><br />
user@linux-host:~$ dmesg<br />
...<br />
[72415.607738] cdc_acm 2-1.8.2:2.0: ttyACM0: USB ACM device<br />
[72415.608446] usbcore: registered new interface driver cdc_acm<br />
[72415.608447] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters<br />
</pre><br />
<br />
* Receive data on CM-T43 Eval board:<br />
<pre><br />
root@cm-t43:~# cat /dev/ttyGS0<br />
</pre><br />
<br />
* Send data from Host PC:<br />
<pre><br />
user@linux-host:~$ echo "Test message" > /dev/ttyACM0<br />
</pre><br />
<br />
=== Analog Audio ===<br />
CM-T43 provides an analog audio interface, which is registered as a standard ALSA sound card. Use '''aplay -l''' to list all soundcards and digital audio devices registered on the system: <br />
<pre><br />
root@cm-t43:~# aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: CMT43SoundCard [CM-T43-Sound-Card], device 0: davinci-mcasp.0-wm8731-hifi wm8731-hifi-0 []<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
</pre><br />
<br />
==== Analog Audio Settings ====<br />
To enable the Analog audio playback, {{cmd|alsamixer}} or {{cmd|amixer}} applications can be used.<br />
* {{cmd|alsamixer}} - set the “''Output Mixer''” control on.<br />
or<br />
* {{cmd|amixer}} - set the “''Output Mixer HiFi Playback Switch''” control on using command line interface:<br />
<pre><br />
root@cm-t43:/# amixer cset numid=13 1<br />
numid=13,iface=MIXER,name='Output Mixer HiFi Playback Switch'<br />
; type=BOOLEAN,access=rw------,values=1<br />
: values=on<br />
</pre><br />
<br />
==== Analog Audio Playback ====<br />
In order to play back a sound file make use of the {{cmd|aplay}} application.<br />
<dl><br />
* {{cmd|aplay -L}} can be used for listing of all pcm devices.<br />
</dl><br />
Here is a sample output of {{cmd|aplay -L}} command:<br />
<pre><br />
root@cm-t43:/# aplay -L<br />
null<br />
Discard all samples (playback) or generate zero samples (capture)<br />
pulse<br />
PulseAudio Sound Server<br />
default:CARD=CMT43SoundCard<br />
CM-T43-Sound-Card, <br />
Default Audio Device<br />
sysdefault:CARD=CMT43SoundCard<br />
CM-T43-Sound-Card, <br />
Default Audio Device<br />
</pre><br />
<br />
=== WiFi ===<br />
CM-T43 features 802.11b/g/n wireless connectivity solution, implemented with a Marvell wireless controller module.<br />
<br />
==== WiFi Initialization ====<br />
* The driver gets loaded automatically. Make sure that the WiFi driver is loaded:<br />
<pre><br />
root@cm-t43:/# lsmod | grep mwifi<br />
mwifiex_sdio 26039 0<br />
mwifiex 256669 1 mwifiex_sdio<br />
cfg80211 259154 1 mwifiex<br />
</pre><br />
* {{cmd|iwconfig}} command from {{cmd|wireless-tools}} package can be used to retrieve detailed information about the WiFi interfaces:<br />
<pre><br />
mlan0 IEEE 802.11abgn ESSID:off/any <br />
Mode:Managed Access Point: Not-Associated <br />
Retry short limit:9 RTS thr=2347 B Fragment thr=2346 B <br />
Encryption key:off<br />
Power Management:on<br />
</pre><br />
<br />
* WLAN interface activating:<br />
<pre><br />
root@cm-t43:/# ifconfig mlan0 up<br />
</pre><br />
* Sample WiFi scanning:<br />
<pre><br />
root@cm-t43:/# iwlist mlan0 scan<br />
</pre><br />
The output will show the list of Access Points and Ad-Hoc cells in range.<br />
For more information about connecting to wireless networks and tuning WiFi interfaces refer to “wpa_supplicant” and “wireless-tools” man pages.<br />
<br />
=== Bluetooth ===<br />
==== Host Controller Interface (HCI) Initialization ==== <br />
* HCI requires no user interaction for being configured. The driver gets loaded automatically unless this option has been disabled by putting a black list rule for this device.<br><br />
Make sure that the Bluetooth driver is loaded:<br />
<pre><br />
root@cm-t43:/# lsmod | grep btmrvl<br />
btmrvl_sdio 14518 0<br />
btmrvl 12690 1 btmrvl_sdio<br />
bluetooth 326343 16 bnep,btmrvl,btmrvl_sdio<br />
</pre><br />
<br />
* HCI device configuration utility can be run to retrieve detailed information about the Bluetooth interfaces:<br />
<pre><br />
root@cm-t43:/# hciconfig -a<br />
hci0: Type: BR/EDR Bus: SDIO<br />
BD Address: 80:D2:1D:5F:45:18 ACL MTU: 1021:7 SCO MTU: 120:6<br />
UP RUNNING PSCAN <br />
RX bytes:1704 acl:0 sco:0 events:76 errors:0<br />
TX bytes:1459 acl:0 sco:0 commands:75 errors:0<br />
Features: 0xff 0xfe 0x8f 0xfe 0xdb 0xff 0x7b 0x87<br />
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 <br />
Link policy: RSWITCH HOLD SNIFF <br />
Link mode: SLAVE ACCEPT <br />
Name: 'cm-t43-0'<br />
Class: 0x000100<br />
Service Classes: Unspecified<br />
Device Class: Computer, Uncategorized<br />
HCI Version: (0x8) Revision: 0x8300<br />
LMP Version: (0x8) Subversion: 0x7270<br />
Manufacturer: Marvell Technology Group Ltd. (72)<br />
</pre><br />
<br />
* If the HCI device is not running, use the below command to enable the HCI device:<br />
<pre><br />
root@cm-t43:/# hciconfig hci0 up<br />
</pre><br />
<br />
* HCI inquire remote devices<br />
<pre><br />
root@cm-t43:/# hcitool scan<br />
Scanning ...<br />
</pre><br />
<br />
=== RTC ===<br />
==== Accessing and setting the RTC ====<br />
To access the RTC time and date run:<br />
<pre><br />
root@cm-t43:/# hwclock<br />
Sat Jun 17 13:36:35 2017 0.000000 seconds<br />
</pre><br />
<br />
To set the date and write it into the RTC do the following:<br />
<pre><br />
root@cm-t43:/# date -s "2015-02-11 10:00:00"<br />
Wed Feb 11 10:00:00 UTC 2015<br />
root@cm-t43:/# hwclock -w<br />
root@cm-t43:/# hwclock<br />
Sat Jun 17 13:39:09 2017 0.000000 seconds<br />
</pre><br />
<br />
=== Touchscreen ===<br />
<br />
Touchscreen calibration runs on first boot. To rerun it, execute the following commands:<br />
<pre><br />
rm /etc/udev/rules.d/ws-calibrate.rules<br />
rm /run/media/mmcblk0p1/ws-calibrate.rules<br />
reboot<br />
</pre><br />
<br />
=== CAN bus ===<br />
<br />
Install can-utils using:<br />
<pre><br />
# apt-get install can-utils<br />
</pre><br />
<br />
==== CAN interface configuration ====<br />
* Load the can bus modules:<br />
<pre><br />
root@cm-t43:~# modprobe can-raw<br />
[ 123.114470] can: controller area network core (rev 20120528 abi 9)<br />
[ 123.120993] NET: Registered protocol family 29<br />
[ 123.155278] can: raw protocol (rev 20120528)<br />
root@cm-t43:~# modprobe can-bcm<br />
[ 145.749470] can: broadcast manager protocol (rev 20120528 t)<br />
</pre><br />
<br />
It is recommended configure the CAN interface, with the {{filename|iproute2}} utilities.<br />
<br />
* To make sure the right {{filename|ip}} utility is used, run:<br />
<pre><br />
root@cm-t43:~# ip -V<br />
ip utility, iproute2-ss160111<br />
</pre><br />
<br />
* Configure the CAN interface bit-rate to 125 Kbits/sec (values of up to 1Mbit/sec are supported):<br />
<pre><br />
root@cm-t43:~# ip link set can0 type can bitrate 125000<br />
</pre><br />
<br />
* Enable the CAN interface:<br />
<pre><br />
root@cm-t43:~# ip link set can0 up<br />
[ 184.948857] net can0: c_can_hw_raminit_wait_syscon: time out<br />
[ 184.954781] c_can_platform 481d0000.can can0: setting BTR=0518 BRPE=0000<br />
</pre><br />
<br />
===== Send/Receive packets =====<br />
<br />
Use {{filename|cansend}} and {{filename|candump}} utilities to send and receive packets via CAN interface.<br />
<br />
* Send standard CAN frame (on the first device):<br />
<pre><br />
root@cm-t43:~# cansend can0 111#1122334455667788<br />
</pre><br />
<br />
* Send extended CAN frame (on the first device):<br />
<pre><br />
root@cm-t43:~# cansend can0 11111111#1122334455667788<br />
</pre><br />
<br />
* Dump all received data frames as well as error frames (on the second device):<br />
<pre><br />
root@cm-t43:~# candump any,0:0,#FFFFFFFF<br />
can0 111 [8] 11 22 33 44 55 66 77 88<br />
can0 11111111 [8] 11 22 33 44 55 66 77 88<br />
</pre><br />
<br />
=== GPIO ===<br />
<br />
To use a GPIO:<br />
* Select a pin you wish to use as GPIO by consulting the [http://www.compulab.com/products/computer-on-modules/cm-t43/#devres CM-T43 reference manual]. The reference manual contains a list of pins and the possible functions each pin can support, many of which include GPIO signals as one of the possible functions.<br />
* Setup the pinmux so that the GPIO function is selected for the pin you chose in the previous step. This may require you to edit the device tree for CM-T43. Consult the [[Linux: Introduction to device trees | device tree article]] in the CM-T43 Linux wiki.<br />
* Export the GPIO in Linux sysfs and cd into it<br />
<pre><br />
root@cm-t43:/# echo <gpio_num> > /sys/class/gpio/export<br />
root@cm-t43:/# cd gpio<gpio_num><br />
</pre><br />
* Select GPIO input/output function:<br />
<pre><br />
root@cm-t43:/# echo in > direction<br />
</pre><br />
or<br />
<pre><br />
root@cm-t43:/# echo out > direction<br />
</pre><br />
* To read GPIO input (or determine what value is being output):<br />
<pre><br />
root@cm-t43:/# cat value<br />
0<br />
</pre><br />
* To output a value on the GPIO pin:<br />
<pre><br />
root@cm-t43:/# echo 1 > value<br />
</pre><br />
<br />
=== PRU ===<br />
<br />
CM-T43 Yocto Linux has PRU support. For usage instructions, consult the [http://processors.wiki.ti.com/index.php/PRU-ICSS TI PRU wiki].<br />
<br />
== See also ==<br />
<br />
* [[CM-T43: Yocto Linux: Automatic Installation]]<br />
* [[CM-T43: Yocto Linux: Manual Installation]]<br />
* [[Linux: Development for ARM modules]]<br />
<br />
[[Category:Linux]]<br />
[[Category:Yocto]]<br />
[[Category:CM-T43]]</div>Grinberg