![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2cb2162cea9812cbb8f42dd3b6788aad.png)
u-boot切到linux 时,卡住了
对比发现板子问题,量到这时候的电平是tf io是3.3v,发现是切不到1.8v,因为跑内核需要切到高速
后来发现是调节IO电平的IO坏了
ad8ef7a3e4a1a93c1f87bd491c12f.png)
Rom code(空板)从sdcard卡启动必须要供电正常,且IO要3.3v,才能被识别到且启动
sdcard识别不到sdr104
[ 2.122929] mmc1: new high speed SDHC card at address aaaa
[ 2.128984] mmcblk1: mmc1:aaaa SD32G 29.7 GiB
[ 2.135164] mmcblk1: p1 p2
cat /sys/kernel/debug/mmc1/ios
clock: 50000000 Hz
actual clock: 50000000 Hz
vdd: 21 (3.3 ~ 3.4 V)
bus mode: 2 (push-pull)
chip select: 0 (don't care)
power mode: 2 (on)
bus width: 2 (4 bits)
timing spec: 2 (sd high-speed)
signal voltage: 0 (3.30 V)
driver type: 0 (driver type B)
发现IO电压只能3.3V不能切1.8V,通过修改后,支持切换到1.8V后识别了sdr104
[ 1.643107] mmc1: new high speed SDHC card at address aaaa
[ 1.649063] mmcblk1: mmc1:aaaa SD32G 29.7 GiB
[ 1.654757] mmcblk1: p1 p2
cat /sys/kernel/debug/mmc1/ios
clock: 200000000 Hz
actual clock: 200000000 Hz
vdd: 21 (3.3 ~ 3.4 V)
bus mode: 2 (push-pull)
chip select: 0 (don't care)
power mode: 2 (on)
bus width: 2 (4 bits)
timing spec: 6 (sd uhs SDR104)
signal voltage: 1 (1.80 V)
driver type: 0 (driver type B)
量sdcard sdr104 的clk是200M左右
不清理内核缓存,对同一个文件连续进行多次读速度测试差异大,不准确
需要用以下命令清除内核缓存,每次测试前都要清除
sync; echo 3 > /proc/sys/vm/drop_caches
下面命令在参数中设置不使用缓存
读
dd if=/dev/mmcblk1 of=/dev/null bs=1G count=1 iflag=direct
写
dd if=/dev/zero of=testfile bs=1G count=1 oflag=direct
sdr104
dd if=/dev/mmcblk1 of=/dev/null bs=1G count=1 iflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 11.6883 s, 91.9 MB/s
dd if=/dev/zero of=testfile bs=1G count=1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 55.9383 s, 19.2 MB/s
拿同样一块tf卡(先抛开不同的文件系统格式,平台不支持extfat/ntfs格式),在 window上用工具软件ATTO 磁盘基准测试.exe测试了,写与读的速度差异较大,4-5倍的样子
为什么TF卡的随机写入性能那么差?
如何浅显易懂地解释「闪存」?它的存储原理是什么?
SD卡在写入时需要先将该区块,应该是256KB置1才能编程,这需要时间,这样时间就耗费在擦除区块上,而读的时候直接读取即可。写的数据越零碎开销就越大,所以就会更慢
tf卡自动搭载
Linux下udev应用
系统是通过将分区名与设备名连接在一起组合成挂载的文件名,名字中有mmcblk1就是接入tf卡槽的卡/dev/mmcblk1p1 /dev/mmcblk1p2
/dev/mmcblk1 /dev/mmcblk1p1 /dev/mmcblk1p2 /dev/mmcblk1p2 /dev/mmcblk1p1
最后脚本处理后挂载到对应的点
root@:/etc/udev/scripts# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/root 14793608 4347476 9672860 32% /
devtmpfs 1437484 4 1437480 1% /dev
tmpfs 1700588 0 1700588 0% /dev/shm
tmpfs 1700588 9164 1691424 1% /run
tmpfs 1700588 0 1700588 0% /sys/fs/cgroup
tmpfs 1700588 0 1700588 0% /tmp
tmpfs 16384 0 16384 0% /media/ram
tmpfs 51200 920 50280 2% /var/volatile
tmpfs 340116 0 340116 0% /run/user/0
/dev/mmcblk1p2 30374844 4577016 24229524 16% /run/media/mmcblk1p2
/dev/mmcblk1p1 137105 3160 133946 3% /run/media/mmcblk1p1
/etc/udev/scripts/mount.sh
调试可以知,脚本中的$DEVNAME是系统udev得到设备节点的路径名
#!/bin/sh
#
# Called from udev
#
# Attempt to mount any added block devices and umount any removed devices
BASE_INIT="`readlink -f "/sbin/init"`"
INIT_SYSTEMD="/lib/systemd/systemd"
if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then
# systemd as init uses systemd-mount to mount block devices
MOUNT="/usr/bin/systemd-mount"
UMOUNT="/usr/bin/systemd-umount"
if [ -x $MOUNT ] && [ -x $UMOUNT ];
then
logger "Using systemd-mount to finish mount"
else
logger "Linux init is using systemd, so please install systemd-mount to finish mount"
exit 1
fi
else
MOUNT="/bin/mount"
UMOUNT="/bin/umount"
fi
PMOUNT="/usr/bin/pmount"
for line in `grep -h -v ^# /etc/udev/mount.blacklist /etc/udev/mount.blacklist.d/*`
do
if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ];
then
logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
exit 0
fi
done
automount_systemd() {
name="`basename "$DEVNAME"`"
# Skip already mounted partitions
if [ -f /run/systemd/transient/run-media-$name.mount ]; then
logger "mount.sh/automount" "/run/media/$name already mounted"
return
fi
# Skip the partition which are already in /etc/fstab
grep "^[[:space:]]*$DEVNAME" /etc/fstab && return
for n in LABEL PARTLABEL UUID PARTUUID; do
tmp="$(lsblk -o $n $DEVNAME | sed -e '1d')"
test -z "$tmp" && continue
tmp="$n=$tmp"
grep "^[[:space:]]*$tmp" /etc/fstab && return
done
[ -d "/run/media/$name" ] || mkdir -p "/run/media/$name"
MOUNT="$MOUNT -o silent"
# If filesystemtype is vfat, change the ownership group to 'disk', and
# grant it with w/r/x permissions.
case $ID_FS_TYPE in
vfat|fat)
MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`"
;;
swap)
return ;;
# TODO
*)
;;
esac
if ! $MOUNT --no-block -t auto $DEVNAME "/run/media/$name"
then
#logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!"
rm_dir "/run/media/$name"
else
logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful"
touch "/tmp/.automount-$name"
fi
}
automount() {
name="`basename "$DEVNAME"`"
if [ -x "$PMOUNT" ]; then
$PMOUNT $DEVNAME 2> /dev/null
elif [ -x $MOUNT ]; then
$MOUNT $DEVNAME 2> /dev/null
fi
# If the device isn't mounted at this point, it isn't
# configured in fstab
grep -q "^$DEVNAME " /proc/mounts && return
! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
# Silent util-linux's version of mounting auto
if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
then
MOUNT="$MOUNT -o silent"
fi
# If filesystem type is vfat, change the ownership group to 'disk', and
# grant it with w/r/x permissions.
case $ID_FS_TYPE in
vfat|fat)
MOUNT="$MOUNT -o umask=007,gid=`awk -F':' '/^disk/{print $3}' /etc/group`"
;;
swap)
return ;;
# TODO
*)
;;
esac
if ! $MOUNT -t auto $DEVNAME "/run/media/$name"
then
#logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!"
rm_dir "/run/media/$name"
else
logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful"
touch "/tmp/.automount-$name"
fi
}
rm_dir() {
# We do not want to rm -r populated directories
if test "`find "$1" | wc -l | tr -d " "`" -lt 2 -a -d "$1"
then
! test -z "$1" && rm -r "$1"
else
logger "mount.sh/automount" "Not removing non-empty directory [$1]"
fi
}
# No ID_FS_TYPE for cdrom device, yet it should be mounted
name="`basename "$DEVNAME"`"
[ -e /sys/block/$name/device/media ] && media_type=`cat /sys/block/$name/device/media`
if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_type" = "cdrom" ]; then
# Note the root filesystem can show up as /dev/root in /proc/mounts,
# so check the device number too
if expr $MAJOR "*" 256 + $MINOR != `stat -c %d /`; then
if [ "`basename $MOUNT`" = "systemd-mount" ];then
automount_systemd
else
automount
fi
fi
fi
if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
do
$UMOUNT $mnt
done
# Remove empty directories from auto-mounter
name="`basename "$DEVNAME"`"
test -e "/tmp/.automount-$name" && rm_dir "/run/media/$name"
fi
tf卡启动,开不了机
硬件发现是卡槽有问题,没有检测到卡有接入,所以没能开机