Difference between revisions of "MCM-iMX93: Yocto Linux: How-To Guide"
(Created page with "=Device Tree= == Available Device Tree Files == The current release includes the following '''dtb''' files: {| class="wikitable" style="text-align:left;" |- | '''DTB''' | '''...") |
|||
(One intermediate revision by the same user not shown) | |||
Line 73: | Line 73: | ||
systemctl restart weston | systemctl restart weston | ||
+ | =Audio= | ||
+ | SBC-MCM93 features WM8926 audio codec.<br> | ||
+ | ===List available sound cards=== | ||
+ | * aplay | ||
+ | <pre> | ||
+ | aplay -l | ||
+ | |||
+ | **** List of PLAYBACK Hardware Devices **** | ||
+ | card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [HiFi wm8962-0] | ||
+ | Subdevices: 1/1 | ||
+ | Subdevice #0: subdevice #0 | ||
+ | </pre> | ||
+ | * procfs | ||
+ | <pre> | ||
+ | cat /proc/asound/cards | ||
+ | |||
+ | 0 [wm8962audio ]: fsl-asoc-card - wm8962-audio | ||
+ | wm8962-audio | ||
+ | </pre> | ||
+ | |||
+ | ===Audio Playback=== | ||
+ | * gplay-1.0 and aplay allow playback of media files: | ||
+ | <pre> | ||
+ | gplay-1.0 /path/to/media.file | ||
+ | aplay -D hw:0,0 -vv /path/to/media.file | ||
+ | </pre> | ||
<!-- | <!-- | ||
=Camera= | =Camera= | ||
Line 196: | Line 222: | ||
... | ... | ||
</pre> | </pre> | ||
+ | |||
+ | =Ethernet= | ||
+ | SBC-MCM93 carrier-board features two Gigabit Ethernet ports implemented with two RTL8211FDI PHYs.<br> | ||
+ | The [https://manpages.debian.org/stretch/network-manager/nmcli.1.en.html NetworkManager] can be used to manage these interfaces. | ||
+ | |||
+ | ===Bandwidth test example=== | ||
+ | Start iperf3 server on host: | ||
+ | iperf3 -s -i 60 | ||
+ | |||
+ | Straight (client sends, server receives) 1 min. test with report each 10 sec. | ||
+ | iperf3 -t 60 -i 10 | ||
+ | |||
+ | Reverse (server sends, client receives) test | ||
+ | iperf3 -t 60 -i 10 -R | ||
= WiFi = | = WiFi = | ||
Line 384: | Line 424: | ||
{| class="wikitable" style="text-align:center;" | {| class="wikitable" style="text-align:center;" | ||
|- | |- | ||
− | | ''' | + | | '''Name in u-boot || '''pin''' || '''GPIO # in sysfs''' |
|- | |- | ||
− | | | + | |GPIO2_18 |
|2 | |2 | ||
− | | | + | |512+18 |
+ | |- | ||
+ | |gpio@20_0 | ||
+ | |4 | ||
+ | |640 | ||
|- | |- | ||
|GPIO2_21 | |GPIO2_21 | ||
|3 | |3 | ||
− | | | + | |512+21 |
|- | |- | ||
− | | | + | |GPIO2_24 |
|5 | |5 | ||
− | | | + | |512+24 |
|- | |- | ||
− | | | + | |GPIO2_26 |
|7 | |7 | ||
− | | | + | |512+26 |
|- | |- | ||
− | | | + | |GPIO2_22 |
|9 | |9 | ||
− | | | + | |512+22 |
|- | |- | ||
|} | |} | ||
− | ==Example: controlling pin | + | ==Example: controlling pin GPIO2_18== |
'''Exporting the pin in sysfs'''</br> | '''Exporting the pin in sysfs'''</br> | ||
<pre> | <pre> | ||
cd /sys/class/gpio/ | cd /sys/class/gpio/ | ||
− | echo $(( | + | echo $((512+18)) > export |
+ | cd /sys/class/gpio/gpio$((512+18)) | ||
+ | </pre> | ||
+ | Now pin is assigned to sysfs. You can view the newly created entry in gpiochip0, line 18 by running: | ||
+ | <pre> | ||
+ | gpioinfo | ||
</pre> | </pre> | ||
− | |||
− | |||
'''Writing to a pin'''</br> | '''Writing to a pin'''</br> | ||
− | |||
Set pin direction to output: | Set pin direction to output: | ||
− | + | echo out > direction | |
Set pin value to high or low: | Set pin value to high or low: | ||
<pre> | <pre> | ||
Line 427: | Line 473: | ||
</pre> | </pre> | ||
'''Reading from a pin'''</br> | '''Reading from a pin'''</br> | ||
− | |||
Set pin direction to input: | Set pin direction to input: | ||
− | + | echo in > direction | |
Read the value of the pin from the value file: | Read the value of the pin from the value file: | ||
− | <pre> | + | cat value |
+ | |||
+ | =ADC= | ||
+ | i.MX93 SoC features integrated 12 bit analog to digital converter.<br> | ||
+ | <!-- | ||
+ | To use the ADC, enable it in device tree e.g. in arch/arm64/boot/dts/compulab/sbc-mcm-imx93.dts: | ||
+ | <pre> | ||
+ | &adc1 { | ||
+ | vref-supply = <®_vref_1v8>; | ||
+ | status = "okay"; | ||
+ | }; | ||
+ | </pre> | ||
+ | --> | ||
+ | for sysfs device controls go to: | ||
+ | cd /sys/bus/iio/devices/iio\:device0/ | ||
+ | SBC-MCM93 exposes ADC signals on 100-mil header '''P9'''. | ||
+ | {| class="wikitable" style="text-align:center;" | ||
+ | |- | ||
+ | | '''Signal Name || '''pin on P9''' || '''sysfs file''' | ||
+ | |- | ||
+ | |ADC_IN0 | ||
+ | |2 | ||
+ | |in_voltage0_raw | ||
+ | |- | ||
+ | |ADC_IN1 | ||
+ | |4 | ||
+ | |in_voltage1_raw | ||
+ | |- | ||
+ | |ADC_IN2 | ||
+ | |6 | ||
+ | |in_voltage2_raw | ||
+ | |- | ||
+ | |ADC_IN3 | ||
+ | |3 | ||
+ | |in_voltage3_raw | ||
+ | |- | ||
+ | |} | ||
+ | For example, to read voltage from P9-2 run: | ||
+ | cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw | ||
+ | Expected output is a value in range 0 - 4095 which spans over the voltage range 0 - 1.8V | ||
=Suspend / Resume= | =Suspend / Resume= |
Latest revision as of 13:58, 11 August 2024
Contents
Device Tree
Available Device Tree Files
The current release includes the following dtb files:
DTB | Hardware Configuration and Features | Jumpers/Connectors Settings |
sbc-mcm-imx93.dtb | default hardware configuration + lvds display | visit Connector Locations |
Set device tree
The current release provides two methods to switch between dtb files:
- U-Boot environment
The U-boot fdtfile variable contains the device tree name that will be loaded into the RAM. This variable can be changed by:
Environment | Command |
U-Boot | setenv fdtfile <fdt_file_name>; saveenv; |
Linux | fw_setenv fdtfile <fdt_file_name> |
- GRUB environment (if the image was created with the meta-compulab-uefi layer)
Environment | Command/Procedure |
GRUB Boot Menu | Goto "Advanced Boot Options" and choose a device tree from the provided dtb list. |
Linux | grub-editenv /boot/grub/grubenv set fdtfile=<fdt_file_name> |
Serial Console
MCM-iMX93 provides serial console on UART1.
SBC-MCM93 carrier-board exposes the console UART via CP2104 serial-to-USB bridge on connector P3 depicted here
Connecting to a host PC
- Use a micro-USB cable to connect the console to an USB port on your host PC.
- Make sure the CP2104 driver is available with your operating system, otherwise install CP2104 driver onto the host PC from https://www.silabs.com/documents/public/software/CP210x_Windows_Drivers_with_Serial_Enumeration.zip
- Identify the host PC interface and port number that will be used for communication with the MCM-iMX93 evaluation kit:
- In most Linux PCs, the serial port will be denoted as one of the following (where n is a positive integer): /dev/ttyUSB0, /dev/ttyUSB1 ... /dev/ttyUSBn
- In Windows PCs, the serial port usually will be denoted as one of the following (where n is a positive integer): COM1, COM2 ... COMn
- Start a terminal emulation program (such as PuTTY on Windows or minicom on Linux).
- In the port configuration section of the terminal emulation program select the port identified in previous step and set the following serial port parameters:
Baud Rate Data Bits Stop Bits Parity Flow Control 115200 8 1 none none
Display
LVDS
The MCM-iMX93 evaluation kit can be optionally supplied with the Startec KD070HDTLA020 7" LVDS LCD panel.
Use the EB-HDRLVDS adapter to connect the LCD panel (if ordered with the kit) to connectors P13 and P14 as depicted in Connector Locations .
Check the Linux device node for information about the display, such as its supported modes and its current configuration.
udevadm info -ap /sys/class/drm/card0-LVDS-1
Display Manager
MCM-iMX93 Yocto uses Weston as the default display manager. It can be configured in /etc/xdg/weston/weston.ini.
For example the transform setting can be set to rotate-90, rotate-180, rotate-270, or commented out.
In order to apply the configuration, you need to:
systemctl restart weston
Audio
SBC-MCM93 features WM8926 audio codec.
List available sound cards
- aplay
aplay -l **** List of PLAYBACK Hardware Devices **** card 0: wm8962audio [wm8962-audio], device 0: HiFi wm8962-0 [HiFi wm8962-0] Subdevices: 1/1 Subdevice #0: subdevice #0
- procfs
cat /proc/asound/cards 0 [wm8962audio ]: fsl-asoc-card - wm8962-audio wm8962-audio
Audio Playback
- gplay-1.0 and aplay allow playback of media files:
gplay-1.0 /path/to/media.file aplay -D hw:0,0 -vv /path/to/media.file
USB
MCM-iMX93 features two USB2.0 ports that are derived from the i.MX93 USB sub-system.
SBC-MCM93 carrier-board multiplexes J2 USB connector with mini-PCIe socket P8. To use USB connector J2 make sure jumper E1 is open.
USB connector J3 is multiplexed with USB SDP port as detailed here.
USB in device mode
USB port can be operated in device mode when connected to a host machine using connector P21.
Available gadgets for the UBS device mode:
USB gadget | SOM command |
usb serial device | modprobe g_serial |
usb network device | modprobe g_ether |
usb mass storage device | modprobe g_mass_storage file=/dev/sdX |
CAN bus
SBC-MCM93 evaluation board exposes one CAN bus interface on header P17.
- To test it you will need another board with CAN IF
- Configure both CAN interface bit-rate to 1 Mbit/sec:
ip link set can0 up type can bitrate 1000000
- On one system, dump all received data frames as well as error frames:
candump any,0:0,#FFFFFFFF can0 111 [8] 11 22 33 44 55 66 77 88 can0 11111111 [8] 11 22 33 44 55 66 77 88 ... can0 03FF0983 [8] D7 61 FF 03 C1 F7 C1 34 can0 19C34D32 [8] F7 5A C2 73 AD 0E 3F 0B can0 0675E391 [4] 2B 2D D3 49 can0 13091C55 [8] 99 32 EC 77 27 81 49 0B can0 098D67CF [8] 22 50 AB 48 AD 7F F4 26 can0 05263FEC [5] 1B 4C 02 45 6E can0 12B30E20 [0] can0 1F193DF9 [1] C5 can0 1EB0B18F [8] 3E 3F DA 57 C2 FE 73 58 can0 1E5C64D9 [5] 6F 0D B3 63 6A can0 1E1DE3F9 [8] 96 48 AC 79 4E 00 27 71 can0 0E1A11B7 [8] 75 81 70 7C 86 79 A7 77 can0 05F8FD8B [7] 33 F9 9B 1E 77 3D 1F can0 1E155FCD [8] E6 BA F8 58 ED 6D C8 10 can0 1D91DF9E [8] 5D 29 82 7B 97 1D AB 5C can0 11FB3CDA [3] 14 65 C3 can0 091352C0 [2] 2C ED ...
On second system:
- Send standard CAN frame:
cansend can0 111#1122334455667788
- Send extended CAN frame:
cansend can0 11111111#1122334455667788
- CAN frames (extended mode) generator, random payload, interval between two successive flames 50 msec:
cangen -g 50 -e -D r -v can0 can: raw protocol (rev 20170425) ... can0 03FF0983#D7.61.FF.03.C1.F7.C1.34 can0 19C34D32#F7.5A.C2.73.AD.0E.3F.0B can0 0675E391#2B.2D.D3.49 can0 13091C55#99.32.EC.77.27.81.49.0B can0 098D67CF#22.50.AB.48.AD.7F.F4.26 can0 05263FEC#1B.4C.02.45.6E can0 12B30E20# can0 1F193DF9#C5 can0 1EB0B18F#3E.3F.DA.57.C2.FE.73.58 can0 1E5C64D9#6F.0D.B3.63.6A can0 1E1DE3F9#96.48.AC.79.4E.00.27.71 can0 0E1A11B7#75.81.70.7C.86.79.A7.77 can0 05F8FD8B#33.F9.9B.1E.77.3D.1F can0 1E155FCD#E6.BA.F8.58.ED.6D.C8.10 can0 1D91DF9E#5D.29.82.7B.97.1D.AB.5C can0 11FB3CDA#14.65.C3 can0 091352C0#2C.ED ...
Ethernet
SBC-MCM93 carrier-board features two Gigabit Ethernet ports implemented with two RTL8211FDI PHYs.
The NetworkManager can be used to manage these interfaces.
Bandwidth test example
Start iperf3 server on host:
iperf3 -s -i 60
Straight (client sends, server receives) 1 min. test with report each 10 sec.
iperf3 -t 60 -i 10
Reverse (server sends, client receives) test
iperf3 -t 60 -i 10 -R
WiFi
SBC-MCM93 carrier-board features 802.11ac wireless connectivity solution implemented with an NXP 88W8997 module.
The NetworkManager can be used to manage WiFi interface.
Before working with WiFi, please ensure that WiFi antenna is connected to the WiFi module. |
Enable/Disable WiFi Interface
- To enable WiFi interface:
nmcli radio wifi on
- To disable WiFi interface:
nmcli radio wifi off
Network Scanning
- Sample WiFi scanning:
nmcli dev wifi list
The output will show the list of Access Points and Ad-Hoc cells in range.
Connecting to Access Point
In the following example:
- Replace <SSID> and <PASSWORD> with the actual access point parameters:
nmcli device wifi connect <SSID> password <PASSWORD> name WifiCon
- Disconnect wireless network:
nmcli connection down WifiCon
- Connect wireless network again:
nmcli connection up WifiCon
Creating Access Point
In the following example:
- Replace <SSID> and <PASSWORD> with desired access point parameters:
nmcli device wifi hotspot ssid <SSID> password <PASSWORD> con-name HotspotCon
- Disable wireless AP:
nmcli connection down HotspotCon
- Enable wireless AP again:
nmcli connection up HotspotCon
Bluetooth
SBC-MCM93 carrier-board features Bluetooth connectivity implemented with an NXP 88W8997 module.
Before working with Bluetooth, please ensure that Bluetooth antenna is connected to the WiFi / Bluetooth. |
To start bluetoothctl use the following command:
bluetoothctl
To start the scan process use the following commands:
default-agent power on scan on
Bluetooth device should be turned on and visible. Its MAC-adress and name should appear in bluetoothctl in following format:
[CHG] Device AA:BB:CC:DD:EE:FF Name: Device_Name
To pair with the Bluetooth device use the following command:
pair AA:BB:CC:DD:EE:FF
Where AA:BB:CC:DD:EE:FF is MAC-adress of the Bluetooth device.
To quit bluetoothctl use the following command:
[Device_Name]# quit
Cellular Modem
The MCM-iMX93 evaluation kit can be optionally supplied with Quectel EG25-G mini-PCIe cellular modem
- Install the modem module into the mini-PCIe socket P8
- Close jumper E1
- Connect a cellular antenna to modem's main antenna connector
- Install an active SIM card into SIM socket P7
- Boot to linux
Run the following command to verify that the modem is detected correctly:
lsusb
Expected output:
Bus 001 Device 002: ID 2c7c:0125 Quectel Wireless Solutions Co., Ltd. EC25 LTE modem
run:
mmcli -L
Expected output:
/org/freedesktop/ModemManager1/Modem/0 [QUALCOMM INCORPORATED] QUECTEL Mobile Broadband Module
Obtain <apn> of your sim card company ,e.g. rl.internet
Establish connection:
nmcli connection add type gsm ifname '*' con-name CellularCon apn <apn> nmcli connection
Expected output:
NAME UUID TYPE DEVICE CellularCon a1620622-8588-4349-b3fc-66be79fbbede gsm cdc-wdm0
Allow up to a minute to connect to wireless network and make sure modem state is connected:
mmcli -m 0
To test the wireless interface run:
ping -c 5 dns.google -I wwan0
UART
The following table outlines default UART routing when MCM-iMX93 is used with the SBC-MCM93 carrier-board:
MCM-iMX93 port | Linux device | on SBC-MCM93 carrier-board | pinout |
UART3 | /dev/ttyLP2 | 100-mil header P20 | 2-rx, 4-tx |
UART5 | /dev/ttyLP4 | 100-mil header P19 | 4-tx, 2-rx, 3-rts, 6-cts |
Example: testing UART5
- Short RX and TX pins on SBC-MCM93 to create a loop-back.
- Run the following commands:
stty -F /dev/ttyLP4 1:0:1cb2:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 cat /dev/ttyLP4 & echo hello > /dev/ttyLP4
The "hello" string should appear on the terminal.
I2C
The following I2C buses and devices are present when MCM-iMX93 is used with the SBC-MCM93 carrier-board:
Device | I2C bus in Linux | Address | HW port in MCM-iMX93 |
user I2C on connector P16 pins: 3-sda, 5-scl |
5 | NA | I2C6 |
To list all mapped devices:
ls /proc/device-tree/soc@0/bus@*/i2c@*/*@* -d -w 1
Note how:
- each node is appended with its address.
- I2C buses order corresponds to the order of their addresses.
e.g. to inspect bus 0, in which we have RTC, run:
# i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: 50 51 52 53 -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- 70: -- -- -- -- -- -- -- --
In the above output numbers mark unused devices, UU marks a device that is used by a driver.
Indeed we see RTC in use at offset 0x69.
An example how to dump EEPROM contents:
hexdump -C /sys/devices/platform/soc@0/44000000.bus/44340000.i2c/i2c-0/0-0050/eeprom
SPI
SBC-MCM93 carrier-board exposes SPI3 port on 10-mil header P15.
ECSPI3_MOSI - pin 3 ECSPI3_SCLK - pin 5 ECSPI3_MISO - pin 2 ECSPI3_SSO - pin 4
Loopback example:
Short MOSI and MISO pins.
Compile test tool:
${CROSS_COMPILE}gcc ./tools/spi/spidev_test.c -o ./spidev_test
Copy the spidev_test binary to the SoM.
On the module, run:
./spidev_test -v -D /dev/spidev0.0 -p "hello"
You should see RX same as TX.
GPIO
SBC-MCM93 carrier-board provides the following MCM-iMX93 GPIOs on 100-mil header P18.
Name in u-boot | pin | GPIO # in sysfs |
GPIO2_18 | 2 | 512+18 |
gpio@20_0 | 4 | 640 |
GPIO2_21 | 3 | 512+21 |
GPIO2_24 | 5 | 512+24 |
GPIO2_26 | 7 | 512+26 |
GPIO2_22 | 9 | 512+22 |
Example: controlling pin GPIO2_18
Exporting the pin in sysfs
cd /sys/class/gpio/ echo $((512+18)) > export cd /sys/class/gpio/gpio$((512+18))
Now pin is assigned to sysfs. You can view the newly created entry in gpiochip0, line 18 by running:
gpioinfo
Writing to a pin
Set pin direction to output:
echo out > direction
Set pin value to high or low:
echo 1 > value echo 0 > value
Reading from a pin
Set pin direction to input:
echo in > direction
Read the value of the pin from the value file:
cat value
ADC
i.MX93 SoC features integrated 12 bit analog to digital converter.
for sysfs device controls go to:
cd /sys/bus/iio/devices/iio\:device0/
SBC-MCM93 exposes ADC signals on 100-mil header P9.
Signal Name | pin on P9 | sysfs file |
ADC_IN0 | 2 | in_voltage0_raw |
ADC_IN1 | 4 | in_voltage1_raw |
ADC_IN2 | 6 | in_voltage2_raw |
ADC_IN3 | 3 | in_voltage3_raw |
For example, to read voltage from P9-2 run:
cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
Expected output is a value in range 0 - 4095 which spans over the voltage range 0 - 1.8V
Suspend / Resume
The following operation requires root access. |
MCM-iMX93 features suspend mode, which allows to minimize power consumption.
The following command should be used to enter suspend mode:
echo mem >/sys/power/state
To resume normal operation press shortly the power button SW4.
CPU temperature
i.MX93 SoC features an internal temperature sensor which allows to measure the SoC temperature. Execute the following command to read the current CPU temperature:
cat /sys/class/thermal/thermal_zone0/temp
RTC
MCM-iMX93 features two RTC devices:
- i.MX93 internal RTC (rtc0) - can be used as wake-up source
- AB1805 external RTC (rtc1) - can be used for low current battery powered time keeper
Internal RTC - rtc0
System information:
Wake up:
rtc0 can be used as a wake up source, as a result an rtcwakeup can be used with this device:
rtcwake --device /dev/rtc0 -s 5 -m mem
External RTC - rtc1
Set the date and write it into the RTC:
date -s "16 Jun 2023 12:00:00" Fri 16 Jun 2023 12:00:00 hwclock --systohc --rtc /dev/rtc1
Read the RTC time and date:
hwclock --show --rtc /dev/rtc1 2023-06-16 12:01:37.935876+00:00
Device Serial Number
Product information is stored in on-board EEPROM.
- To read the product serial number run:
cat /proc/device-tree/product-sn && echo
- To read the product configuration part number run:
cat /proc/device-tree/product-options && echo