您的位置:首页 > 运维架构 > Linux

arm linux打印机驱动编译方法,嵌入式linux驱动打印机HP系列

2017-03-17 09:53 1876 查看

arm linux打印机驱动编译方法和过程记录(2017.03.15):

改动添加概述:

添加foo2zjs工具(用于发送数据到打印机进行打印);

添加gohstscript工具(用于转换文档格式到打印机能识别的pbm格式);

添加enscript,用于把txt,c,cpp等文档转换到打印机能识别的PostScript格式;

1. 添加交叉编译foo2zjs方法:

1. wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz 
2. make

3. save a copy of arm2hpdl

4.  make clean

5. modify Makefile,在Makefile添加交叉编译工具链CC:
CC=arm-none-linuxxxxxxx

6. make (use the embedded toolchain complie again)

8. ./arm2hpdl sihp1020.img > sihp1020.dl


在arm上打印,利用foo2zjs打印方法:

2. #### foo2zjs使用方法,在嵌入式端,需要: cat sihp1020.dl > /dev/usb/lp0,把固件发送到HP 1020打印机

#### 接着发送打印的pbm文件到 HP1020打印机即可: /dev/usb/lp0即可打印!

2. 添加交叉编译ghostscript方法:

下载源码包: ghostcript-9.04

http://iweb.dl.sourceforge.net/project/ghostscript/GPL%20Ghostscript/9.04/ghostscript-9.04.tar.bz2

解压:

tar xvf ghostscript-9.04.tar.bz2


解压出来的文件夹,复制多一份,重命名区分x86和arm版本,我们需要编译两种版本;

cp ghostscript-9.04  ghostscript-9.04-arm -rf &&  mv ghostscript-9.04 ghostscript-9.04-pc


编译x86版本,进入:

cd ghostscript-9.04-pc/


开始编译X86版本的ghostscript-9.04-pc:

./configure

make


保存编译处理的x86版本的部分生成文件(后面要复制到arm版的文件夹里面的):

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版本(例子是phascan,对应的是我们的工具链接arm-angstrom):

首先配置好环境变量,确定能找到arm-angstrom-linux-gnueabi-xxx

进入arm版本的ghostscripte目录中:

cd ../ghostscript-9.04-arm/


修改Makefile.in中 “STDLIBS=@PTHREAD_LIBS@ -lm” 为 “STDLIBS=@PTHREAD_LIBS@ -static -lm”

sed -i '387s/STDLIBS=@PTHREAD_LIBS@ -lm/STDLIBS=@PTHREAD_LIBS@ -static -lm/' ./Makefile.in


修定/tmp目录:

sed -i '74s/"\/tmp\/"/"\/data\/misc\/printer\/tmp\/"/'  ./base/gp_unifs.c


运行配置脚本.configure,生成Makefile文件:

./configure --host=arm-linux --target=arm-linux --disable-fontconfig --disable-gtk --disable-cups --prefix=/home/lin/ghostscript-9.04-arm/build/


prefix 参数决定了arm版本的gs搜索路径,在目标板上必须和编译的时候一致,因为编译好的应用程序会从prefix指定路径查找配置和依赖的文件;

拷贝之前在X86编译通过的文件到arm目录:

cp ../ghostscript-9.04-pc/echogs_arm  obj/aux/echogs
cp ../ghostscript-9.04-pc/genarch_arm  obj/aux/genarch
cp ../ghostscript-9.04-pc/genconf_arm  obj/aux/genconf
cp ../ghostscript-9.04-pc/mkromfs_arm  obj/aux/mkromfs


修改configure出来的Makefile问及,去掉有关X11的devs,不去掉就会编译不过:

gedit Makefile


在大约509行,添加井号注释掉:

#DEVICE_DEVS=$(DISPLAY_DEV) $(DD)x11.dev $(DD)x11_.dev $(DD)x11alpha.dev $(DD)x11alt_.dev $(DD)x11cmyk.dev $(DD)x11cmyk2.dev $(DD)x11cmyk4.dev $(DD)x11cmyk8.dev $(DD)x11gray2.dev $(DD)x11gray4.dev     $(DD)x11mono.dev $(DD)x11rg16x.dev $(DD)x11rg32x.dev


开始交叉编译:

make XCFLAGS=-DHAVE_SYS_TIME_H=1 CC=arm-angstrom-linux-gnueabi-gcc


正常情况下,可以编译通过,生成./bin/gs文件;

执行:make install

之后,文件被安装到: /home/lin/ghostscript-9.04-arm/build

复制交叉编译好的各种程序到以及交叉编译后的share目录到target中的bin目录中:

scp -rv build/share/  root@192.168.1.233:/usr/share/


复制交叉编译好的各种程序到target中的bin目录中:

scp build/bin/*  root@192.168.1.233:/usr/bin/


在target中执行gs,生成pbm文件用于打印(我生成的是example中的chess.ps):

gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4 -r600x600 -sDEVICE=pbmraw -sOutputFile=test_1.pbm /home/lin/ghostscript-9.04-arm/build/share/g
hostscript/9.04/examples/chess.ps


准备打印,在target终端中发送固件到打印机:

cat sihp1020.dl > /dev/usb/lp0


打印文件的方法,在target中执行(A4纸张,打印内容是test_1.pbm):

foo2zjs -z1 -p9 -r600x600 test_1.pbm > /dev/usb/lp0


3. 添加交叉编译enscript方法:

下载gnu从enscript源码或者点击这里下载

ftp://ftp.gnu.org/gnu/enscript/enscript-1.6.6.tar.gz

解压缩enscript-1.6.6.tar.gz:

tar xvf enscript-1.6.6.tar.gz


运行configure脚本,配置enscript-1.6.6.tar.gz:

./configure --with-media=Letter --prefix=/home/lin/enscript-1.6.6/build/


修改生成的Makefile,把文中的CC替换成arm-angstrom-linux-gnueabi-gcc

开始交叉编译:

make CC=arm-angstrom-linux-gnueabi-gcc


安装到configure中prefix指定的目录,之后在target板上,需要把prefix目录也拷贝到target板子对应的位置;

make install


用ssh链接登陆目标开发板(我这里IP:192.168.1.233),然后,刚刚install的目录拷贝到target板子上:

“`sh

scp -r build/share/ root@192.168.1.233:/home/lin/enscript-1.6.6/build/

scp -r build/etc/ root@192.168.1.233:/home/lin/enscript-1.6.6/build/etc/

““

enscripte使用示例,先通过enscript转换文档为ps,然后用ghostscript转ps为pbm,最后把pbm通过foo2zjs工具发送到打印机节点实现打印:





```sh
enscript -p test_enscript3.ps test_enscript3.txt

gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4 -r600x600 -sDEVICE=pbmraw -sOutputFile=test_enscript.pbm /home/test_enscript3.


test_enscript3.ps test_enscript3.txt

cat test_enscript.pbm  > /dev/usb/lp0
```


到此,打印成功,可以看到txt文档被打印出来;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: