# USB and cam system bug?



## Seeker (Dec 14, 2009)

```
# ll /dev/da*
[I]ls: No match.[/I]
```
Now, I plug into USB port my mobile phone(File Transfer mode).

```
# camcontrol devlist
[I]<SEMC Int.Memory 0000>             at scbus0 target 0 lun 0 (da0,pass0)
<SEMC Mem-Stick 0000>              at scbus1 target 0 lun 0 (da1,pass1)[/I]
```


```
# ll /dev/da*
[I]crw-r-----  1 root  operator  -   0, 147 Dec 14 20:37:26 2009 /dev/da0
crw-r-----  1 root  operator  -   0, 149 Dec 14 20:37:27 2009 /dev/da1[/I]
```
For mounting, there should be /dev/da1s1 listed, but it is not.

_"Something"_ made it ready/loaded, as I did:

```
# camcontrol load da1
```
In /etc/rc.conf:

```
hald_enable="YES"
dbus_enable="YES"
```
Now in order to get /dev/da1s1 listed

```
# camcontrol rescan all
[I]Re-scan of bus 0 was successful
Re-scan of bus 1 was successful[/I]
```


```
# ll /dev/da*
[I]crw-r-----  1 root  operator  -   0, 147 Dec 14 20:37:26 2009 /dev/da0
crw-r-----  1 root  operator  -   0, 149 Dec 14 20:37:27 2009 /dev/da1[/I]
```
Still nothing...
So I do this:

```
# mount -t msdosfs -o -m=600,-M=700 /dev/da1s1 ~/mobile
[I]mount_msdosfs: /dev/da1s1: No such file or directory[/I]
```
*Now watch this!*
_Excluding slice 1_

```
# mount -t msdosfs -o -m=600,-M=700 /dev/da1 ~/mobile
[I]mount_msdosfs: /dev/da1: Invalid argument[/I]
```
Exactly command above, made /dev/da1s1 to appear

```
# ll /dev/da*
[I]crw-r-----  1 root  operator  -   0, 147 Dec 14 20:37:26 2009 /dev/da0
crw-r-----  1 root  operator  -   0, 149 Dec 14 20:37:27 2009 /dev/da1
[color="Red"]crw-r-----  1 root  operator  -   0, 150 Dec 14 20:46:21 2009 /dev/da1s1[/color][/I]
```
Now I can do:

```
# mount -t msdosfs -o -m=600,-M=700 /dev/da1s1 ~/mobile
```
And _*Voila!*_

Is this a bug?


----------



## jb_fvwm2 (Dec 15, 2009)

Maybe explained by my post and others in the thread Nov 2008.
"Can't mount usb flash drive" 
(desktop usage >> Multimedia subforum(s).)


----------



## Seeker (Dec 15, 2009)

I disagree with you.
Those post are nothing but a trial and error attempts, with no final solution.

I will be very simple. Concentrate on this:
When I plugin USB device, I want it to immidieatly show as:

```
# ll /dev/da*
[I]crw-r-----  1 root  operator  -   0, 147 Dec 14 20:37:26 2009 /dev/da0
[color="Red"]crw-r-----  1 root  operator  -   0, 150 Dec 14 20:46:21 2009 /dev/da0s1[/color]
crw-r-----  1 root  operator  -   0, 149 Dec 14 20:37:27 2009 /dev/da1
[color="Red"]crw-r-----  1 root  operator  -   0, 150 Dec 14 20:46:21 2009 /dev/da1s1[/color][/I]
```
insetad of current:

```
# ll /dev/da*
[I]crw-r-----  1 root  operator  -   0, 147 Dec 14 20:37:26 2009 /dev/da0
crw-r-----  1 root  operator  -   0, 149 Dec 14 20:37:27 2009 /dev/da1
[/I]
```


----------



## pbd (Dec 15, 2009)

(My 8.0-RELEASE does exactly the same with HTC Dream/T-mobile G1.)


----------



## Beastie (Dec 15, 2009)

Could be a bug or a regression. Did it behave similarly on 7.x or you have only tried 8.0?

Also, I'm just curious. Why do you enable HAL if you want to manually mount the device? Isn't HAL usually used to auto-detect and auto-mount devices?


----------



## pbd (Dec 15, 2009)

Beastie said:
			
		

> Could be a bug or a regression. Did it behave similarly on 7.x or you have only tried 8.0?



I have tried on 7.1-RELEASE-p8: it's the same.


----------



## Seeker (Dec 15, 2009)

I use hal because other ports need it(ie: Xorg). Not because this exact case.

It sucks a big time, a fact, that you first have to *intentionally cause an error*, with attempt to *mount device itself* in order for device to be rescanned by OS and to properly show device's slices in /dev


----------



## jb_fvwm2 (Dec 15, 2009)

I recollect one of the moderators on this or 
daemonforums.org explaining it better.


----------



## aragon (Dec 15, 2009)

Has someone filed a PR?


----------



## Seeker (Dec 16, 2009)

I did not. 
Actually..., I've never done such a thing, so I have no experience with it.

If someone did, than post a link to it, so we could track a progress.


----------



## aragon (Dec 16, 2009)

It's best if someone who can reproduce the bug logs the PR...


----------



## crsd (Dec 16, 2009)

Does stopping hald solve the problem?


----------



## Seeker (Dec 16, 2009)

I booted without hald.
It didn't affect issue in any way, except that mouse worked in default console, but not when I started X.

I must notice that after a reebot, with usb memory leaved plugged in, all devices were properly showed with theirs slices in /dev/da*

This type of scan is obviously not initiated when usb is plugged in afterwords.


----------



## Beastie (Dec 16, 2009)

You aren't connecting indirectly through an external USB hub, are you?


----------



## Seeker (Dec 17, 2009)

No, I simply plug it in a usb slot on my midi case


----------



## Beastie (Dec 17, 2009)

And other devices such as mice or pendrives work fine?


----------



## tingo (Dec 17, 2009)

Seeker said:
			
		

> No, I simply plug it in a usb slot on my midi case



Frontend ports by any chance? If so, try the ports on the back of the case also. I have seen some motherboards where the front / back usb ports worked differently.


----------



## Beastie (Dec 17, 2009)

That's why I'm asking the above question. These may all be connected to 1 root hub only. You may check the MoBo diagrams, but I thought plugging a pendrive or mouse in was easier.


----------



## Seeker (Dec 17, 2009)

In a back of a case are 4 usb slots.(directly on a MB)
In front of a case are 2 usb slots.(wired to MB)

usb mouse and this mem are always plugged in front case usb slots.
Now I've attached mem in a back of a case.

Nothing changed.


----------



## Seeker (Dec 18, 2009)

I tried it on a laptop and all is same.
Here are some sys messages


```
da1 at umass-sim1 bus 1 scbus1 target 0 lun 0
da1: <SEMC Mem-Stick 0000> Removable Direct Access SCSI-0 device
da1: 1.000MB/s transfers
da1: Attempt to query device size failed: NOT READY, Medium not present
```
And more when mounting

```
GEOM: da1: partition 1 does not start on a track boundary.
GEOM: da1: partition 1 does not end on a track boundary.
```


----------



## Beastie (Dec 18, 2009)

Then destroy the slices, recreate them and do a newfs.


----------



## Seeker (Dec 18, 2009)

But this is a mobile phone.
I simply bought it formatted "as is".
Factory did this.


----------



## Seeker (Dec 21, 2009)

But this doesn't explain, why is all properly displayed/detected, if USB device is attached prior to booting.

If I attach USB device afterwards, then I have to initiate an error, in order to get a properly displayed/detected devices/slices


----------



## aragon (Dec 21, 2009)

My phone also formats its memory card with no regard to cylinder boundaries, but I don't have this problem...


----------



## Seeker (Jan 5, 2010)

Seeker said:
			
		

> But this doesn't explain, why is all properly displayed/detected, if USB device is attached prior to booting.
> 
> If I attach USB device afterwards, then I have to initiate an error, in order to get a properly displayed/detected devices/slices




```
...
da0 at umass-sim0 bus 0 scbus0 target 0 lun 0
da0: <SEMC Int.Memory 0000> Removable Direct Access SCSI-0 device
da0: 1.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present
(probe1:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
(probe1:umass-sim1:1:0:0): CAM Status: SCSI Status Error
(probe1:umass-sim1:1:0:0): SCSI Status: Check Condition
(probe1:umass-sim1:1:0:0): UNIT ATTENTION asc:29,0
(probe1:umass-sim1:1:0:0): Power on, reset, or bus device reset occurred
(probe1:umass-sim1:1:0:0): Retrying Command (per Sense Data)
(probe1:umass-sim1:1:0:0): TEST UNIT READY. CDB: 0 0 0 0 0 0
(probe1:umass-sim1:1:0:0): CAM Status: SCSI Status Error
(probe1:umass-sim1:1:0:0): SCSI Status: Check Condition
(probe1:umass-sim1:1:0:0): NOT READY asc:3a,0
(probe1:umass-sim1:1:0:0): Medium not present
(probe1:umass-sim1:1:0:0): Unretryable error
da1 at umass-sim1 bus 1 scbus1 target 0 lun 0
da1: <SEMC Mem-Stick 0000> Removable Direct Access SCSI-0 device
da1: 1.000MB/s transfers
da1: Attempt to query device size failed: NOT READY, Medium not present
can't re-use a leaf (minimum_cmd_size)!
ugen4.2: <Sony Ericsson> at usbus4 (disconnected)
umass0: at uhub4, port 2, addr 2 (disconnected)
(da0:umass-sim0:0:0:0): lost device
(da0:umass-sim0:0:0:0): removing device entry
umass1: at uhub4, port 2, addr 2 (disconnected)
(da1:umass-sim1:1:0:0): lost device
(da1:umass-sim1:1:0:0): removing device entry
```

What does this tell you?
Any indication to this issue?


----------



## Seeker (Jan 6, 2010)

Ok guys, I've just destroyed the slices, recreate them and did a newfs_msdos FAT16, then restored data and NADA! 

I guess it is time for filling a pr.


----------



## jb_fvwm2 (Jan 6, 2010)

Have you loaded ehci.ko?  (Useful in v8 vs v7). If
that helps.


----------



## Seeker (Jan 6, 2010)

jb_fvwm2 said:
			
		

> Have you loaded ehci.ko?  (Useful in v8 vs v7). If
> that helps.



I can't load it. 


```
# kldstat
Id Refs Address    Size     Name
 1   24 0xc0400000 b7abe0   kernel
 2    1 0xc0f7b000 1a60     accf_data.ko
 3    1 0xc0f7d000 2534     accf_http.ko
 4    1 0xc0f80000 2030     wlan_xauth.ko
 5    1 0xc46c4000 3000     pflog.ko
 6    1 0xc46c7000 35000    pf.ko
 7    1 0xc4983000 e000     fuse.ko
 8    2 0xc4aa4000 7a000    osscore.ko
 9    1 0xc4b2a000 6000     oss_audigyls.ko
10    1 0xc4c93000 68000    radeon.ko
11    1 0xc4cfb000 14000    drm.ko
```


```
# kldload ehci
kldload: can't load ehci: File exists
```


```
# locate ehci.ko
/boot/kernel/ehci.ko
/boot/kernel/ehci.ko.symbols
```


----------



## richardpl (Jan 6, 2010)

Is this because hald and dbus are enabled?


----------



## Seeker (Jan 6, 2010)

Some ports depend on it.
I'll disable them.


----------



## Seeker (Jan 6, 2010)

I disabled hald and dbus and even moused(strange that my usb mouse works in console).

I still can't *kldload ehci*


----------



## crsd (Jan 6, 2010)

```
# kldload ehci
kldload: can't load ehci: File exists
```
means that *ehci* is already built in kernel. You can check it using [cmd=""]kldstat -v | grep ehci[/cmd]



> I disabled hald and dbus and even moused(strange that my usb mouse works in console).


/usr/sbin/moused is started by *devd* upon USB mouse attach (and is killed on detach). You can check /etc/devd.conf, line with _device-name "ums[0-9]+";_


----------



## Seeker (Jan 7, 2010)

crsd said:
			
		

> ```
> # kldload ehci
> kldload: can't load ehci: File exists
> ```
> means that *ehci* is already built in kernel. You can check it using [cmd=""]kldstat -v | grep ehci[/cmd]


Yeah! 

```
# kldstat -v | grep ehci
                280 ehci/usbus
                275 pci/ehci
```



			
				crsd said:
			
		

> /usr/sbin/moused is started by *devd* upon USB mouse attach (and is killed on detach). You can check /etc/devd.conf, line with _device-name "ums[0-9]+";_


Aaaaa... :stud
And I've been asking, what initiates:

```
# ps -U root | grep moused
  675  ??  Is     0:02.34 /usr/sbin/moused -p /dev/ums0 -t auto -I /var/run/moused.ums0.pid
```
So I need *moused_enable="YES"*, only for PS/2 mouses?


----------



## Seeker (Jan 28, 2010)

Just to say that all this post is based on my mobile phone, which I attach to USB and am using it as a USB memory.

Yesterday, I plugged in _real_ USB memory stick and slice was immediately recognized.
That is..., it worked as I want my mobile phone, to work.


----------



## Seeker (Feb 13, 2010)

Ok, this is state, which I achieve when I leave mobile phone plugged in and reboot:
http://www.starforce.biz/LOAD_boot.txt
And this is state from this post when I plug in already booted system:
http://www.starforce.biz/LOAD_after_boot.txt


----------



## Seeker (Feb 15, 2010)

GUYS!

Point is that link *1*, contains a *SOLUTION*, as all slices are recognized and listed properly.
So boot time code *DOES SOMETHING*, that after boot procedure *DOESN'T DO*.

Which cmd, I need to execute in order to have a same effect from first link, that is..., to have slices recognized, too?


----------



## mav@ (Feb 15, 2010)

I've recently merged some potentially related CAM code to 8-STABLE. So it can be a good time to update.

Other option - it can be hardware issue. Phone reports that it has no media inserted. Probably when plugged after boot it is probed faster, that possible gives phone not enough time to initialize. You may try `false > /dev/da0` command after attach to trigger media re-taste.


----------



## Seeker (Feb 15, 2010)

O no! I had enough of STABLE, for whole my life! 

```
# false > /dev/da0
# false > /dev/da1
```
_Worked quietly and flawlessly!
Thx! _


----------

