# Laserjet 1000 hp1000fw udev problem [solved]

## trakon88

hi there,

for those having the same problem as me and have followed this guide : https://forums.gentoo.org/viewtopic-t-276876-highlight-hp1000fw.html

you have to change the hp1000fw script to this (maybe not perfect, but works for me):

#---------------start-------------------------------------

#! /bin/sh

firmware=/etc/hotplug/usb/sihp1000.dl

detector=/usr/local/bin/usb_id_test

(                                               # this is new

while [ ! -e /dev/usb/lp0 ]; do # while node not exist

    true                                     #waiting for the node

done                                       # found node

if [ -e $detector ]; then

 if [ -e $firmware ]; then

  candidate_list=`find /dev/usb -name lp*` # this differs from original but not important to change

  for candidate in $candidate_list; do

   printer_status=`$detector $candidate | grep 'hp LaserJet 1000'`

   if [ "$printer_status" != "" ]; then

    # I have found a hp LaserJet 1000  :Smile: 

    firmware_status=`$detector $candidate | grep 'FWVER'`

    if [ "$firmware_status" = "" ]; then

     result=`cat $firmware > $candidate`

    fi

   fi

  done

 fi

fi

) &            # this '&' is important because the script is done in background so udev will create the device node and script can find it

#------------------------end------------------------

because the /dev/usb/lp0 node exists after the script is run ... if you run it in the background - it'll work

you can also watch here:

https://forums.gentoo.org/viewtopic-t-339033-highlight-udev+hotplug.html

thanx a lot for gentoo ... and hope this helps ...

aleX

----------

## genstef

I wonder why the patch I apply from 

/usr/portage/net-print/foo2zjs/files/hp-printer-udev.patch

is not enough for your case?

----------

## trakon88

Hi,

the truth is I didn't try ... I think your's is OK, but my solution works for me so why should I change ...

greetings

aleX

----------

## Lawless

I reinstalled my system this weekend and I gave your ebuild a try

```

[2005/07/04 21:41:47] info kern usb 1-1.1: new full speed USB device using uhci_hcd and address 4

[2005/07/04 21:41:47] info kern drivers/usb/class/usblp.c: usblp0: USB Bidirectional printer dev 4 if 0 alt 0 proto 2 vid 0x03F0 pid 0x0517

[2005/07/04 21:41:48] notice user /etc/hotplug/usb/hplj1000: Udev detected, waiting for udev to create device nodes

[2005/07/04 21:42:08] notice user /etc/hotplug/usb/hplj1000: Udev failed to initialise device /dev/usb/lp0

```

/dev/usb/lp0 exists...

udev-0.58

----------

## genstef

Strange .. I think I will need to fix it then, any idea why it fails? Does increasing the timeout help?

----------

## Lawless

A while ago when I switched to udev I tried several things to wait for lp0 being create (loops, daemon-like scripts waiting for the printer) but nothing was a real solution - so I stopped using a hotplug script in favor of an udev script.

Now that your method doesn't work for me either I'm using an udev script again

```

/etc/dev.d/default/hp.dev

#!/bin/bash                     

                                

if [ ACTION="add" ] && [ DEVNAME="/dev/usb/lp0" ]; then

firmware=/etc/dev.d/default/sihp1000.img

detector=/usr/local/bin/usb_id_test

if [ -d /dev/usb/ ]; then       

if [ -e $detector ]; then       

 if [ -e $firmware ]; then      

  candidate_list=`find /dev/usb -name lp*`" "`find /dev -name usblp*`

  for candidate in $candidate_list; do

  printer_status=`$detector $candidate | grep 'hp LaserJet 1000'`

  if [ "$printer_status" != "" ]; then

  # I have found a hp LaserJet 1000 :-)

  firmware_status=`$detector $candidate | grep 'FWVER'`

  if [ "$firmware_status" = "" ]; then

  result=`cat $firmware > $candidate`

  fi

  fi

  done

  fi

  fi

fi

fi

```

The udev scripts are garanteed to start _after_ creating the /dev device - so there is no problem of waiting for lp0.

I will improve the script because it still tests all usb printers till it founds an hplj1000.

With udev you can create a symlink to something like /dev/hplaser so you can change the script to

```

#!/bin/bash                     

                                

if [ ACTION="add" ] && [ DEVNAME="/dev/hplaser" ]; then

firmware=/etc/dev.d/default/sihp1000.img

cat $firmware > $candidate

fi

```

Now I need the correct udev rule to create /dev/hplaser - perhaps this afternoon when I'm at home.

The printer sends some unique data to udev so you can create a special device for everey printer (which is then parsed by the script).

----------

## Lawless

Yes it works

/etc/udev/rules.d/10-udev.rules

```

BUS="usb",  SYSFS{product}="hp LaserJet 1000", NAME="hplaser"

```

/etc/dev.d/default/hp.dev

```

if [ $ACTION="add" ] && [ $DEVNAME="/dev/hplaser" ]; then

  firmware=/etc/dev.d/default/sihp1000.img

  cat $firmware > /dev/hplaser

fi

```

No hotplug at all - no problems so far...

----------

## cancech

I reinstalled gentoo this past weekend and I've been unable to get my printer, a HP Laserjet 1000, to work.

The problem is that the firmware isn't being loaded when it's pluged/detected. The node /dev/usb/lp0 is created and if I manually upload the firmware 

```
cat sihp1000.img > /dev/usb/lp0
```

then I can use the printer no problem. But I haven't been able to figure out to get it so that the firmware is uploaded automagically...

I tried the above mention script 

```

/etc/dev.d/default/hp.dev

#!/bin/bash                     

                               

if [ ACTION="add" ] && [ DEVNAME="/dev/hplaser" ]; then

firmware=/etc/dev.d/default/sihp1000.img

cat $firmware > $candidate

fi

```

in conjunction with the udev rule

```

/etc/udev/rules.d/10-udev.rules

BUS="usb",  SYSFS{product}="hp LaserJet 1000", NAME="hplaser" 

```

The node /dev/hplaser was created, but the firmware wasn't uploaded. I also tried a script which is located with the gentoo wiki page about the HP 1000 here

```

/etc/dev.d/default/hotplug.dev

#!/bin/sh

if [ "$DEVNAME" != "/dev/usb/lp0" ]; then exit; fi

cat /lib/firmware/sihp1000.dl > /dev/usb/lp0

```

Am I missing some crutial piece of information here? Thanks

----------

## Lawless

It depends on what udev version you are using... I switched to stable x86 because of the dozens of new udev versions within a few weeks where every release had a new bug. 

I'm currently using udev 0.58 and my current rule looks like this

```

/etc/udev/rules.d/10-udev.rules

BUS="usb", SYSFS{product}="hp LaserJet 1000", NAME="hplaser", SYMLINK="usb/lp0"

```

and the according script

```

#!/bin/bash

if [ $ACTION="add" ] && [ $DEVNAME="/dev/hplaser" ]; then

firmware=/etc/dev.d/hplaser/sihp1000.img

cat $firmware > /dev/hplaser

```

did just move to /etc/dev.d/hplaser/hp.dev together with the image file.

I had problems with other udev versions but I don't know how it is with the newest.

When I plug in the printer it starts and stops then waits a second and starts again - if this happens I know the firmware is loaded. 

I'm using this new rule now since my last post above having no more problems with the printer but I don't want to know what will come with a new udev version :(

----------

## cancech

Don't know what version of udev I've got.... it's whatever gentoo installed for me. 

I'll check to be sure after work.

----------

## cancech

I'm using udev version 058  :Confused: 

----------

## cancech

heh

I found my problem...... I forgot to make the script executable

```
chmod 755 /etc/dev.d/hp/hp.dev
```

 :Laughing: 

----------

## genstef

I made a proper implementation for the hotplug script, based on udev-RUN-rules:

http://article.gmane.org/gmane.linux.hotplug.devel/8429

Feel free to try it out.

----------

## Lawless

And what's in your hplj-udev? (it's a binary?!)

How do you know which lp* to use for the cat (this is why I use the /dev/hplaser simlink)

btw the other udev scripts are all stored in /etc/udev/scripts

----------

## genstef

Sorry, that was gmail attaching it wrongly  :Sad: 

So here is the scirpt:

http://dev.gentoo.org/~genstef/files/hplj-udev

And it's imo the best one ever because it finally knows the device node  :Smile: 

----------

## Lawless

Ah... you're getting the device via that env var DEVNAME - ok with that a simlink would be superfluous (didn't know that udev sets that var) but with this method you could also get rid of the usb_printerid binary. You are testing the printer twice - one time by the udev rule (which only fires when it is the correct device) and then again in the script.

---

Edit

Wouldn't that be enough?

```

$FIRMWARE="/path/to/file"

SUBSYSTEM=="usb", KERNEL=="lp*", ACTION=="add", \

SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="0517", \

RUN+="cat $FIRMWARE > $DEVNAME"

```

----------

## genstef

no, it wouldn't .. because if you are not supposed to upload the firmware twice .. the script checks exactly that before uploading.

----------

## Lawless

Because the printer only starts the first time I upload the firmware and does nothing when I load it a second time I think it doesn't matter how often the cat is done - it seems to ignore it.

And: the rule says ACTION=="ADD" which should (does it? I hope so) only start when the printer is plugged in.

So no reason for me to check it twice...

----------

## genstef

Well, I tried again and it indeed does not print anymore when I try to load the firmware a second time, so I think the script is needed.

I updated the foo2zjs ebuild with the patch for hplj1020 and a new loading script and some udev rules:

http://dev.gentoo.org/~genstef/files/overlay/foo2zjs.tar

Please test and tell me if it is working.

Be sure to remove the hotplug script: /etc/hotplug/usb/hplj*

Oh and of course your previous udev tries if you have any ..

----------

