米尔i.MX6UL开发板Linux应用开发(一) 点击:1313 | 回复:0



changnan111

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:11帖 | 1回
  • 年度积分:0
  • 历史总积分:69
  • 注册:2017年12月19日
发表于:2018-01-11 15:15:09
楼主

硬件:米尔i.MX6UL开发板MYD-Y6ULX
简介:MYD-Y6ULX开发板(i.MX6UL开发板)由MYC-Y6ULX核心板和底板组成,基于NXP i.MX6UL处理器或i.MX6ULL处理器可选,MYD-Y6ULX开发板(i.MX6ULL开发板)提供丰富外设硬件,板载了Mini PCIE接口(用于4G模块)及SIM卡槽、WIFI芯片及天线接口、双百兆网口、LCD液晶接口、音频接口、带隔离的CAN,RS485,RS232等。

部署开发环境:开发前需要PC安装好Linux操作系统,推荐使用Ubuntu 16.04 64bit发行版,连接网线并配置好网络,后续操作需要连接互联网安装或下载相关软件包。

本章主要介绍MYD-Y6ULX开发板底板外围硬件设备应用例程的使用。
使用前,需要先安装Yocto提供的SDK工具链,再编译所有例程代码,并拷贝至开发板目录下。
编译应用例程
加载工具链到当前终端后,可以查看gcc的版本信息,确认当前环境已正确加载。
$source /opt/myir-imx6ulx-fb/4.1.15-2.0.1/environment-setup-cortexa7hf-neon-\
poky-linux-gnueabi
$ arm-poky-linux-gnueabi-gcc --version
arm-poky-linux-gnueabi-gcc (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

编译示例代码:
$cd $DEV_ROOT/04-Sources
$tar xvf example.tar.gz
$cd example
$make

Ethernet 测试
本例使用Linux sokect API,实现简单的C/S结构的程序,两个程序通过TCP/IP协议栈通信。将可执行程序arm_client拷贝至开发板,pc_server拷贝
至PC,将开发板和PC接入网络。
在 PC 上配置IP并运行服务程序:
$ sudo ifconfig eth0 192.168.1.111
$ ./pc_server
REC FROM: 192.168.1.222

在开发板上运行客户程序,将看到所发送的信息:
# ifconfig eth0 192.168.1.222
# ./arm_client 192.168.1.111
form server: Make Your idea Real!

GPIO-KEY 测试
本例演示如何在Linux用户空间读取按键状态和键值。运行gpio_key程序后,按下或释放S2按键,串口会输出相应按键的状态信息。按下"Ctrl-C"可
退出程序。
在开发板的控制终端上执行程序:
# ./gpio_key /dev/input/event2
Hit any key on board ......
key 2 Pressed
key 2 Released
key 2 Pressed
key 2 Released

GPIO-LED 测试
本例程演示使用Linux系统API操作开发板上的LED灯,D30。运行程序后,D30闪烁。按下"Ctrl-C"可结束程序。
# ./gpio_led /sys/class/leds/user/brightness

USB Host 测试
使用USB存储设备插入USB HOST(J6)接口,调试串口会输出检测设备信息。同时,使用将此存储设备挂载至linux系统下对其读写。
# usb 1-2: USB disconnect, device number 6
usb 1-2: new high-speed USB device number 7 using atmel-ehci
usb 1-2: New USB device found, idVendor=0bda, idProduct=0316
usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2: Product: USB3.0-CRW
usb 1-2: Manufacturer: Generic
usb 1-2: SerialNumber: 20120501030900000
usb-storage 1-2:1.0: USB Mass Storage device detected
scsi host5: usb-storage 1-2:1.0
scsi 5:0:0:0: Direct-Access Generic- SD/MMC 1.00 PQ:
0 ANSI: 4
sd 5:0:0:0: [sda] 31116288 512-byte logical blocks: (15.9 GB/14.8
GiB)
sd 5:0:0:0: [sda] Write Protect is off
sd 5:0:0:0: [sda] Write cache: disabled, read cache: enabled, doesn't
support DPO or FUA
sda: sda1 sda2
sd 5:0:0:0: [sda] Attached SCSI removable disk
# mount /dev/sda1 /mnt/
# echo "hello" > /mnt/hello.txt
# cat

USB Device测试
本例程演示使用开发板的Micro USB接口(J26)作为Device模式,可以将指定的文件或设备模拟为设备,连接到其它USB HOST设备。这里把内存作为
存储设备提供给HOST设备。
开发板上使用modprobe加载驱动:
#mkfs.vfat /dev/ram1
#modprobe g_mass_storage file=/dev/ram1 removable=1 \
iSerialNumber="1234"
[ 3048.950498] Mass Storage Function, version: 2009/09/11
[ 3048.982245] LUN: removable file: (no medium)
[ 3048.997849] LUN: removable file: /dev/ram1
[ 3049.000674] Number of LUNs=1
[ 3049.002272] Number of LUNs=1
[ 3049.023990] g_mass_storage gadget: Mass Storage Gadget,
version: 2009/09/11
[ 3049.029682] g_mass_storage gadget: g_mass_storage ready
[ 3094.766373] g_mass_storage gadget: high-speed config
#1: Linux File-Backed Storage

Linux PC机上查看到有USB设备接入,SerialNumber为"1234",Manufacturer是内核构建版本号:
#dmesg | tail -n 20
[2872436.778616] usb 1-1: USB disconnect, device number 102
[2872436.779156] sd 3:0:0:0: [sdb] Synchronizing SCSI cache
[2872436.779201] sd 3:0:0:0: [sdb] Synchronize Cache(10)
failed: Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK
[2872442.508567] usb 1-1: new high-speed USB device number 103
using xhci_hcd
[2872442.650549] usb 1-1: New USB device found, idVendor=0525,
idProduct=a4a5
[2872442.650551] usb 1-1: New USB device strings: Mfr=3, Produ
ct=4, SerialNumber=5
[2872442.650552] usb 1-1: Product: Mass Storage Gadget
[2872442.650553] usb 1-1: Manufacturer: Linux 4.1.15-1.2.0+g8d9
8da6 with 2184000.usb
[2872442.650554] usb 1-1: SerialNumber: 1234
[2872442.657827] usb-storage 1-1:1.0: USB Mass Storage device
detected
[2872442.657895] usb-storage 1-1:1.0: Quirks match for vid 0525
pid a4a5: 10000
[2872442.657923] scsi host3: usb-storage 1-1:1.0
[2872443.669426] scsi 3:0:0:0: Direct-Access Linux File-
Stor Gadget 0401 PQ: 0 ANSI: 2
[2872443.669886] sd 3:0:0:0: Attached scsi generic sg1 type 0
[2872443.670820] sd 3:0:0:0: [sdb] 131072 512-byte logical blocks:
(67.1 MB/64.0 MiB)
[2872443.779976] sd 3:0:0:0: [sdb] Write Protect is off
[2872443.779979] sd 3:0:0:0: [sdb] Mode Sense: 0f 00 00 00
[2872443.890093] sd 3:0:0:0: [sdb] Write cache: enabled, read cache:
enabled, doesn't support DPO or FUA
[2872444.110372] sdb:
[2872444.330074] sd 3:0:0:0: [sdb] Attached SCSI removable disk

此章结束,下一章将继续介绍i.MX6UL开发板的Linux应用开发(二)。




热门招聘
相关主题

官方公众号

智造工程师