小编最近在研究嵌入式打印机系统,走了不少弯路。算是成功的移植到tiny4412 和 QZD4418 中两者区别不大但是 QZD4418 在运行gs 的时候无效,后来找到了解决办法 。为了大家移植方便,我写一写我移植的过程!下面以tiny4421为例:
一、准备工作
配置内核支持USB打印接口
Device Drivers --->
[*] USB support --->
<*> USB Printer support(选择)
二、开发环境
软件环境:
ubuntu 14.04
内核 :linux-3.5-tiny4412.tar.bz2
交叉编译器: arm-linux-gcc-4.5.1-v6-vfp-20120301.tgz
文件系统:busybox-1.17.2 (自己制作的)
硬件环境:
开发板: tiny4412(三星)
开发商: 友善之臂
三、移植说明
前言,我采用的方案是Ghostscript + hpijs-2.1.4 + foo2zjs 下面我具体说一下移植过程和他们之间的联系
1、编译移植Ghostscript-9.04
官网地址:http://www.ghostscript.com/download/gsdnld.html
下载地址:http://iweb.dl.sourceforge.net/project/ghostscript/GPL%20Ghostscript/9.04/ghostscript-9.04.tar.bz2
关于gs 可以查看手册 Use.htm 在包的doc里面 ,这个手册里面有详细的介绍
特别提醒:我之前下载Ghostscript 9.18 当前最新版。移植成功,但是运行出错
gs -h 正常输出
当执行
gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4
-r600x600 -sDEVICE=pbmraw -sOutputFile=test_1.pbm chess.ps
输出如下:
**** Unable to open the initial device, quitting.
Unrecoverable error: unknownerror in .special_op
具体原因Google 很久也没有找到原因,我建议大家移植Ghostscript 9.04
移植步骤:
tar xvjf ghostscript-9.04.tar.bz2
cp ghostscript-9.04 ghostscript-9.04-arm -r && mv ghostscript-9.04 ghostscript-9.04-pc
为什么要编译pc 版呢? 原因是在编译arm版是要用到ghostscript的一些命令,所以为了保证移植顺利必须先编译pc版本
cd ghostscript-9.04-pc && ./configure && make XCFLAGS=-DHAVE_SYS_TIME_H=1 去掉警告
编译成功后,拷贝为如下
cp obj/aux/genarch genarch_arm
cp obj/aux/genconf genconf_arm
cp obj/aux/echogs echogs_arm
cp obj/aux/mkromfs mkromfs_arm
开始编译arm版本
cd ghostscript-9.04-arm
./configure --host=arm-linux --prefix=/opt/gs/ --disable-fontconfig --disable-gtk --disable-cups
注:--prefix=/opt/gs/ 开发也要一样的路径不可以顺便乱放,gs 运行时依赖默认路径
会有两次出错
第一次:
cp genarch_arm obj/aux/genarch
cp genconf_arm obj/aux/genconf
cp echogs_arm obj/aux/echogs
第二次:
cp mkromfs_arm obj/aux/mkromfs
不出错的话编译通过
最后:
make install DESTDIR=${PWD}_install
cp _install/opt/gs /opt/ -rf (开发板)
cp gs /bin/ (开发板)
大功告成:
可以运行
gs -h
输出如下:
GPL Ghostscript 9.04 (2011-08-05)
Copyright (C) 2011 Artifex Software, Inc. All rights reserved.
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
-dNOPAUSE no pause after page | -q `quiet', fewer messages
-g
-sDEVICE=
-sOutputFile=
embed %d or %ld for page #
Input formats: PostScript PostScriptLevel1 PostScriptLevel2 PostScriptLevel3 PDF
Default output device: bbox
Available devices:
alc1900 alc2000 alc4000 alc4100 alc8500 alc8600 alc9100 ap3250 appledmp
atx23 atx24 atx38 bbox bit bitcmyk bitrgb bitrgbtags bj10e bj10v bj10vh
bj200 bjc600 bjc800 bjc880j bjccmyk bjccolor bjcgray bjcmono bmp16 bmp16m
bmp256 bmp32b bmpgray bmpmono bmpsep1 bmpsep8 ccr cdeskjet cdj1600 cdj500
cdj550 cdj670 cdj850 cdj880 cdj890 cdj970 cdjcolor cdjmono cdnj500 cfax
cgm24 cgm8 cgmmono chp2200 cif cljet5 cljet5c cljet5pr coslw2p coslwxl
cp50 declj250 deskjet devicen dfaxhigh dfaxlow dj505j djet500 djet500c
dl2100 dnj650c epl2050 epl2050p epl2120 epl2500 epl2750 epl5800 epl5900
epl6100 epl6200 eplcolor eplmono eps9high eps9mid epson epsonc epswrite
escp escpage faxg3 faxg32d faxg4 fmlbp fmpr fs600 gdi hl1240 hl1250 hl7x0
hpdj1120c hpdj310 hpdj320 hpdj340 hpdj400 hpdj500 hpdj500c hpdj510
hpdj520 hpdj540 hpdj550c hpdj560c hpdj600 hpdj660c hpdj670c hpdj680c
hpdj690c hpdj850c hpdj855c hpdj870c hpdj890c hpdjplus hpdjportable ibmpro
ijs imagen imdi inferno iwhi iwlo iwlq jetp3852 jj100 jpeg jpegcmyk
jpeggray la50 la70 la75 la75plus laserjet lbp310 lbp320 lbp8 lex2050
lex3200 lex5700 lex7000 lips2p lips3 lips4 lips4v lj250 lj3100sw lj4dith
lj4dithp lj5gray lj5mono ljet2p ljet3 ljet3d ljet4 ljet4d ljet4pjl
ljetplus ln03 lp1800 lp1900 lp2000 lp2200 lp2400 lp2500 lp2563 lp3000c
lp7500 lp7700 lp7900 lp8000 lp8000c lp8100 lp8200c lp8300c lp8300f
lp8400f lp8500c lp8600 lp8600f lp8700 lp8800c lp8900 lp9000b lp9000c
lp9100 lp9200b lp9200c lp9300 lp9400 lp9500c lp9600 lp9600s lp9800c
lps4500 lps6500 lq850 lx5000 lxm3200 lxm5700m m8510 mag16 mag256 md1xMono
md2k md50Eco md50Mono md5k mgr4 mgr8 mgrgray2 mgrgray4 mgrgray8 mgrmono
miff24 mj500c mj6000c mj700v2c mj8000c ml600 necp6 npdl nullpage oce9050
oki182 oki4w okiibm oprp opvp paintjet pam pbm pbmraw pcl3 pcx16 pcx24b
pcx256 pcx2up pcxcmyk pcxgray pcxmono pdfwrite pgm pgmraw pgnm pgnmraw
photoex picty180 pj pjetxl pjxl pjxl300 pkm pkmraw pksm pksmraw plan9bm
png16 png16m png256 png48 pngalpha pnggray pngmono pnm pnmraw ppm ppmraw
pr1000 pr1000_4 pr150 pr201 ps2write psdcmyk psdrgb psgray psmono psrgb
pswrite pxlcolor pxlmono r4081 rinkj rpdl samsunggdi sgirgb sj48 spotcmyk
st800 stcolor sunhmono t4693d2 t4693d4 t4693d8 tek4696 tiff12nc tiff24nc
tiff32nc tiff48nc tiff64nc tiffcrle tiffg3 tiffg32d tiffg4 tiffgray
tifflzw tiffpack tiffscaled tiffscaled24 tiffscaled8 tiffsep tiffsep1
uniprint wtscmyk wtsimdi xcf xes
Search path:
%rom%Resource/Init/ : %rom%lib/ :
/opt/gs/share/ghostscript/9.04/Resource/Init :
/opt/gs/share/ghostscript/9.04/lib :
/opt/gs/share/ghostscript/9.04/Resource/Font :
/opt/gs/share/ghostscript/fonts :
/opt/gs/share/fonts/default/ghostscript :
/opt/gs/share/fonts/default/Type1 :
/opt/gs/share/fonts/default/TrueType : /usr/lib/DPS/outline/base :
/usr/openwin/lib/X11/fonts/Type1 : /usr/openwin/lib/X11/fonts/TrueType
Initialization files are compiled into the executable.
For more information, see /opt/gs/share/ghostscript/9.04/doc/Use.htm.
Please report bugs to bugs.ghostscript.com.
在运行
gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4-r600x600 -sDEVICE=pbmraw -sOutputFile=test_1.pbm chess.ps
在 /opt/gs/share/ghostscript/9.04/examples 下有chess.ps -sOutputFile 也可以是pdf 亲测有用
ls 一下,出现test_1.pbm 表示正常!
gs 只是负责转换打印机能识别的格式,当然需要通过协议传输给它,接下来就来移植foo2zjs 吧
2、移植编译 foo2zjs
官网下载:http://foo2zjs.rkkda.com/
官网文档说明:http://foo2zjs.rkkda.com/manual.pdf
tar xf foo2zjs.tar.gz
首先编译pc 版本 直接make 一般不会报错,然后 arm2hpdl ../ (x86工具用于把打印机的固件转换成arm版的)
接着修改Makefile
在最开头增加
1 CC=arm-linux-gcc //这个才是增加的
2 LANG=C
3 UNAME := $(shell uname)
4 MACH := $(shell uname -m | sed 's/i.86/x86_32/')
保存退出
make
出现报错信息
command2foo2lava-pjl.c:35:30: fatal error: cups/sidechannel.h: No such file or directory
compilation terminated.
make: *** [command2foo2lava-pjl.o] Error 1
我研究了一下,vim command2foo2lava-pjl.c
#include
#include
#include
#include
#include
#include
#include
发现编译时需要cups的支持,接下来当然是要交叉编译cups啦,
官网下载地址:http://www.cups.org/software.php
我下载的是:cups-1.5.4-source.tar.gz
tar xf cups-1.5.4-source.tar.gz
cd cups-1.5.4
./configure --host=arm-linux --target=arm-linux --build=i686-linux CC=arm-linux-gcc CXX=arm-linux-g++ LD=arm-linux-ld RANLIB=arm-linux-ranlib AR=arm-linux-ar --disable-gnutls --disable-gssapi --disable-dbus --prefix=/
make
出错:
Compiling ppdmerge.cxx...
Linking ppdmerge...
Compiling ppdpo.cxx...
Linking ppdpo...
Compiling genstrings.cxx...
Linking genstrings...
Generating localization strings...
/bin/sh: ./genstrings: cannot execute binary file
make[1]: *** [genstrings] Error 126
make: *** [all] Error 1
解决
vim vim Makedefs
‘原来的:
140 BUILDDIRS = filter backend berkeley cgi-bin driver monitor notifier ppdc scheduler systemv conf data desktop locale man doc examples templates
改成:
140 BUILDDIRS = filter backend berkeley cgi-bin driver monitor notifier ppdc scheduler systemv conf data desktop locale doc examples templates
其实就是移除了对man 文档的支持
继续make 编译通过
最后
make install DSTROOT=${PWD}/_install
cd _install /
cp usr/include/cups opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/include ==>(交叉编译器所在的头文件)
cp usr/lib opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/lib/ ==>(交叉编译器所在的库文件)
回到 foo2zjs
make
编译通过:
执行 ./getweb 得到以下结果,下面列出了该软件支持的打印机固件。
hzl@hzl-virtual-machine:foo2zjs$ ./getweb
$Id: getweb.in,v 1.114 2015/02/12 00:22:02 rick Exp $
Usage:
./getweb something
Convenience script to get extra somethings from the web,
such as ICC color profiles, firmware, PPD files, etc.
$ ./getweb 1025 # Get HP LaserJet Pro CP1025nw .ICM files
$ ./getweb 1215 # Get HP Color LaserJet CP1215 .ICM files
$ ./getweb 1500 # Get HP Color LaserJet 1500 .ICM files
$ ./getweb 1600 # Get HP Color LaserJet 1600 .ICM files
$ ./getweb 2600n # Get HP Color LaserJet 2600n .ICM files
$ ./getweb 1600w # Get Konica Minolta 1600W .ICM files
$ ./getweb 1680 # Get Konica Minolta 1680MF .ICM files
$ ./getweb 1690 # Get Konica Minolta 1690MF .ICM files
$ ./getweb 2480 # Get Konica Minolta 2480 MF .ICM files
$ ./getweb 2490 # Get Konica Minolta 2490 MF .ICM files
$ ./getweb 2530 # Get Konica Minolta 2530 DL .ICM files
$ ./getweb 4690 # Get Konica Minolta 4690MF .ICM files
$ ./getweb 6115 # Get Xerox Phaser 6115MFP .ICM files
$ ./getweb 110 # Get Oki C110 .ICM files
$ ./getweb 6121 # Get Xerox Phaser 6121MFP .ICM files
$ ./getweb 2200 # Get Minolta 2200 DL .ICM files
$ ./getweb 2300 # Get Minolta 2300 DL .ICM files
$ ./getweb 2430 # Get Konica Minolta 2430 DL .ICM files
$ ./getweb cpwl # Get Minolta Color PageWorks/Pro L .ICM files
$ ./getweb 300 # Get Samsung CLP-300 .ICM files
$ ./getweb 310 # Get Samsung CLP-310 .ICM files
$ ./getweb 315 # Get Samsung CLP-315 .ICM files
$ ./getweb 325 # Get Samsung CLP-325 .ICM files
$ ./getweb 360 # Get Samsung CLP-360 .ICM files
$ ./getweb 365 # Get Samsung CLP-365 .ICM files
$ ./getweb 600 # Get Samsung CLP-600 .ICM files
$ ./getweb 610 # Get Samsung CLP-610 .ICM files
$ ./getweb 2160 # Get Samsung CLX-2160 .ICM files
$ ./getweb 3160 # Get Samsung CLX-3160 .ICM files
$ ./getweb 3175 # Get Samsung CLX-3175 .ICM files
$ ./getweb 3185 # Get Samsung CLX-3185 .ICM files
$ ./getweb 6110 # Get Xerox Phaser 6110 and 6110MFP .ICM files
$ ./getweb 500 # Get Lexmark C500 .ICM files
$ ./getweb 301 # Get Oki C301dn .ICM files
$ ./getweb c310 # Get Oki C310dn .ICM files
$ ./getweb c511 # Get Oki C511dn .ICM files
$ ./getweb c810 # Get Oki C810 .ICM files
$ ./getweb 3100 # Get Oki C3100 .ICM files
$ ./getweb 3200 # Get Oki C3200 .ICM files
$ ./getweb 3300 # Get Oki C3300 .ICM files
$ ./getweb 3400 # Get Oki C3400 .ICM files
$ ./getweb 3530 # Get Oki C3530 MFP .ICM files
$ ./getweb 5100 # Get Oki C5100 / C5150n .ICM files
$ ./getweb 5200 # Get Oki C5200 .ICM files
$ ./getweb 5500 # Get Oki C5500 .ICM files
$ ./getweb 5600 # Get Oki C5600 .ICM files
$ ./getweb 5800 # Get Oki C5800 .ICM files
$ ./getweb 160 # Get Olivetti d-Color P160W .ICM files
$ ./getweb 1000 # Get HP LJ 1000 firmware file
$ ./getweb 1005 # Get HP LJ 1005 firmware file
$ ./getweb 1018 # Get HP LJ 1005 firmware file
$ ./getweb 1020 # Get HP LJ 1020 firmware file
$ ./getweb p1005 # Get HP LJ P1005 firmware file
$ ./getweb p1006 # Get HP LJ P1006 firmware file
$ ./getweb p1007 # Get HP LJ P1007 firmware file
$ ./getweb p1008 # Get HP LJ P1008 firmware file
$ ./getweb p1505 # Get HP LJ P1505 firmware file
$ ./getweb all # Get everything above
$ ./getweb 2300dl_fw # Get Minolta 2300DL v2.55 firmware (experts only)
$ ./getweb update # Get latest version of this software.
欣慰的看到有 ($ ./getweb 1020# Get HP LJ 1020 firmware file ) 1020 的固件
配置ubuntu上网
./getweb 1020
hzl@hzl-virtual-machine:foo2zjsbak$ ls img
sihp1020.img
这就是1020 的打印机固件,这是我们需要转换成arm版本能用的固件,把刚才编译x86 版本的arm2hpdl
./arm2hpdl sihp1020.img > sihp1020.dl
cp sihp1020.dl 到开发板中的目录中去
cp foo2zjs 到开发板中的bin ==>传输给打印机的命令 还有其他信号的打印机命令,可以去官网查看手册,看看自己的打印机合适什么命令,就拷贝什么命令到开发板中!
运行 ,打印如下,说明正常!
foo2zjs -h
Usage:
foo2zjs [options]
Convert Ghostscript pbmraw format to a monochrome ZJS stream,
for driving the Minolta/QMS 2300 DL network color laser printer
and other Zenographics-based black and white printers.
gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE \
-sPAPERSIZE=letter -r1200x600 -sDEVICE=pbmraw \
-sOutputFile=- - < testpage.ps \
| foo2zjs -r1200x600 -g10200x6600 -p1 >testpage.zm
foo2zjs [options]
foo2zjs [options]
Convert Ghostscript bitcmyk or pksmraw format to a color ZJS stream,
for driving the Minolta/QMS 2300 DL network color laser printer
N.B. Color correction is expected to be performed by ghostscript.
gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE \
-sPAPERSIZE=letter -g10200x6600 -r1200x600 -sDEVICE=bitcmyk \
-sOutputFile=- - < testpage.ps \
| foo2zjs -r1200x600 -g10200x6600 -p1 >testpage.zc
Normal Options:
-c Force color mode if autodetect doesn't work
-d duplex Duplex code to send to printer [1]
1=off, 2=longedge, 3=shortedge
4=manual longedge, 5=manual shortedge
-g
-m media Media code to send to printer [1]
-z0:
1=standard, 2=transparency, 3=glossy, 257=envelope,
259=letterhead, 261=thickstock, 262=postcard, 263=labels
-z1,-z2: above plus
258=light, 261=cardstock, 263=rough, 265=labels,
267=envelope, 273=vellum, 512=color, 513=letterhead,
514=preprinted, 515=prepunched, 516=recycled
-p paper Paper code to send to printer [1]
-z0:
1=letter, 5=legal, 7=executive, 9=A4, 11=A5, 13=B5jis
20=env#10, 27=envDL 28=envC5 34=envB5 37=envMonarch
-z1: -z0 plus
257=16K 197x273, 258=fanfold german legal, 259=b5iso,
260=postcard, 261=doublepostcard, 262=A6
-z2: -z0 plus
43=postcard, 70=A6, 82=double postcard rotated,
257=16K 197x273, 263=16K 184x260, 264=16K 195x270,
258=fanfold german legal
-z3: -z0 plus
43=postcard, 70=A6, 82=double postcard rotated,
257=16K 197x273, 263=16K 184x260, 264=16K 195x270,
258=fanfold german legal, 268=photo4x6, 269=photo5x8,
270=photo10x15
-n copies Number of copies [1]
-r
-s source Source code to send to printer [7]
1=upper 2=lower 4=manual 7=auto
Code numbers may vary with printer model
-t Draft mode. Every other pixel is white.
-T density Print density (1-5) [3].
-J filename Filename string to send to printer []
-U username Username string to send to printer []
Printer Tweaking Options:
-u
-l
-L mask Send logical clipping values from -u/-l in ZjStream [3]
0=no, 1=Y, 2=X, 3=XY
-A AllIsBlack: convert C=1,M=1,Y=1 to just K=1
-B BlackClears: K=1 forces C,M,Y to 0
-A, -B work with bitcmyk input only
-P Do not output START_PLANE codes. May be needed by some
some black and white only printers.
-X padlen Add extra zero padding to the end of BID segments [16]
-z model Model: [0]
0=KM 2300DL / HP 1000 / HP 1005
1=HP 1018 / HP 1020 / HP 1022
2=HP Pro P1102 / P1566 / P1606dn
3=HP Pro CP102?nw
Debugging Options:
-S plane Output just a single color plane from a color print [all]
1=Cyan, 2=Magenta, 3=Yellow, 4=Black
-D lvl Set Debug level [0]
-V Version $Id: foo2zjs.c,v 1.109 2011/11/12 16:39:53 rick Exp $
cp usb_printerid 到开发板中的bin 查看 打印机的信息
在开发板中
catsihp1020.dl > /dev/usb/lp0
此时打印机1020 有响声,两指示灯同时闪烁,说明估计加载成功,现在离成功更近一不了哦。
可以查看打印机的信息:
usb_printerid /dev/lp0
GET_DEVICE_ID string:
MFG:Hewlett-Packard;MDL:HP LaserJet 1020;CMD:ACL;CLS:PRINTER;DES:HP LaserJet 1020;
下面就见证奇迹是的时刻吧!找到之前通过gs 转换成的test_1.pbm
在开发板中执行
foo2zjs -z1 -p9 -r600x600 test_1.pbm > /dev/usb/lp0
成功打印 终于大功告成!1020(hp激光打印机)可以告一段落!
但是说好的喷墨打印机1010 呢,看到 ./getweb 并没支持啊,通过各方面的搜索资料,还要移植一个hpijs。接下来继续搬砖,看到这里打印相比别的驱动是复杂的多了。
3、编译移植hpijs
官网下载地址:http://sourceforge.net/projects/hpinkjet/files/hpijs/
我下载的是:hpijs-2.1.4.tar.gz
tar xf hpijs-2.1.4.tar.gz
cd hpijs-2.1.4
./configure --host=arm-linux --target=arm-linux --build=i686-linux CC=arm-linux-gcc CXX=arm-linux-g++ LD=arm-linux-ld RANLIB=arm-linux-ranlib AR=arm-linux-ar
make
出错:
DHAVE_SYSLOG_H=1 -DHAVE_UNISTD_H=1 -DHAVE_JPEGLIB_H=1 -DVERSION=\"2.1.4\" -DHAVE_STRTOD=1 -DHAVE_STRTOL=1 -DHAVE_LIBM=1 -I. -I. -g -O2 -DAPDK_LITTLE_ENDIAN -DAPDK_DJ660 -DAPDK_DJ6xx -DAPDK_DJ6xxPhoto -DAPDK_DJ8xx -DAPDK_DJ9xx -DAPDK_DJ9xxVIP -DAPDK_DJ630 -DAPDK_APOLLO2XXX -DAPDK_APOLLO21XX -DAPDK_APOLLO2560 -DAPDK_DJ600 -DAPDK_DJ350 -DAPDK_DJ8x5 -DAPDK_PSP100 -DAPDK_AUTODUPLEX -DAPDK_HIGH_RES_MODES -DAPDK_LJMONO -DAPDK_DJ540 -DAPDK_DJ850 -DAPDK_DJ890 -DAPDK_DJ3320 -DAPDK_LJCOLOR -DAPDK_DJGENERICVIP -DAPDK_LJJETREADY -DAPDK_LJFASTRASTER -DAPDK_BUFFER_SEND -DAPDK_LDL_COMPRESS -DAPDK_EXTENDED_MEDIASIZE -DAPDK_MLC_PRINTER -DAPDK_DJ3600 -DAPDK_LINUX -DAPDK_AUTO_INCLUDE -MT registry.o -MD -MP -MF ".deps/registry.Tpo" -c -o registry.o registry.cpp; \
then mv -f ".deps/registry.Tpo" ".deps/registry.Po"; else rm -f ".deps/registry.Tpo"; exit 1; fi
registry.cpp: In member function 'virtual apdk::DRIVER_ERROR apdk::DeviceRegistry::SelectDevice(char*, int*, char*, apdk::SystemServices*)':
registry.cpp:249:62: error: invalid conversion from 'const char*' to 'char*'
registry.cpp:252:65: error: invalid conversion from 'const char*' to 'char*'
make: *** [registry.o] Error 1
hzl@hzl-virtual-machine:hpijs-2.1.4$
执行:
修正语法错误 dj3320.cpp第403行和registry.cpp第249行 开头的char改为const char
sed -i '249s/\tchar\t/\tconst char\t/' registry.cpp
sed -i '403s/ char/ const char/' dj3320.cpp
继续make 编译通过
make install DESTDIR=${PWD}/_install
cp _install/usr / ===>到开发板的目录。
cp _install/usr/local/bin/hpijs /bin ====>开发板的bin目录
在开发板中执行:
hpijs -h
Hewlett-Packard Co. Inkjet Server 2.1.4
Copyright (c) 2001-2004, Hewlett-Packard Co.
说明成功的移植
连接1010 usb 到板子
接下一条,命令搞定1010
gs -sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD-sDeviceManufacturer="HEWLETT-PACKARD" -sDeviceModel="deskjet5550" -r300x300 -dNOPAUSE -dSAFER -sOutputFile="/dev/usb/lp0" chess.ps -c quit
结果出错:
Copyright (C) 2011 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC fordetails.
GPL Ghostscript 9.04: **** Could not open temporary file/data/misc/printer/tmp/gs_NlyvTT
GPL Ghostscript 9.04: Could not open the scratch file /data/misc/printer/tmp/gs_NlyvTT.
**** Unable to open the initial device, quitting.
解决:
mkdir data/misc/printer/tmp/gs_NlyvTT -p ===>> 我也是碰巧这样的觉得的 是什么原因日后有空再研究吧!
继续
gs -sDEVICE=ijs -sIjsServer=hpijs -dIjsUseOutputFD-sDeviceManufacturer="HEWLETT-PACKARD" -sDeviceModel="deskjet5550" -r300x300 -dNOPAUSE -dSAFER -sOutputFile="/dev/usb/lp0" chess.ps -c quit
成功打印
看到这条命令又臭又长,可以查看hpijs 的官方手册 hpijs_readme.html 里面都有详细的介绍。
在doc里面有文档
ls usr/local/share/doc/hpijs-2.1.4/
COPYING gs_hpijs.png hpijs_readme.html
我这里只提一下重点的参数! ,-sDeviceModel="deskjet5550“ 这个是对应的打印机驱动,为什么选择这个 deskjet5550“ 因为hp deskjet 1010 最近几年才出来 这个包里根本没有1010 的ppd文件,关于ppd文件hpijs 里面有对应的deskjet5550ppd 请看
在开发板中:
ls /usr/share/cups/model/foomatic-ppds/HP/HP-DeskJet_5
550-hpijs.ppd.gz
当然这里面有很多型号的打印机,大家可以自己研究就一下,关于什么是ppd文件,官方有一句话带过:
"For every PostScript printer the manufacturers provide a PPD file which contains all printer-specific information about the particular printer model: Basic printer capabilities as whether the printer is a color printer, fonts, PostScript level, etc., and especially the user-adjustable options, as paper size, resolution, etc."
我也是参考一个大神的博文的才明白的,估计是 deskjet5550 和deskjet1010 一样的协议吧, -sOutputFile="/dev/usb/lp0" 只要把打印的内容输出到 设备文件中,也可以指定文件 xx cat xx > /dev/usb/lp0 效果也是一样的!
到这里算是完成了1010 和1020 的打印机驱动了
四、补充说明
文章最开始提到:关于 QZD4418 在运行gs 的时候无效 这里说明一下,
我开始以为是文件系统的原因,后来我也自己做了一个文件系统效果还是一样,我开始怀疑交叉编译的的问题于是我对比了一下tiny4412 的交叉编译器
file 了一下 发现 QZD4418 的交叉编译器是64 位环境的
file /usr/local/arm/arm-cortex_a9-eabi-4.7-eglibc-2.18/bin/arm-cortex_a9-linux-gnueabi-gcc
/usr/local/arm/arm-cortex_a9-eabi-4.7-eglibc-2.18/bin/arm-cortex_a9-linux-gnueabi-gcc: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0xfb9e354ff588a908734d7fcb266f7c8d3a2bb8e0, stripped
-v
root@gzsd-virtual-machine:/home/work/print/hpijs-2.1.4/_install# arm-cortex_a9-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-cortex_a9-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/local/arm/arm-cortex_a9-eabi-4.7-eglibc-2.18/bin/../libexec/gcc/arm-cortex_a9-linux-gnueabi/4.7.4/lto-wrapper
Target: arm-cortex_a9-linux-gnueabi
Configured with: /home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/src/gcc-linaro-4.7-2013.11/configure --build=x86_64-build_unknown-linux-gnu --host=x86_64-build_unknown-linux-gnu --target=arm-cortex_a9-linux-gnueabi --prefix=/opt/crosstools/arm-cortex_a9-eabi-4.7-eglibc-2.18 --with-sysroot=/opt/crosstools/arm-cortex_a9-eabi-4.7-eglibc-2.18/arm-cortex_a9-linux-gnueabi/sysroot --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=softfp --with-pkgversion='crosstool-NG linaro-1.13.1-4.8-2013.11 - nexell' --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-mpfr=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-mpc=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-ppl=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-cloog=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-libelf=/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm -L/home/pjsin/devel/tools/crosstools/ct/linaro-1.13.1-4.8-2013.11/.build/arm-cortex_a9-linux-gnueabi/build/static/lib -lpwl' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gold --with-local-prefix=/opt/crosstools/arm-cortex_a9-eabi-4.7-eglibc-2.18/arm-cortex_a9-linux-gnueabi/sysroot --enable-c99 --enable-long-long --with-specs='%{save-temps: -fverbose-asm} %{funwind-tables|fno-unwind-tables|mabi=*|ffreestanding|nostdlib:;:-funwind-tables}' --enable-poison-system-directories
Thread model: posix
gcc version 4.7.4 20131111 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2013.11 - nexell)
版本为 version 4.7.4 20131111
tiny4412 的交叉编译器
32 位环境
hzl@hzl-virtual-machine:hpijs$ file /home/tiny4412/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/bin/ar
/home/tiny4412/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/bin/ar: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, BuildID[sha1]=3170e0b2655986c33011182af53d4aba06b1c9ac, stripped
hzl@hzl-virtual-machine:hpijs$ arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/home/tiny4412/opt/FriendlyARM/toolschain/4.5.1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.1/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /work/toolchain/build/src/gcc-4.5.1/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.5.1 --with-sysroot=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --enable-languages=c,c++ --disable-multilib --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=softfp --with-pkgversion=ctng-1.8.1-FA --with-bugurl=http://www.arm9.net/ --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-gmp=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpfr=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-ppl=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-cloog=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpc=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-libelf=/work/toolchain/build/arm-none-linux-gnueabi/build/static --enable-threads=posix --with-local-prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.5.1 (ctng-1.8.1-FA)
对比两者版本有区别,个人觉得版本应该问题不大,毕竟都是armv7指令集,是什么问题我也不得而知。反正如果换成tiny4412 的交叉编译器编译gs 放在 QZD4418 是没有任何问题的!
关于cups:
还有一款hp的激光打印机1108 是新出的用上面的方法也不成功。我想到现在ubuntu上面安装了hplip-3.15.11.tar.gz 几乎所有的惠普打印机和一体机
安装步骤参照官网即可:http://hplipopensource.com/hplip-web/install/manual/distros/ubuntu.html
关于hplip 百度:
按照这个链接: http://blog.chinaunix.net/uid-23381466-id-4465324.html 也可以实现命令行打印,
想想是不是可以移植cups 让p1108 支持嵌入式打印呢
参考: http://blog.sina.com.cn/s/blog_9da24f3b0101otng.html
结果不行,在板子可以正常运行,待解决,希望碰到的小伙伴一起讨论一下, 我发现的问题是 HP-LaserJet-Professional-P1108.ppd文件 需要 hpcups 命令的支持 该问题至今没有解决!
五、结尾
上文是我搞打印机驱动的一点心得,希望可以帮助大家少走弯路,有什么问题也欢迎 讨论和指教网易邮箱: [email protected]
参考文献:
http://blog.csdn.net/kangear/article/details/18141741
http://blog.csdn.net/kangear/article/details/39002105
http://blog.csdn.net/smartdog_1/article/details/37760313