MCM-iMX93: Yocto Linux: How-To Guide

From Compulab Mediawiki
Revision as of 10:04, 19 February 2025 by Igor (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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

Switching the 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

  1. Use a micro-USB cable to connect the console to an USB port on your host PC.
  2. 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
  3. 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
  4. Start a terminal emulation program (such as PuTTY on Windows or minicom on Linux).
  5. 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

CAN bus interface is available via header P17. CAN bus on-board termination is enabled by shorting jumper E6.

Operation Example

  • Obtain another board with CAN interface
  • Short jumper E6
  • Connect:
DUT Header P17          Device 2
CAN_H (pin 2) --------  CAN_H
CAN_L (pin 6) --------  CAN_L
  • Configure both CAN interface bit-rate to 1 Mbit/sec:
ip link set can0 up type can bitrate 1000000
  • On both system, listen to received data frames as well as error frames:
candump any,0:0,#FFFFFFFF &
  • Send data from one system and expect to receive it on the other:
  • Standard frame:
cansend can0 111#1122334455667788
  • Extended frame:
cansend can0 11111111#1122334455667788
  • Generate 50 random extended frames with 50 msec interval between each:
cangen -g 50 -e -D r -v can0 -n 50
  • Disable the interfaces:
ip link set can0 down

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.

Admolition note.png 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

  • Prepare routing:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
systemctl stop dnsmasq.service
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i uap0 -o eth0 -j ACCEPT
iptables-save > /etc/iptables/iptables.rules
sudo sed -i 's/^#\(net.ipv[4,6].*forward\)/\1/' /etc/sysctl.conf
nmcli radio wifi on
  • In the following example Replace <SSID> and <PASSWORD> with desired access point parameters:
nmcli device wifi hotspot ssid <SSID> password <PASSWORD> con-name HotspotCon ifname uap0
  • 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.


Admolition note.png 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 P19 2-rx, 4-tx
UART5 /dev/ttyLP4 100-mil header P20 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.

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

Admolition note.png The operation below requires root access.
  • Suspend mode allows minimizing the power consumption.
  • WiFi device currently doesn't support suspension so you should first run:
ip link set mlan0 down
ip link set uap0 down
ip link set wfd0 down
modprobe -r moal
modprobe -r btmrvl_sdio 
  • 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.
  • To enter temporary sleep run:
rtcwake -s 5 -m mem -d /dev/rtc0

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

User LEDs

operation

turn green LED on

echo default-on > /sys/class/leds/user-led1-green/trigger

turn green LED off

echo none > /sys/class/leds/user-led1-green/trigger

turn yellow LED on

echo default-on > /sys/class/leds/user-led2-yellow/trigger

turn yellow LED off

echo none > /sys/class/leds/user-led2-yellow/trigger

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

See Also