# Add usb device



## vince66 (Dec 6, 2017)

Hello everybody,

I'm beginner of FreeBSD. So, I apologize in advance for my question.

In the attached photos you can see the /var/log/messages where it is shown that the kernel knows that on my machine are usb controllers (ohci, ehci), but when I use usbconfig command the system inform me that there are not usb devices.
Moreover, if I attach a usb stick, never happens.

Are other ways to interrogate the usb device driver to investigate the problem ?
Please, can you tell me (tips, articles/books to read) how can I add a usb device ?

Thanks in advance.

Regards.

Vincenzo.


----------



## k.jacker (Dec 6, 2017)

Hey Vincenzo,



vince66 said:


> I use usbconfig command the system inform me that there are not usb devices.


Did you run it as root?



vince66 said:


> Moreover, if I attach a usb stick, never happens.


Do you mean that you inserted an usb-stick and you couldn't access it?


----------



## vince66 (Dec 6, 2017)

Of corse, i run usbconfig as root.

I think so ... that's way I use FreeBSD ... however, when I plug a usbstick, i should see it in /dev ... and this doesn't happen ... I try to be more precise: I am not interesting to access it (mount its filesystem), but only connect it to pc to take its clone with dd ... but, of corse I need to know its name under /dev.

Any tips ?

Thanks in advance.

Vincenzo.


----------



## k.jacker (Dec 6, 2017)

You don't need to search for it's name in /dev.
The device name should appear in the kernel message on ttyv0 and in `dmesg|tail`
It will most likely be /dev/da0.

Running `gpart show` will also show all attached drives that have at least an MBR or GPT partition table on them.
Since you want to clone that drive it should have a partition table and will show up.


----------



## vince66 (Dec 7, 2017)

Thanks very much.
Please, let me the possibility to understand more.

*1 - You don't need to search for it's name in /dev.*
Yes, i wrong. I'm agree with you.

*2 - The device name should appear in the kernel message on ttyv0 and in dmesg|tail
It will most likely be /dev/da0.*

When I plug in the usb stick, no device name (/dev/da0) appears on the ttyv0 and in dmesg.
My question is due to the problem I shown in the previous post: usbd_req_re_enumerate.

It seems that one of the four usb port of my motherboard is broken.
Installing FreeBSD I receive the messages:

>> usbd_req_re_enumerate: addre=2, set address failed (USB_ERR_IOERROR, ignored)
>> usbd_setup_device_desc: getting device descriptor at addr 2 failed,
>> USB_ERR_IOERROR ugen0.2: <Unknown> at usbus0 (disconnected)
>> uhub_reattach_port: could not allocate new device

To avoid this, I've disabled in the BIOS the option:

"USB 1.1 OHCI Controllers"

that, by default, disables also the "USB 2.0 EHCI controller" and the "USB legacy" and disabling all the USB ports on my system after the boot (I can only use a PS/2 keyboard to work).

However, this don't happen if I installl Ubuntu 16.04.

For this reason I'm trying to understand in which a way I can activate the three usb ports that work well.

*3 - Running gpart show will also show all attached drives that have at least an MBR or GPT partition table on them.
Since you want to clone that drive it should have a partition table and will show up.*

Are you shure of this ? Please, consider a usb stick with the MBR or GPT damaged.
In this case FreeBSD is not able to detect it and "create" /dev/da0 ?

Thanks in advance.

Best Regards.

Vincenzo.


----------



## vince66 (Dec 7, 2017)

Thanks very much.
Please, let me the possibility to understand more.

*1 - You don't need to search for it's name in /dev.*
Yes, i wrong. I'm agree with you.

*2 - The device name should appear in the kernel message on ttyv0 and in dmesg|tail
It will most likely be /dev/da0.*

When I plug in the usb stick, no device name (/dev/da0) appears on the ttyv0 and in dmesg.
My question is due to the problem I shown in the previous post: usbd_req_re_enumerate.

It seems that one of the four usb port of my motherboard is broken.
Installing FreeBSD I receive the messages:

>> usbd_req_re_enumerate: addre=2, set address failed (USB_ERR_IOERROR, ignored)
>> usbd_setup_device_desc: getting device descriptor at addr 2 failed,
>> USB_ERR_IOERROR ugen0.2: <Unknown> at usbus0 (disconnected)
>> uhub_reattach_port: could not allocate new device

To avoid this, I've disabled in the BIOS the option:

"USB 1.1 OHCI Controllers"

that, by default, disables also the "USB 2.0 EHCI controller" and the "USB legacy" and disabling all the USB ports on my system after the boot (I can only use a PS/2 keyboard to work).

However, this don't happen if I installl Ubuntu 16.04.

For this reason I'm trying to understand in which a way I can activate the three usb ports that work well.

*3 - Running gpart show will also show all attached drives that have at least an MBR or GPT partition table on them.
Since you want to clone that drive it should have a partition table and will show up.*

Are you shure of this ? Please, consider a usb stick with the MBR or GPT damaged.
In this case FreeBSD is not able to detect it and "create" /dev/da0 ?

Thanks in advance.

Best Regards.

Vincenzo.


----------



## sidetone (Dec 7, 2017)

vince66 , can you clarify what types of USB's those are? To make sure they are not flash drives, as it is assumed.

You can also look in /dev/ to see which file or folder appears or disappears, when you plug in or unplug that usb device. Tell us what that is. Then you can look for it with `dmesg | grep`, or you can look for it with `dmesg` by itself, as k.jacker suggested.


----------



## k.jacker (Dec 7, 2017)

vince66 said:


> Are you shure of this ? Please, consider a usb stick with the MBR or GPT damaged.
> In this case FreeBSD is not able to detect it and "create" /dev/da0 ?


I kindly remind you of, that it was you, reaching out for help.

Back to your problem...
Hard to tell from the distance what's going on and why it's working on Ubuntu.
You might have luck assinging the USB ports to another IRQ from the BIOS.

If that won't do the trick I'd simply buy an add-on card and disable the motherboard's USB ports.


----------



## vince66 (Dec 7, 2017)

Hello guys,

I wish to thank you for your kindly reply. I know, it is very hard to tell from distance what's going on.

Please, let me try to pose the question in a different way:
1- I have disabled in the BIOS any usb ports; that is i have disabled the options: "USB 1.1 OHCI Controllers", "USB 2.0 EHCI controller" and the "USB legacy" (so doing any usb port does'nt work and I can only use a PS/2 keyboard/mouse).
2- I have saved these changes and reboot the system (F10 key)
3- How can I do to inform the FreeBSD kernel of the existence of the usb interface and use usb memory sticks like those depicted in the attached photo ?



K.jacker, your reply has been very important because you generate a new one question:
if the MBR (or GPT) of a usb memory stick is damaged, but the stick is full of data, is FreeBSD alike able to detect it as /dev/da0 ?
The question derives from the following necessity: I'm not interesting to know what is stored in it, what is its filesystem, etc..., but only freeze it in a "dd" image.

I hope to hear you soon  and thanks in advance for your time.

Regards.

Vincenzo.


----------



## k.jacker (Dec 7, 2017)

Hey Vincenzo,

The kernel messages will allways appear when you insert whatever usb device, no matter if it's a keyboard, mouse or usb-drive.
It doesn't matter if it's a new/blank usb-drive or one with data on it.

Though for `gpart` to 'see' it, it needs to have at least a MBR/GPT partition table on it, filessystems are not needed to be 'seen'.
If the primary partition table (in sector0) is somewhat damaged it think it would be shown as _[CORRUPTED]_ by gpart.
If the secondary partition table is damaged gpart will mention that also (applies only to GPT).

If you don't see kernel messaged when you insert the drive, then you can't access/use it (no matter what kind of device it is).
Remember that the kernel messages do not appear in X and you have to check with `dmesg|tail` when you are not on ttyv0.

Even if your USB drive might have damaged data on it, you should still be able to `dd` it's contents to a file or whatever, as long as you see kernel messages indicating it's device name.


----------



## vince66 (Dec 7, 2017)

Yes ! yes ! yes ! ... now it is clear ! thanks very much !!!

Vincenzo.


----------

