# Load printer firmware on printer power on?



## Deleted member 2077 (Feb 27, 2013)

I run this when my server reboots: 


```
cat /usr/local/share/foo2zjs/firmware/sihp1020.dl >  /dev/unlpt0
```

If the printer is on, then CUPs and all that printing works.  But if printer is not on, I have to re-run that manually when it finally gets powered up.

I tried this in /etc/devd.conf


```
# start action when USB printer unlpt0 is plugged in
# wait 3 second and upload firmware
#
attach 100 {
        device-name "ulpt0";
        action "sleep 3; cat /usr/local/share/foo2zjs/firmware/sihp1020.dl >  /dev/unlpt0"
};
```

for both "ulpt0" and "unlpt0" for device-name - but doesn't seem to run that command it when powered on.  Were does devd keeps it's logs, I greped in /var/log for 'devd' and found nothing.

dmesg


```
Copyright (c) 1992-2012 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 9.0-RELEASE-p2 #1: Tue Jun  5 21:01:26 CDT 2012
    root@fire3:/usr/obj/usr/src/sys/FIRE3 i386
CPU: Intel(R) Atom(TM) CPU N2800   @ 1.86GHz (1866.78-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x30661  Family = 6  Model = 36  Stepping = 1
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,C
MOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x40e39d<SSE3,DTES64,MON,DS_CPL,EST,TM2,SSSE3,CX16,xTPR,PDCM,MOVBE>
  AMD Features=0x20100000<NX,LM>
  AMD Features2=0x1<LAHF>
  TSC: P-state invariant, performance statistics
real memory  = 4294967296 (4096 MB)
avail memory = 3396247552 (3238 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <INTEL  DN2800MT>
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
FreeBSD/SMP: 1 package(s) x 2 core(s) x 2 HTT threads
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP/HT): APIC ID:  1
 cpu2 (AP): APIC ID:  2
 cpu3 (AP/HT): APIC ID:  3
ioapic0: Changing APIC ID to 8
ioapic0 <Version 2.0> irqs 0-23 on motherboard
lapic0: Forcing LINT1 to edge trigger
acpi0: <INTEL DN2800MT> on motherboard
acpi0: Power Button (fixed)
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 14318180 Hz quality 950
Event timer "HPET" frequency 14318180 Hz quality 450
Event timer "HPET1" frequency 14318180 Hz quality 440
Event timer "HPET2" frequency 14318180 Hz quality 440
acpi0: reservation of 0, 4000 (3) failed
Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x408-0x40b on acpi0
cpu0: <ACPI CPU> on acpi0
cpu1: <ACPI CPU> on acpi0
cpu2: <ACPI CPU> on acpi0
cpu3: <ACPI CPU> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0x40d0-0x40d7 mem 0xd0600000-0xd06fffff i
rq 16 at device 2.0 on pci0
pcib1: <ACPI PCI-PCI bridge> at device 28.0 on pci0
pci1: <ACPI PCI bus> on pcib1
em0: <Intel(R) PRO/1000 Network Connection 7.2.3> port 0x3000-0x301f mem 0xd0400
000-0xd041ffff,0xd0000000-0xd03fffff,0xd0420000-0xd0423fff irq 16 at device 0.0
on pci1
em0: Using MSIX interrupts with 3 vectors
em0: Ethernet address: 00:22:4d:7f:33:38
pcib2: <ACPI PCI-PCI bridge> at device 28.1 on pci0
pci2: <ACPI PCI bus> on pcib2
em1: <Intel(R) PRO/1000 Network Connection 7.2.3> port 0x2000-0x201f mem 0xd0580
000-0xd059ffff,0xd0500000-0xd057ffff,0xd05a0000-0xd05a3fff irq 17 at device 0.0
on pci2
em1: Using MSIX interrupts with 3 vectors
em1: Ethernet address: 00:1b:21:a8:06:7b
uhci0: <Intel 82801G (ICH7) USB controller USB-A> port 0x40a0-0x40bf irq 23 at d
evice 29.0 on pci0
usbus0: <Intel 82801G (ICH7) USB controller USB-A> on uhci0
uhci1: <Intel 82801G (ICH7) USB controller USB-B> port 0x4080-0x409f irq 19 at d
evice 29.1 on pci0
usbus1: <Intel 82801G (ICH7) USB controller USB-B> on uhci1
uhci2: <Intel 82801G (ICH7) USB controller USB-C> port 0x4060-0x407f irq 18 at d
evice 29.2 on pci0
usbus2: <Intel 82801G (ICH7) USB controller USB-C> on uhci2
uhci3: <Intel 82801G (ICH7) USB controller USB-D> port 0x4040-0x405f irq 16 at d
evice 29.3 on pci0
usbus3: <Intel 82801G (ICH7) USB controller USB-D> on uhci3
ehci0: <Intel 82801GB/R (ICH7) USB 2.0 controller> mem 0xd0700400-0xd07007ff irq
 23 at device 29.7 on pci0
usbus4: EHCI version 1.0
usbus4: <Intel 82801GB/R (ICH7) USB 2.0 controller> on ehci0
pcib3: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci3: <ACPI PCI bus> on pcib3
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
ahci0: <Intel ICH7 AHCI SATA controller> port 0x40c8-0x40cf,0x40dc-0x40df,0x40c0
-0x40c7,0x40d8-0x40db,0x4020-0x402f mem 0xd0700000-0xd07003ff irq 19 at device 3
1.2 on pci0
ahci0: AHCI v1.10 with 4 3Gbps ports, Port Multiplier not supported
ahcich0: <AHCI channel> at channel 0 on ahci0
ahcich1: <AHCI channel> at channel 1 on ahci0
pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
acpi_button0: <Power Button> on acpi0
acpi_button1: <Sleep Button> on acpi0
atrtc0: <AT realtime clock> port 0x70-0x77 irq 8 on acpi0
atrtc0: Warning: Couldn't map I/O.
Event timer "RTC" frequency 32768 Hz quality 0
attimer0: <AT timer> port 0x40-0x43,0x50-0x53 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
orm0: <ISA Option ROM> at iomem 0xcf800-0xd07ff pnpid ORM0000 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
coretemp0: <CPU On-Die Thermal Sensors> on cpu0
coretemp0: Can not get Tj(target) from your CPU, using 100C.
est0: <Enhanced SpeedStep Frequency Control> on cpu0
p4tcc0: <CPU Frequency Thermal Control> on cpu0
coretemp1: <CPU On-Die Thermal Sensors> on cpu1
coretemp1: Can not get Tj(target) from your CPU, using 100C.
est1: <Enhanced SpeedStep Frequency Control> on cpu1
p4tcc1: <CPU Frequency Thermal Control> on cpu1
coretemp2: <CPU On-Die Thermal Sensors> on cpu2
coretemp2: Can not get Tj(target) from your CPU, using 100C.
est2: <Enhanced SpeedStep Frequency Control> on cpu2
p4tcc2: <CPU Frequency Thermal Control> on cpu2
coretemp3: <CPU On-Die Thermal Sensors> on cpu3
coretemp3: Can not get Tj(target) from your CPU, using 100C.
est3: <Enhanced SpeedStep Frequency Control> on cpu3
p4tcc3: <CPU Frequency Thermal Control> on cpu3
Timecounters tick every 1.000 msec
usbus0: 12Mbps Full Speed USB v1.0
usbus1: 12Mbps Full Speed USB v1.0
usbus2: 12Mbps Full Speed USB v1.0
usbus3: 12Mbps Full Speed USB v1.0
usbus4: 480Mbps High Speed USB v2.0
ugen0.1: <Intel> at usbus0
uhub0: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
ugen1.1: <Intel> at usbus1
uhub1: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus1
ugen2.1: <Intel> at usbus2
uhub2: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus2
ugen3.1: <Intel> at usbus3
uhub3: <Intel UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus3
ugen4.1: <Intel> at usbus4
uhub4: <Intel EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus4
uhub0: 2 ports with 2 removable, self powered
uhub1: 2 ports with 2 removable, self powered
uhub2: 2 ports with 2 removable, self powered
uhub3: 2 ports with 2 removable, self powered
ada0 at ahcich0 bus 0 scbus0 target 0 lun 0
ada0: <INTEL SSDSA2CW080G3 4PC10362> ATA-8 SATA 2.x device
ada0: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 76319MB (156301488 512 byte sectors: 16H 63S/T 16383C)
ada1 at ahcich1 bus 0 scbus1 target 0 lun 0
ada1: <ST32000542AS CC34> ATA-8 SATA 2.x device
ada1: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
ada1: Command Queueing enabled
ada1: 1907729MB (3907029168 512 byte sectors: 16H 63S/T 16383C)
lapic1: Forcing LINT1 to edge trigger
SMP: AP CPU #1 Launched!
lapic2: Forcing LINT1 to edge trigger
SMP: AP CPU #2 Launched!
lapic3: Forcing LINT1 to edge trigger
SMP: AP CPU #3 Launched!
Timecounter "TSC-low" frequency 14584204 Hz quality 1000
Trying to mount root from ufs:/dev/ada0p2 [rw,noatime]...
uhub4: 8 ports with 8 removable, self powered
ugen4.2: <vendor 0x058f> at usbus4
uhub5: <vendor 0x058f product 0x6254, class 9/0, rev 2.00/1.00, addr 2> on usbus
4
ugen1.2: <Lite-On Technology Corp.> at usbus1
ukbd0: <Lite-On Technology Corp. HP Basic USB Keyboard, class 0/0, rev 1.10/1.04
, addr 2> on usbus1
kbd0 at ukbd0
uhub5: 4 ports with 4 removable, self powered
arp: 192.168.0.1 moved from 20:76:00:0b:bc:3c to 20:76:00:22:9d:00 on em0
arp: 192.168.0.1 moved from 20:76:00:22:9d:00 to 20:76:00:0b:bc:3c on em0
arp: 192.168.0.1 moved from 20:76:00:0b:bc:3c to 20:76:00:22:9d:00 on em0
arp: 192.168.0.1 moved from 20:76:00:22:9d:00 to 20:76:00:0b:bc:3c on em0
Cuse4BSD v0.1.26 @ /dev/cuse
ugen4.3: <Hewlett-Packard> at usbus4
ulpt0: <Hewlett-Packard HP LaserJet 1020, class 0/0, rev 2.00/1.00, addr 3> on u
sbus4
ulpt0: using bi-directional mode
ulpt0: offline
ugen4.3: <Hewlett-Packard> at usbus4 (disconnected)
ulpt0: at uhub4, port 3, addr 3 (disconnected)
ugen4.3: <Hewlett-Packard> at usbus4
ulpt0: <Hewlett-Packard HP LaserJet 1020, class 0/0, rev 2.00/1.00, addr 3> on u
sbus4
ulpt0: using bi-directional mode
ugen4.3: <Hewlett-Packard> at usbus4 (disconnected)
ulpt0: at uhub4, port 3, addr 3 (disconnected)
```


----------



## wblock@ (Feb 27, 2013)

The printer device appearing would be a CDEV.  See the system /etc/devd.conf for an example with the ums device.

I think devd(8) will give a lot more information if run in the foreground and with -D.


----------



## Deleted member 2077 (Feb 27, 2013)

oh, sounds good.  I'll test when I get home.  It had a config error (syntax), so might be on the right track.  Thanks.


----------



## Deleted member 2077 (Feb 27, 2013)

So, this isn't right; but I noticed in devd -Dd that this was being called: /usr/local/sbin/ulpt-cupsd.sh.  The entry I put in devd.conf isn't working.

but anyways, I modified this sh script:


```
if [ -z "$printer" ]; then
        # nothing to do
# commented out.
#       exit 0
fi

case "$1" in
enable)
        chown cups:cups "/dev/$2"
        /usr/local/sbin/cupsenable "$printer"
        #added this line
        sleep 12; cat /usr/local/share/foo2zjs/firmware/sihp1020.dl >  /dev/unlpt0
        ;;
disable)
# etc...
```

So, that works, but probably not the right way to do it.  Probably have problems if this is every updated in src..

I don't know, why isn't my entry in devd.conf (in first post) not working?

I don't know what CDEV is and the only ums device is in my devd.conf is:


```
attach 100 {
        device-name "ums[0-9]+";
        action "/etc/rc.d/moused quietstart $device-name";
};

detach 100 {
        device-name "ums[0-9]+";
        action "/etc/rc.d/moused stop $device-name";
};
```


----------



## wblock@ (Feb 27, 2013)

What version of FreeBSD are you running?  devd(8) changed recently.  This is from 9.1-STABLE:

```
notify 100 {
        match "system" "DEVFS";
        match "subsystem" "CDEV";
        match "type" "CREATE";
        match "cdev" "ums[0-9]+";

        action "/etc/rc.d/moused quietstart $cdev";
};

notify 100 {
        match "system" "DEVFS";
        match "subsystem" "CDEV";
        match "type" "DESTROY";
        match "cdev" "ums[0-9]+";

        action "/etc/rc.d/moused stop $cdev";
};
```


----------



## Deleted member 2077 (Feb 27, 2013)

wblock@ said:
			
		

> What version of FreeBSD are you running?  devd(8) changed recently.  This is from 9.1-STABLE:
> 
> ```
> notify 100 {
> ...




FreeBSD 9.0-RELEASE-p2


----------

