15AH, San Francisco

California, United States.

Send Your Mail At:

tianyingkejishe@sina.cn

Working Hours

Mon-Sat: 9.30am To 7.00pm

分类标题

Autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et dolore feugait.

分类归档 Linux

【Linux】打印机环境安装一

一、环境配置

 sudo apt-get update
 sudo apt-get upgrade
 sudo apt install cups  #公共UNIX打印系统

二、驱动安装

sudo apt-get install hplip

三、打印机安装

hp-setup -i #第一个选0,第二个按p
xiaobao@armbian:~/software/shareprint$ hp-setup -i

HP Linux Imaging and Printing System (ver. 3.23.12)
Printer/Fax Setup Utility ver. 9.0

Copyright (c) 2001-18 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

(Note: Defaults for each question are maked with a '*'. Press <enter> to accept the default.)


--------------------------------
| SELECT CONNECTION (I/O) TYPE |
--------------------------------

  Num       Connection  Description
            Type
  --------  ----------  ----------------------------------------------------------
  0*        usb         Universal Serial Bus (USB)
  1         net         Network/Ethernet/Wireless (direct connection or JetDirect)

Enter number 0...1 for connection type (q=quit, enter=usb*) ? 0

Using connection type: usb

Setting up device: hp:/usb/DeskJet_1110_series?serial=CN75J28090069Z



---------------------
| PRINT QUEUE SETUP |
---------------------


Please enter a name for this print queue (m=use model name:'DeskJet_1110'*, q=quit) ?
Using queue name: DeskJet_1110
Locating PPD file... Please wait.

Found PPD file: hplip:0/ppd/hplip/HP/hp-deskjet_1110_series.ppd
Description:

Note: The model number may vary slightly from the actual model number on the device.

Does this PPD file appear to be the correct one (y=yes*, n=no, q=quit) ?
Enter a location description for this printer (q=quit) ?
Enter additonal information or notes for this printer (q=quit) ?

Adding print queue to CUPS:
Device URI: hp:/usb/DeskJet_1110_series?serial=CN75J28090069Z
Queue name: DeskJet_1110
PPD file: hplip:0/ppd/hplip/HP/hp-deskjet_1110_series.ppd
Location:
Information:


You do not have permission to add a printer. You need authentication.
Username: root
Password:


---------------------
| PRINTER TEST PAGE |
---------------------


Would you like to print a test page (y=yes*, n=no, q=quit) ? y

HP Linux Imaging and Printing System (ver. 3.23.12)
Testpage Print Utility ver. 6.0

Copyright (c) 2001-18 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.


HP Linux Imaging and Printing System (ver. 3.23.12)
System Tray Status Service ver. 2.0

Copyright (c) 2001-18 HP Development Company, LP
This software comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to distribute it
under certain conditions. See COPYING file for more details.

warning: No display found.
error: hp-systray requires Qt4 GUI and DBus support. Exiting.
warning: Unable to connect to dbus. Is hp-systray running?
Printing test page to printer DeskJet_1110...
请求 ID 为 DeskJet_1110-1 (1 个文件)
Test page has been sent to printer.

note: If an error occured, or the test page failed to print, refer to the HPLIP website
note: at: http://hplip.sourceforge.net for troubleshooting and support.


Done.

Done.

linux 获取OS盘符的方法

在服务器测试中,对硬盘的测试有很多,有些测试用例需要我们写一下自动化的脚本,比如给服务器所有的盘施加压力,这个就需要我们把除了OS盘的所有盘遍历出来,下面介绍几种方法来筛选OS盘
我们知道,判断os 盘的方法一般是看其有没有boot分区,通常用两个指令来获取:lsblk和df -h 下面一次介绍一下这两种方法的写法

1、 lsblk 如图所示 带有boot 分区的就是OS盘

系统盘是sda

系统盘是nvme0n1

shell命令行:

lsblk -l  |grep -i boot -B 1 |grep -i disk |awk '{print $1}'

筛选除了OS外所有的盘符

lsblk -l  |grep -vw sda |grep -i disk |awk '{print $1}'
lsblk -l  |grep -vw nvme0n1 |grep -i disk |awk '{print $1}'

2、 df -h

系统盘是sda

shell命令行

df -h | awk '{print $1}' | grep -iE "/dev/sd" | sed 's/[0-9]//g' |sort -u |awk -F "/" {'print $NF'}

系统盘是nvme0n1

shell 命令行

 df -h | awk '{print $1}' | grep -iE "/dev/nvme" | sed 's/p[0-9]//g' |sort -u |awk -F "/" {'print $NF'}

对此可以写成一个小脚本来判断OS,代码如下:

#!/bin/bash
bootdisk=`df -h |grep -i boot | awk '{print $1}' | grep -iE "/dev/sd" | sed 's/[0-9]//g' |sort -u|awk -F "/" '{print $NF}'`
if  test -z "$bootdisk"
then
        bootdisk=`df -h |grep -i boot| awk '{print $1}' | grep -iE "/dev/nvme" | sed 's/p[0-9]*//g' |sort -u|awk -F "/" '{print $NF}'`
        echo "os disk os $bootdisk"
else
        echo "os disk is $bootdisk"
fi

运行结果如下图:

【phy】yt8521 phy芯片驱动移植

1、准备驱动文件

2、添加到相应目录

把motorcomm.c、yt8614-phy.h放到Linux的linux-5.19.1/drivers/net/phy/

把motorcomm_phy.h放到Linux的linux-5.19.1/include/linux/

3、修改Makefile

增加:obj-$(CONFIG_MOTORCOMM_PHY) += motorcomm.o

4、修改Kconfig

增加:

config MOTORCOMM_PHY
        tristate "Motorcomm PHYs"
        help
          Enables support for Motorcomm network PHYs.
          Currently supports the YT8511 gigabit PHY.

【安凯】环境搭建

一、配置gcc工具

export PATH="${PATH}:/opt/arm-anykav500-linux-uclibcgnueabi/bin"
临时生效,必须使用绝对路径。

二、libmpfr.so.4: cannot open shared object file: No such file or directory

sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4

三、yylloc符号错误

……
186
187 extern YYSTYPE yylval;
188 //extern YYLTYPE yylloc;
189 int yyparse (void);
……
1193 /* The lookahead symbol. / 1194 int yychar; 1195 1196 / The semantic value of the lookahead symbol. / 1197 YYSTYPE yylval; 1198 / Location data for the lookahead symbol. / 1199 static YYLTYPE yylloc 1200 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL 1201 = { 1, 1, 1, 1 } 1202 # endif 1203 ; 1204 / Number of syntax errors so far. */
1205 int yynerrs;
1206
……

调整yylloc为局部符号.

【安凯】SDK编译时./mkfs.jffs2打包失败问题

一、报错

./mkfs.jffs2: error while loading shared libraries: liblzo2.so.2: cannot open shared object file: No such file or directory

二、解决方法

sudo apt-get update              //更新源,可以先执行第二步,不能安装则尝试更新源
sudo apt-get install liblzo2-dev:i386

Shell 中 kill 掉指定名称的进程

在 Linux 开发中我们时常会遇到对于之前进程 kill 掉,然后再运行当前进程或程序的情况,此时我们是不知道需要 kill 的进程号的,那么就需要通过一个 shell 命令组合来实现这个需求。

实现方法

如下命令可以实现:

ps a | grep -w nameprocess | grep -v grep| cut -c 1-6 | xargs kill -9

说明:

  • 管道符 “|” 用来隔开两个命令,管道符左边命令的输出会作为管道符右边命令的输入。
  • “ps a” 是查看所有进程的命令。这时检索出的进程将作为下一条命令 “grep“的输入,注意要结束其它程序时,请将上面命令中的 nameprocess 替换成其它程序名,-w ‘nameprocess’ 强制 PATTERN 仅完全匹配字词。
  • “grep -v grep” 是在列出的进程中去除含有关键字 “grep” 的进程。
  • “cut -c 1-6” 是截取输入行的第 1 个字符到第 6 个字符,而这正好是进程号 PID,或者根据自己实际的情况可以调整字符的截取位置。
  • “xargs kill -9” 中的 xargs 命令是用来把前面命令的输出结果(PID)作为 “kill -9” 命令的参数,并执行该命令。
  • “kill -9” 会强行杀掉指定进程,这样就成功清除了同名进程。

其他方法

ps axu|grep nameprocess | awk '{print "kill -9 "}'

【Linux】分区扩容至整个SD卡

一、查看信息

root@somlabs:~# fdisk -l
省略若干


Disk /dev/mmcblk1: 3.7 GiB, 3965714432 bytes, 7745536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9de2d76a

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p0      16384 1628159 1611776  787M 83 Linux

二、操作分区

假如需要扩展分区为mmcblk0p1

root@somlabs:~# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk1: 3.7 GiB, 3965714432 bytes, 7745536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9de2d76a

Device         Boot Start     End Sectors  Size Id Type
/dev/mmcblk1p1      16384 1628159 1611776  787M 83 Linux
这里也看到Start扇区也是16384
Command (m for help): d
把这个分区删除
Partition 1 has been deleted.

Command (m for help): p
列出分区信息Disk /dev/mmcblk1: 3.7 GiB, 3965714432 bytes, 7745536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9de2d76a

Command (m for help): n
新建分区Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
主分区Partition number (1-4, default 1): 1
分区序号,First sector (2048-7745535, default 2048): 16384
这里要使用起始扇区16384这个值Last sector, +sectors or +size{K,M,G,T,P} (16384-7745535, default 7745535):
默认回车取最大,
Created a new partition 1 of type 'Linux' and of size 3.7 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n
不改变文件分区信号??
Command (m for help): w
写入生效
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

三、重启系统

root@somlabs:~# reboot

四、扩容文件系统

resize2fs /dev/mmcblk1p1
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/mmcblk1p1 is m[  122.795430] EXT4-fs (mmcblk1p1): resizing filesystem from 201472 to 966144 blocks
ounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
[  123.861183] EXT4-fs (mmcblk1p1): resized filesystem to 966144
The filesystem on /dev/mmcblk1p1 is now 966144 (4k) blocks long.

五、查看大小

df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       3.7G  499M  3.0G  15% /
devtmpfs         88M     0   88M   0% /dev
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           248M  3.4M  245M   2% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs            50M     0   50M   0% /run/user/0

【Linux】MTD 动态挂载SPI-NOR flash

1、配置psi-nor为驱动模块

 Device Drivers  --->   
   <*> Memory Technology Device (MTD) support  ---> 
     <M>   SPI NOR device support  ---> 

2、进入内核加载

modpro and insmod xxx.ko

spi-nor.ko