arm linux printer driver compilation method, embedded Linux driver printer HP series

Keywords: Makefile Linux ftp ssh

arm linux printer driver compilation method and process record (2017.03.15):

Change Add Overview:

  • Add foo2zjs tool (for sending data to printer for printing);
  • Add gohstscript tool (for converting document format to pbm format recognized by printer);
  • Encript is added to convert txt, c, cpp and other documents into PostScript format recognized by printers.

1. Add cross-compiled foo2zjs method:

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,stay Makefile Add cross-compiler toolchain CC:
CC=arm-none-linuxxxxxxx

6. make (use the embedded toolchain complie again)

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

Printing on arm, using foo2zjs printing method:
2.

  1. #### Then send the printed pbm file to the HP1020 printer: / dev/usb/lp0 to print!

2. Add cross-compiling ghostscript method:

  • Download source package: ghostcript-9.04
    http://iweb.dl.sourceforge.net/project/ghostscript/GPL%20Ghostscript/9.04/ghostscript-9.04.tar.bz2

  • Decompression:

    tar xvf ghostscript-9.04.tar.bz2
  • Unzipped folder, duplicate one more copy, rename to distinguish x86 and arm versions, we need to compile two versions;

    cp ghostscript-9.04  ghostscript-9.04-arm -rf &&  mv ghostscript-9.04 ghostscript-9.04-pc
  • Compile x86 version and enter:

    cd ghostscript-9.04-pc/
  • Start compiling the X86 version of ghostscript-9.04-pc:

    ./configure
    
    make
  • Save part of the x86 version of the compiler's generated file (later to be copied to the arm version of the folder):

    cp obj/aux/genarch  genarch_arm
    cp obj/aux/genconf  genconf_arm
    cp obj/aux/echogs   echogs_arm
    cp obj/aux/mkromfs  mkromfs_arm
  • Start compiling arm version (example is phascan, corresponding to our tool link arm-angstrom):
    Firstly, configure the environment variables and make sure that arm-angstrom-linux-gnueabi-xxx can be found.

  • Enter the ghostscripte directory of arm version:

    cd ../ghostscript-9.04-arm/
  • Modify "STDLIBS=@PTHREAD_LIBS@-lm" to "STDLIBS=@PTHREAD_LIBS@-static-lm" in Makefile.in

    sed -i '387s/STDLIBS=@PTHREAD_LIBS@ -lm/STDLIBS=@PTHREAD_LIBS@ -static -lm/' ./Makefile.in
  • Revision/tmp directory:

    sed -i '74s/"\/tmp\/"/"\/data\/misc\/printer\/tmp\/"/'  ./base/gp_unifs.c 
  • Run the configuration script. configure to generate the Makefile file file:

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

    The prefix parameter determines the gs search path of arm version, which must be consistent with the compilation time on the target board, because the compiled application will find the configuration and dependent files from the prefix specified path.

  • Copy the files compiled before X86 to the arm directory:

    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
  • Makefile from the modified configure asks that if you remove devs about X11, you will compile without removing them.

    gedit Makefile

    In about 509 lines, add the well number to comment out:

    #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 
    
  • Start cross-compiling:

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

    Normally, it can compile and generate. / bin/gs files.

  • Execution: make install

    After that, the file is installed to: / home/lin/ghostscript-9.04-arm/build

  • Copy cross-compiled programs to and from cross-compiled share directory to bin directory in target:

    scp -rv build/share/  root@192.168.1.233:/usr/share/
  • Copy the cross-compiled programs to the bin directory in target:

    scp build/bin/*  root@192.168.1.233:/usr/bin/
  • Execute gs in target and generate pbm files for printing (I generated chess.ps in example):

        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
  • Prepare to print, send firmware to printer in target terminal:

        cat sihp1020.dl > /dev/usb/lp0
  • The method of printing a file is executed in target (A4 paper, print content is test_1.pbm):

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

3. Add cross-compiled enscript method:

  • Download gnu from enscript source Or click here to download:
    ftp://ftp.gnu.org/gnu/enscript/enscript-1.6.6.tar.gz

  • Decompress enscript-1.6.6.tar.gz:

    tar xvf enscript-1.6.6.tar.gz
  • Run the configure script to configure enscript-1.6.6.tar.gz:

    ./configure --with-media=Letter --prefix=/home/lin/enscript-1.6.6/build/
  • Modify the generated Makefile to replace the C in the text with arm-angstrom-linux-gnueabi-gcc

  • Start cross-compiling:

    make CC=arm-angstrom-linux-gnueabi-gcc
  • Install the prefix directory in configure, and then copy the prefix directory to the corresponding location of the target board on the target board.

    make install
  • Login to the target development board with ssh link (IP:192.168.1.233 here), and then copy the directory just install ed to the target board:

    "`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/
    ""

  • Encripte uses examples to convert documents to ps through enscript, then ps to pbm through ghostscript, and finally sends pbm to printer node through foo2zjs tool for printing:

```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
```

At this point, the print is successful, you can see the txt document is printed out;

Posted by varun8211 on Mon, 22 Apr 2019 02:15:35 -0700