1.查看cpu温度
cat /sys/class/hwmon/hwmon0/temp1_input
2.gpio测试
1)查看gpio组:gpiodetect
2)查看指定gpio9信息:gpioinfo gpiochip9 即查看gpio9的详细信息
3)读取某个gpio9 第0个引脚状态:gpioget gpiochip9 0
4)设置gpio9第0个引脚状态:gpioset gpiochip9 0=1,即设置gpio9第0个引脚为高电平
3.RTC性能测试
1)读取RTC硬件时间: hwclock -r -f /dev/rtc0
显示:Sat Jan 1 00:41:27 2000 0.000000 seconds
2)RTC时间写入系统:hwclock -s -f /dev/rtc0
3)关机保持实际
#busybox date -s 201911060953.30
Wed Nov 6 09:53:30 UTC 2019
4)写入时间并读出时间
# hwclock -w -f /dev/rtc0
# hwclock -r -f /dev/rtc0
5)关机一段时间超过24小时再次读RTC时间
# hwclock -r -f /dev/rtc0
查看重新开机是否能否自动同步系统时间(与硬件无关,与驱动和系统配置相关)
# busybox date
6)RTC复位保持
a.写入时间
# busybox date -s 201911060953.30
b.写入系统时间
# hwclock -w -f /dev/rtc0
c.读出时间
# hwclock -r -f /dev/rtc0
e.硬复位系统后再次读RTC时间
# hwclock -r -f /dev/rtc0
查看重启是否能否自动同步系统时间(与硬件无关,与驱动和系统配置相关)
# busybox date
软复位系统后再次读RTC时间
# hwclock -r -f /dev/rtc0
查看重启是否能否自动同步系统时间(与硬件无关,与驱动和系统配置相关)
# busybox date
4.设置linux用户密码
#passwd
New password:
Retype new password:
passwd: password updated successfully
root@stm32mp1:~#
用ssh的时候,先用网线连接电脑,开发板要给用户设置密码后才能使用
g.使用休眠到内存方式,20s后使用内部RTC唤醒系统
echo +20 > /sys/class/rtc/rtc0/wakealarm; echo mem > /sys/power/state
5.usb挂载
1) fdisk -l
查看磁盘分区情况
2)插入u盘
a.FAT32格式
mount -t vfat /dev/sda /mnt
b.NTFS格式
mount -t ntfs /dev/sda /mnt
c.卸载
umount /mnt
6.蓝牙测试
1)打开蓝牙设备
hciconfig hci0 up
2)如果出现如下信息
Can't init device hci0: Operation not possible due to RF-kill (132)
root@stm32mp1:~# rfkill list
0: hci0: bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: wlan
Soft blocked: yes
Hard blocked: no
则运行命令rfkill unblock 0(或者蓝牙bluetooth)打开蓝牙
3)运行bluetoothctl在这个命令下运行“help” 命令,将会出一系列蓝牙设备命令
4)connect <bluetooth name>进行连接
如:[bluetooth]# connect 74:23:44:CE:B6:7D
Attempting to connect to 74:23:44:CE:B6:7D
[CHG] Device 74:23:44:CE:B6:7D Connected: yes
Connection successful
[CHG] Device 74:23:44:CE:B6:7D ServicesResolved: yes
7.SD卡测试
1)emmc启动 ,插上sd卡显示
root@stm32mp1:~# [ 1194.298356] mmc1: host does not support reading read-only switch, assuming write-enable
[ 1194.309981] mmc1: new high speed SDHC card at address 59b4
[ 1194.316805] mmcblk1: mmc1:59b4 USD00 14.7 GiB
[ 1194.324061] mmcblk1: p1
2)检查磁盘空间,可以看到sd卡信息
fdisk -l
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 8192 30930943 30922752 14.8G c W95 FAT32 (LBA)
3)fdisk /dev/sdb对sd卡进行分区
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
选择n添加分区
Command (m for help): n
To create more partitions, first replace a primary with an extended partition.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-30930943, default 2048): 4096
Last sector, +sectors or +size{K,M,G,T,P} (4096-8191, default 8191):
Created a new partition 2 of type 'Linux' and of size 2 MiB.
Command (m for help):
Command (m for help): w
The partition table has been altered.
这样分区添加完成
4) 格式化分区:mkfs -t ext4 /dev/mmcblk1p2
5)挂载格式化分区到某一个文件下面
mount /dev/mmcblk1p2 /tmp //如挂载到根目录下
6)往测试分区写入
"root@stm32mp1:/tmp# time dd if=/dev/zero of=ffmpeg1 bs=120M count=1 conv=fsync
1+0 records in
1+0 records out
125829120 bytes (126 MB, 120 MiB) copied, 14.1368 s, 8.9 MB/s
real 0m14.220s
user 0m0.000s
sys 0m2.570s
7)往测试分区读出
root@stm32mp1:/tmp# time dd if=ffmpeg1 of=/dev/null bs=120M count=1 iflag=direct,nonblock
1+0 records in
1+0 records out
125829120 bytes (126 MB, 120 MiB) copied, 5.80604 s, 21.7 MB/s
real 0m5.891s
user 0m0.000s
sys 0m0.512s
emmc测试方法类似
8.以太网iperf3测试
TCP测试:
1)首先再windows下需要iperf3工具文件解压放在任意磁盘,记住位置
2)windows下cmd打开命令提示符窗口
a.d:切换到D盘
b.cd \<iperf文件夹>
3)先手动设备电脑ipv4地址,然后ifconfig eth0 xxx.xxx.xxx.xx设置开发板地址,并相互ping看是否ping通
4)做好准备工作后,服务器端iperf3 -s出现下面服务器监听端口,-s参数表示服务器端
5)客户端 iperf3 -c 192.168.0.102 -i 2 -t 60,参数-i间隔时间,-t 时长最大速率以TCP方式向192.168.0.102传送60秒数据流,每隔2秒打印一次,上传速度
root@stm32mp1:~# iperf3 -c 192.168.0.102 -i 2 -t 60
Connecting to host 192.168.0.102, port 5201
[ 5] local 192.168.0.32 port 43120 connected to 192.168.0.102 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-2.00 sec 198 MBytes 828 Mbits/sec 232 182 KBytes
[ 5] 2.00-4.00 sec 209 MBytes 877 Mbits/sec 167 212 KBytes
[ 5] 4.00-6.00 sec 173 MBytes 723 Mbits/sec 115 147 KBytes
[ 5] 6.00-8.00 sec 161 MBytes 676 Mbits/sec 86 118 KBytes
[ 5] 8.00-10.00 sec 138 MBytes 579 Mbits/sec 130 38.5 KBytes
6)iperf3 -c 192.168.0.102 -i 2 -t 60 -R,反转测试方向,也就是服务器发送数据给客户端,也就是下载速度,不加R是上传速度
[ 5] 56.00-58.00 sec 215 MBytes 901 Mbits/sec
[ 5] 58.00-60.00 sec 220 MBytes 922 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate
[ 5] 0.00-60.00 sec 6.08 GBytes 871 Mbits/sec sender
[ 5] 0.00-60.00 sec 6.08 GBytes 871 Mbits/sec receiver
UDP测试:
1)客户端iperf3 -c 192.168.0.102 -u -i 2 -t 60 -b 1G2 -b参数设置目标速率是n bit/sec(UDP默认是每秒1Mbits,TCP/SCTP没有限制),参数-u表示udp,上传速度
[ 5] 56.00-58.00 sec 59.1 MBytes 248 Mbits/sec 42467
[ 5] 58.00-60.00 sec 59.4 MBytes 249 Mbits/sec 42641
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-60.00 sec 1.73 GBytes 248 Mbits/sec 0.000 ms 0/1275702 (0%) sender
[ 5] 0.00-60.00 sec 1.71 GBytes 245 Mbits/sec 0.035 ms 16082/1275702 (1.3%) receiver
2)客户端iperf3 -c x.x.x.x -u -i 2 -t 60 -b 1G -R 服务器发数据给客户端,下载速度
[ 5] 52.00-54.00 sec 59.2 MBytes 248 Mbits/sec 0.258 ms 29663/72152 (41%)
[ 5] 54.00-56.00 sec 68.6 MBytes 288 Mbits/sec 0.009 ms 22917/72196 (32%)
[ 5] 56.00-58.00 sec 85.4 MBytes 358 Mbits/sec 0.008 ms 10792/72151 (15%)
[ 5] 58.00-60.00 sec 73.8 MBytes 309 Mbits/sec 0.230 ms 19354/72378 (27%)
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Jitter Lost/Total Datagrams
[ 5] 0.00-60.00 sec 2.93 GBytes 419 Mbits/sec 0.000 ms 0/2153962 (0%) sender
[ 5] 0.00-60.00 sec 2.14 GBytes 307 Mbits/sec 0.230 ms 579280/2153962 (27%) receiver
9.can调试
1)检查can的设备树
查看can原理图,can1接线如下:
接着再datasheet查看can1的寄存器的基地址为0x4400e000:
在开发板上通过读取设备节点方式查看can1的状态,:
Board $> cat /proc/device-tree/soc/can\@4400e000/status
okay
如果为“ok”表示这个外设是有效的
2)用dmesg检测仔细信息
root@stm32mp1:/proc/device-tree/soc/can@4400e000# dmesg | grep 4400e000
[ 1.980974] m_can 4400e000.can: m_can device registered (irq=37, version=32)
上面命令显示给can设备分配m_can设备驱动。在板子上检查完设备驱动之后,如果正常,再看下硬件配置(设备树)。
3)查看设备树检查对应的硬件信息
can设备树信息:
.dtsi文件
1046 m_can1: can@4400e000 {
1047 compatible = "bosch,m_can";
1048 reg = <0x4400e000 0x400>, <0x44011000 0x1400>;
1049 reg-names = "m_can", "message_ram";
1050 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>,
1051 <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
1052 interrupt-names = "int0", "int1";
1053 clocks = <&rcc CK_HSE>, <&rcc FDCAN_K>;
1054 clock-names = "hclk", "cclk";
1055 bosch,mram-cfg = <0x0 0 0 32 0 0 2 2>;
1056 status = "disabled";
1057 };
.dtb文件
333 /*can*/
334 &m_can1 {
335 pinctrl-names = "default", "sleep";
336 pinctrl-0 = <&m_can1_pins_a_myir>;
337 pinctrl-1 = <&m_can1_sleep_pins_a_myir>;
338 status = "okay";
339 };
一些节点解释:
- compatible=“bosch,m_can”:表示匹配到到bosch,m_can这个驱动程序。
- reg = <0x4400e000 0x400>, <0x44011000 0x1400>:表示控制can1寄存器的基地址和地址范围<0x4400e000 0x400>,以及cansram的基地址和长度,即映射总线上设备的配置空间的地址范围 <0x44011000 0x1400>。
- reg-names = "m_can", "message_ram":使用官方的驱动时需要保持官方的reg-names字段。
- interrupts属性:3个cell的时候,第一个表示中断类型,第二个表示中断号,第三个表示触发电平
a.检查时钟
root@stm32mp1:~# grep -E "clock|can" /sys/kernel/debug/clk/clk_summary | sed 's,\s\+, ,g' | column -t
clock count count count rate accuracy phase cycle
fdcan_k 1 1 0 74250000 0 0 50000
fdcan 0 0 0 104438965 0 0 50000
表示时钟是74.25M Hz。
b.检查can1引脚是否正确
cat /sys/kernel/debug/pinctrl/soc\:pin-controller\@50002000/pinmux-pins | grep 4400e000
cat /sys/kernel/debug/pinctrl/soc\:pin-controller\@50002000/pinconf-pins | grep -E "PA11|PA12"
c.检查中断是否正确
Board $> cat /proc/interrupts | grep can0
各种外设的中断号和GIC查看datasheet 第21章Interrupt list。