Latest Posts

uboot下的mii命令简介


uboot下有一个mii命令。命令帮助信息如下:

mii - MII utility commands                                                      
                                                                                
Usage:                                                                          
mii device                     - list available devices                         
mii device            - set current device                             
mii info                 - display MII PHY info                           
mii read            - read  MII PHY  register             
mii write     - write MII PHY  register             
mii dump            - pretty-print   (0-5 only)           
Addr and/or reg may be ranges, e.g. 2-7. 

 

mii device示例,会输出MDC/MDIO总线设备

uboot>mii device                                                           
MII devices: 'FSL_MDIO0' 'FM_TGEC_MDIO'
Current device: 'FSL_MDIO0'

 

mii info打印输出,PHY后面跟的就是addr

uboot> mii info
PHY 0x00: OUI = 0x5043, Model = 0x1D, Rev = 0x01, 1000baseT, FDX
PHY 0x01: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x02: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x03: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x04: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x05: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x06: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x07: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX

 

mii read          - read  MII PHY register            
mii write   - write MII PHY register  

上述两个命令,需要根据具体的芯片手册寄存器设置来进行配置。以下命令为示例

mii write 0 0 0x8000    向地址为0的phy芯片的0寄存器写入0x8000

mii  read 0 0     读取地址为0的phy芯片的寄存器0的值


Read More

RJ45网口两个LED灯的指示意义以及控制原理


一般RJ45网口会有两个LED灯,至少从外观上看是两个。一个是link灯,一个是ACT灯。

参考下图所示,缺口朝上,一般右边绿灯常亮,表示link上,左边黄色、橘色、或者绿色灯闪烁,表示有数据传输。

有些act灯实际可能有多个是个多色灯,比如黄色、绿色。当100M时闪绿灯,当千兆时闪黄灯,以做区分。

 

这些灯是有PHY进行控制的。PHY的硬件接口文档中会有说明,以及相关的寄存器设置。

在uboot中可以使用mii来修改寄存器,改变亮灯状态。

在linux系统下,可以使用内核、驱动或者mii-tools修改控制灯的状态。

这些如何操作需要参考具体的硬件手册,因硬件手册厂家一般是不公开的,但从网上也能够找到零星的资料。

以下能够查找到的网上公开资料,可供参考

RTL8211F在uboot下使用mii工具配置网口灯详解

RJ45 LED灯


Read More

查centos的发行版本名称和版本号


rhel系统 cat /etc/os-release cat /etc/system-release cat /etc/redhat-release
centos系统 cat /etc/centos-release
fedora系统 cat /etc/fedora-release


Read More

主轴起旋时间spin up time解释


主轴起旋时间spin up time解释。

该词的来源是SMART Attribute。

03 03 Spin-Up Time Lower Average time of spindle spin up (from zero RPM to fully operational).

 

03(003)主轴起旋时间 Spin Up Time
主轴起旋时间就是主轴电机从启动至达到额定转速所用的时间,数据值直接显示时间,单位为毫秒或者秒,因此数据值越小越好。不过对于正常硬盘来说,这一项仅仅是一个参考值,硬盘每次的启动时间都不相同,某次启动的稍慢些也不表示就有问题。
硬盘的主轴电机从启动至达到额定转速大致需要4秒~15秒左右,过长的启动时间说明电机驱动电路或者轴承机构有问题。旦这一参数的数据值在某些型号的硬盘上总是为0,这就要看当前值和最差值来判断了。 
对于固态硬盘来说,所有的数据都是保存在半导体集成电路中,没有主轴电机,所以这项没有意义,数据固定为0,当前值固定为100。

Spin-up time - is the time required to accelerate the disk to operating speed. Frequently used drives are often left spinning to improve access time, but drives may be spun down to reduce energy use or noise.

crystal diskinfo


Read More

CentOS7图形界面与命令行界面切换


方法一

开机以命令模式启动,执行:

systemctl set-default multi-user.target

 

开机以图形界面启动,执行:

systemctl set-default graphical.target

方法2

命令行界面下进入图形界面

startx

方法3

图形界面下显示命令行

ctrl+alt+F2

在这个命令行界面再返回图形界面

alt+F1或者

ctrl+alt+F1

方法4

在命令上 输入 init 3 命令 切换到dos界面 

输入 init 5命令 切换到图形界面

 


Read More

Linux cmp命令用于比较两个文件是否有差异


Linux cmp命令用于比较两个文件是否有差异,使用参数可以对文件部分内容进行比较。

$ cmp --help
用法: cmp [选项]... 文件1 [文件2 [跳1 [跳2]]]
逐字节比较两个文件。

<跳1> 和 <跳2> 分别是每个文件要略过的字节数。

长选项的必需参数也是相应短选项的必需参数。
  -b  --print-bytes          打印出内容相异的字节
  -i, --ignore-initial=SKIP         两个输入内容都略过前 SKIP 字节
  -i, --ignore-initial=跳1:跳2      略过 <文件1> 的前 <跳1> 个字节和文件 <文件2>
                                    的前 <跳2> 个字节。
  -l, --verbose              输出所有相异字节的字节数和内容
  -n, --bytes=限制           最多比较 <限制> 个字节
  -s, --quiet, --silent      suppress all normal output
      --help                 显示此帮助信息并退出
  -v, --version              输出版本信息并退出

<跳> 值可以加上以下的单位:
kB=1,000、K=1,024、MB=1,000,000、M=1,048,576、GB=1,000,000,000、G=107,374,182,
还有 T、P、E、Z、Y,如此类推。

如果文件是 “-” 或没给出,则从标准输入读入内容。
如果输入相同,则退出状态为 0;1 表示输入不同;2 表示有错误产生。

命令示例

比较两个文件是否相同,并查看返回值

$ cmp 6M00.bin 6MFF.bin
6M00.bin 6MFF.bin 不同:第 1 字节,第 1 行

$ echo $?
1

$ cmp 6M00.bin 6M00.bin

$ echo $?
0

特殊用法,指定偏移位置,指定比较数量。

$ cmp -i 0:102 6M00.bin 6MFF.bin -n 100
6M00.bin 6MFF.bin 不同:第 1 字节,第 1 行

$ echo $?
1

 


Read More

Linux tr 命令用于转换或删除文件中的字符。


tr [-cdst][--help][--version][第一字符集][第二字符集]  
tr [OPTION]…SET1[SET2] 

 

 

$ tr --help
用法:tr [选项]... SET1 [SET2]
Translate, squeeze, and/or delete characters from standard input,
writing to standard output.

  -c, -C, --complement    use the complement of SET1
  -d, --delete            delete characters in SET1, do not translate
  -s, --squeeze-repeats   replace each sequence of a repeated character
                            that is listed in the last specified SET,
                            with a single occurrence of that character
  -t, --truncate-set1     first truncate SET1 to length of SET2
      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

SET 是一组字符串,一般都可按照字面含义理解。解析序列如下:

  \NNN  八进制值为NNN 的字符(1 至3 个数位)
  \\            反斜杠
  \a            终端鸣响
  \b            退格
  \f            换页
  \n            换行
  \r            回车
  \t            水平制表符
  \v            垂直制表符
  字符1-字符2   从字符1 到字符2 的升序递增过程中经历的所有字符
  [字符*]       在SET2 中适用,指定字符会被连续复制直到吻合设置1 的长度
  [字符*次数]   对字符执行指定次数的复制,若次数以 0 开头则被视为八进制数
  [:alnum:]     所有的字母和数字
  [:alpha:]     所有的字母
  [:blank:]     所有呈水平排列的空白字符
  [:cntrl:]     所有的控制字符
  [:digit:]     所有的数字
  [:graph:]     所有的可打印字符,不包括空格
  [:lower:]     所有的小写字母
  [:print:]     所有的可打印字符,包括空格
  [:punct:]     所有的标点字符
  [:space:]     所有呈水平或垂直排列的空白字符
  [:upper:]     所有的大写字母
  [:xdigit:]    所有的十六进制数
  [=字符=]      所有和指定字符相等的字符

Translation occurs if -d is not given and both SET1 and SET2 appear.
-t may be used only when translating.  SET2 is extended to length of
SET1 by repeating its last character as necessary.  Excess characters
of SET2 are ignored.  Only [:lower:] and [:upper:] are guaranteed to
expand in ascending order; used in SET2 while translating, they may
only be used in pairs to specify case conversion.  -s uses the last
specified SET, and occurs after translation or deletion.

将文件testfile中的小写字母全部转换成大写字母,此时,可使用如下命令:

cat testfile |tr a-z A-Z 

示例将ab转化为AB

# echo abc |tr ab AB
ABc


Read More

linux创建一定大小文件命令--dd


本文讲解了linux创建文件命令:dd。使用dd这个linux命令可以创建一定大小文件。

linux创建文件命令:dd命令

把指定的输入文件拷贝到指定的输出文件中,并且在拷贝的过程中可以进行格式转换。语法:

$ dd --help
用法:dd [操作数] ...
 或:dd 选项
Copy a file, converting and formatting according to the operands.

  bs=BYTES        read and write up to BYTES bytes at a time
  cbs=BYTES       convert BYTES bytes at a time
  conv=CONVS      convert the file as per the comma separated symbol list
  count=N         copy only N input blocks
  ibs=BYTES       read up to BYTES bytes at a time (default: 512)
  if=FILE         read from FILE instead of stdin
  iflag=FLAGS     read as per the comma separated symbol list
  obs=BYTES       write BYTES bytes at a time (default: 512)
  of=FILE         write to FILE instead of stdout
  oflag=FLAGS     write as per the comma separated symbol list
  seek=N          skip N obs-sized blocks at start of output
  skip=N          skip N ibs-sized blocks at start of input
  status=LEVEL    The LEVEL of information to print to stderr;
                  'none' suppresses everything but error messages,
                  'noxfer' suppresses the final transfer statistics,
                  'progress' shows periodic transfer statistics

N and BYTES may be followed by the following multiplicative suffixes:
c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M,
GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Each CONV symbol may be:

  ascii     from EBCDIC to ASCII
  ebcdic    from ASCII to EBCDIC
  ibm       from ASCII to alternate EBCDIC
  block     pad newline-terminated records with spaces to cbs-size
  unblock   replace trailing spaces in cbs-size records with newline
  lcase     change upper case to lower case
  ucase     change lower case to upper case
  sparse    try to seek rather than write the output for NUL input blocks
  swab      swap every pair of input bytes
  sync      pad every input block with NULs to ibs-size; when used
            with block or unblock, pad with spaces rather than NULs
  excl          fail if the output file already exists
  nocreat       do not create the output file
  notrunc       不截断输出文件
  noerror       读取数据发生错误后仍然继续
  fdatasync     结束前将输出文件数据写入磁盘
  fsync 类似上面,但是元数据也一同写入

FLAG 符号可以是:

  append        追加模式(仅对输出有意义;隐含了conv=notrunc)
  direct        使用直接I/O 存取模式
  directory     除非是目录,否则 directory 失败
  dsync         使用同步I/O 存取模式
  sync          与上者类似,但同时也对元数据生效
  fullblock     为输入积累完整块(仅iflag)
  nonblock      使用无阻塞I/O 存取模式
  nocache   Request to drop cache.  See also oflag=sync
  noctty        不根据文件指派控制终端
  nofollow      不跟随链接文件
  binary        使用二进制I/O 存取模式
  text  使用文本I/O 存取模式
  count_bytes  treat 'count=N' as a byte count (iflag only)
  skip_bytes  treat 'skip=N' as a byte count (iflag only)
  seek_bytes  treat 'seek=N' as a byte count (oflag only)

Sending a USR1 signal to a running 'dd' process makes it
print I/O statistics to standard error and then resume copying.

Options are:

      --help            显示此帮助信息并退出
      --version         显示版本信息并退出

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告dd 的翻译错误
Full documentation at: <http://www.gnu.org/software/coreutils/dd>
or available locally via: info '(coreutils) dd invocation'

 

实例:

创建一个100M的空文件

dd if=/dev/zero of=hello.txt bs=100M count=1

以上是linux创建文件命令:dd的用法。


Read More


© 2008-2022 CunYouLu存有录博客 村友录 存游录 鲁ICP备08005943号