maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   [Announce] USB hostmode beta release (https://talk.maemo.org/showthread.php?t=65232)

blue_led 2011-12-03 14:49

Re: [Announce] USB hostmode beta release
 
Quote:

Originally Posted by pali (Post 1132671)
@blue_led:
why is problem with autodetection usb speed? and it is possible to check if host usb device or charger is connected?

You miss 1 year ? :D

first q :switching speed need vbus go 0 Volts. for valid usb session vbus above 4.4 volts condition is needed . switching vbus from 0 to 5 v ( for setting speed ) will trigger an interrupt activating khubd, but usb phy and driver are not in a stable state and khubd go crazy ( timeout ). generic or custom KP kernel don't know how to switch isp1707 speed ( is "platform dependent" and not allowed when vbus is 5V ). if some patches will be writen for vbus switching in kernel some processes ( bme ) need to be stopped for leaving i2c device bq24150 free to controll. and for vbus stable a timer doing any action every less 32 s on bq21450's i2c interface also is needed
so pointing from kernel space to bme and setting a timer look ugly

it is easy doing all selections from userspace

second q: is not a problem

pali 2011-12-03 15:08

Re: [Announce] USB hostmode beta release
 
I see that problem from kernel hostmode patch (error messages in musb_procfs.c), but I was not sure if switching vbus is only problem. But I started looking around bq2145x chip and I will write kernel module(s) for bq chip and charging...

jbscurtis 2011-12-03 18:53

Re: [Announce] USB hostmode beta release
 
The jumper cables are a nice touch :)

joerg_rw 2011-12-03 19:20

Re: [Announce] USB hostmode beta release
 
@blue_led
the userland autospeed has one problem: it needs to either depend on sysklogd being installed or use kmsg directly. You need to support both cases, or rdepend on ksyslogd pkg.
You are aware you can find about lowspeed vs high/fullspeed devices by reading out the status registers of PHY, and IIRC they are even printed in syslog. on one the D+ is low while on other the D- is low (see USB 101 about lowspeed vs full/highspeed signalling via pullup R) [maybe the prev isn't all correct as I haven't re-read the specs myself just now, it's a while since I last looked into them]
Great to see your progress, while I clearly suck delivering that stuff :-D
Keep in mind it may take quite some time after disabling boost mode until VBUS drops to a sane level so you can switch speed. Maybe testing VBUS voltage may give a clue, or just insert a short (some 5..15s) charging phase so bq24150 will try to pull power and thus discharges VBUS rail. Otherwise musb_core might not allow proper changing of speed.

cheers and keep hacking
jOERG

blue_led 2011-12-03 20:04

Re: [Announce] USB hostmode beta release
 
Quote:

Originally Posted by joerg_rw (Post 1132779)
@blue_led
the userland autospeed has one problem: it needs to either depend on sysklogd being installed or use kmsg directly. You need to support both cases, or rdepend on ksyslogd pkg.
You are aware you can find about lowspeed vs high/fullspeed devices by reading out the status registers of PHY, and IIRC they are even printed in syslog. on one the D+ is low while on other the D- is low (see USB 101 about lowspeed vs full/highspeed signalling via pullup R) [maybe the prev isn't all correct as I haven't re-read the specs myself just now, it's a while since I last looked into them]
Great to see your progress, while I clearly suck delivering that stuff :-D
Keep in mind it may take quite some time after disabling boost mode until VBUS drops to a sane level so you can switch speed. Maybe testing VBUS voltage may give a clue, or just insert a short (some 5..15s) charging phase so bq24150 will try to pull power and thus discharges VBUS rail. Otherwise musb_core might not allow proper changing of speed.
jOERG

my script is plain, dumb, ash script. for sure it don't suffer for missing lib
i think there is a bug or some curent leakage on d+ line so with no device attached the driver see a full/high speed device. also some modern usb devices don't have a physical resistor on data lines. they are inside asics and connected by inside fet transistors as found in isp707. i can't control how kernel deal with those cips . and i think this pull-up resistor is not connected instantly so the driver don't act well.
in sys log i see "Forcemode... no device attached" followed immediately by "Forcemode ... full spped device detected" .
my script is "event driven" so it wait for vbus changes, and sys messages. setting speed is not a problem but driver don't act as expected.
in one case i see "b-host" state :D


Late edit:
i found proper ( stable) procedure for sensing low speed devices when high or full speed is set.
rmmod g_file_storage is the key ( workaround ) . proper solution is interrupt deactivation for "vbus stable"

joerg_rw 2011-12-03 22:53

Re: [Announce] USB hostmode beta release
 
Quote:

Originally Posted by blue_led (Post 1132801)
my script is plain, dumb, ash script. for sure it don't suffer for missing lib

I don't talk about libs, I related to the way you get syslog/dmesg logs from kernel. Not all systems have pkg sysklogd installed, and on those who have you will need to use sth along the line of "tail -f /var/log/syslog" as the only alternative source for kernel logging (/proc/kmesg) is already occupied by the syslog daemon, I.E. a logger msg would either go to syslog or to your process listening to /proc/kmsg then on a random basis, if you'd use /proc/kmsg on a system with syslog installed.
On systems that have no /var/log/syslog OTOH you either install sysklogd pkg to get /var/log/syslog, or you need to use /proc/kmsg.


Quote:

Originally Posted by blue_led (Post 1132801)
i think there is a bug or some curent leakage on d+ line so with no device attached the driver see a full/high speed device. also some modern usb devices don't have a physical resistor on data lines. they are inside asics and connected by inside fet transistors as found in isp707. i can't control how kernel deal with those cips . and i think this pull-up resistor is not connected instantly so the driver don't act well.
in sys log i see "Forcemode... no device attached" followed immediately by "Forcemode ... full spped device detected" .
my script is "event driven" so it wait for vbus changes, and sys messages. setting speed is not a problem but driver don't act as expected.
in one case i see "b-host" state :D


Late edit:
i found proper ( stable) procedure for sensing low speed devices when high or full speed is set.
rmmod g_file_storage is the key ( workaround ) . proper solution is interrupt deactivation for "vbus stable"

you mostly lost me on all that, except the "event driven" detail. I'm not aware of any such bug and couldn't figure how normal hostmode would work if normal peripherals wouldn't adhere to the standards regarding pullup/down resistors. What do you mean by "interrupt deactivation"? The state changes on USB/VBUS are sensed by ke-recv and/or hulda process via kernel event messages, quite similar to udev. ke-recv and/or udev and/or hulda then start requester which in turn loads g_file_storage (or was it g_nokia?) - IIRC

cheers
jOERG

blue_led 2011-12-03 23:41

Re: [Announce] USB hostmode beta release
 
you are all right.
dropping vbus activate g_file storage and i don't need this.

i have final scenario:
1 stop bme
2 vbus on
3 rmmod g_file_storage
4 force low
5 F > ..
6 listen to messages ( hard speed detection )
7 if no message >> low speed device
if full/high message >> go further ( step 8 )
if no device >> exit
8 put usb in stable state ...... ( here need more tests including modprobe g_file_storage or switch to peripheral )
9 force full
11 F >
12 if message "force ..error... high speed device .. but not high.." >> go high ( soft speed detection )
exit

i don't see a fastest way

pali 2011-12-04 22:04

Re: [Announce] USB hostmode beta release
 
@blue_led:
What about modifing musb_procfs.c (or in other kernel parts) to do this detection in kernel?

blue_led 2011-12-04 23:46

hostmode . the script
 
1 Attachment(s)
@pali
it can be very possible, even OTG mode
but this depend on vbus switching and the patch will be very specialized pointing only for rx51
sensing speed of device can be done without a timer for bq24500. 32s is enough for all jobs
now it is clear for me how to do this. as my post above..
first part ->hardware detection of the device
power the vbus and read debug register
here we have 3 cases
0 no device
1 low speed device
2 high or full
after this, speed can be set and read device descriptor
if the device is high speed then switch
high speed devices can be read in full speed mode

the goal of my script is to prove the concept

@everybody

[Announce] The n900 hostmode script
features: icon, automatic speed, status area icon ,notifications, mass sotorage automount, no gui

unzip the attachment in a folder
as root run
Code:

chmod 755 install.sh
install.sh

LE: zip updated with icon file. sorry for mistake
please reload

To support efforts press "Thanks"

joerg_rw 2011-12-04 23:52

Re: hostmode . the script
 
Quote:

Originally Posted by blue_led (Post 1133260)
@pali
it can be very possible, even OTG mode
but this depend on vbus switching and the patch will be very specialized pointing only for rx51
sensing speed of device can be done without a timer for bq24500. 32s is enough for all jobs
now it is clear for me how to do this. as my post above..
first part ->hardware detection of the device
power the vbus and read debug register
here we have 3 cases
0 no device
1 low speed device
2 high or full
after this, speed can be set and read device descriptor
if the device is high speed then switch
high speed devices can be read in full speed mode

the goal of my script is to prove the concept

@everybody

[Announce] The n900 hostmode script

unzip the attachment in a folder
as root run
Code:

chmod 755 install.sh
install.sh


Yes, this concept is correct. I don't know what you mean by "32s is enough" though. At least bq24150 watchdog will need 10s at worst case

cheers
jOERG


All times are GMT. The time now is 22:01.

vBulletin® Version 3.8.8