![]() |
Re: N900 does now allow USB hostmode!
Quote:
And I would concentrate on kernel side - going through hub and process a disk/USB stick (I assume that this stuff is more interesting for anybody). |
Re: N900 will not allow USB OTG!
Just fact : when I play with usb port & procfs, on my n900, pc suite mode status hang-on even there is no usb charger, pc or any device connected !??
So good nwes for us ( from egoshin ) bme fault the otg usb host. Q why I say still otg ? A (my opinion ) : egoshin make work otg module. it is the only one activated by configs . Initial connection to pc is needed to initialize otg state machine as a peripheral then switch to host by HNP. The great discovery of egoshin is initial connection to pc. All previous attempt to activate host mode was made without this phase. Mode selection: usb device | pc suite, feat bme is a garbage bunch of software. We need to change all of this. As i know, echo H > .... force HNP egoshin, please, please try without " echo host > ..../mode Quote:
charging on host mode is now accepted by ( patched ) usb 2.0 standard . because charging circuit is INDEPENDENT from usb stuff nothing prevent this on N900 we have 2 situation 1) vbus =5v ( from external source) THEN charge if is needed. IF PC don't host . IF D+/D- short then high power charge ELSE can host if wanted. 2) vbus =0 THEN IF host then BOOST More: this settings are made on only one f.. asic no rocket science From ancient n900 times : ... limitation at hardware level .... My a.. . sorry for language. |
Re: N900 will not allow USB OTG!
I'm not sure whether this has been posted here already:
excerpt from drivers/usb/musb/Kconfig (it would be possible to build it with USB host only) config USB_MUSB_HOST depends on USB bool "USB Host" help Say Y here if your system supports the USB host role. If it has a USB "A" (rectangular), "Mini-A" (uncommon), or "Mini-AB" connector, it supports the host role. (With a "Mini-AB" connector, you should enable USB OTG.) # use USB_GADGET_MUSB_HDRC not USB_MUSB_PERIPHERAL to #ifdef peripheral # side support ... OTG needs both roles config USB_MUSB_PERIPHERAL depends on USB_GADGET bool "USB Peripheral (gadget stack)" select USB_GADGET_MUSB_HDRC help Say Y here if your system supports the USB peripheral role. If it has a USB "B" (squarish), "Mini-B", or "Mini-AB" connector, it supports the peripheral role. (With a "Mini-AB" connector, you should enable USB OTG.) config USB_MUSB_OTG depends on USB && USB_GADGET && PM && EXPERIMENTAL bool "Both host and peripheral: USB OTG (On The Go) Device" select USB_GADGET_MUSB_HDRC select USB_OTG help The most notable feature of USB OTG is support for a "Dual-Role" device, which can act as either a device or a host. The initial role choice can be changed later, when two dual-role devices talk to each other. At this writing, the OTG support in this driver is incomplete, omitting the mandatory HNP or SRP protocols. However, some of the cable based role switching works. (That is, grounding the ID pin switches the controller to host mode, while leaving it floating leaves it in peripheral mode.) Select this if your system has a Mini-AB connector, or to simplify certain kinds of configuration. To implement your OTG Targeted Peripherals List (TPL), enable USB_OTG_WHITELIST and update "drivers/usb/core/otg_whitelist.h" to match your requirements. endchoice |
Re: N900 will not allow USB OTG!
If you disable OTG, will that break the N900's ability to charge and be a peripheral?
I don't think we really want OTG, do we? We want USB host... If we disabled OTG, is there a way to manually switch between peripheral / PC Suite mode (USB client) and USB host? Or do egoshin's tests (success via forcing OTG mode) suggest that OTG is our only hope? |
Re: N900 will not allow USB OTG!
1 Attachment(s)
/* whitelist */
and about uB connector.... always chinese people made an adapter and I present to you my spring collection @titan Quote:
|
Re: N900 will not allow USB OTG!
@blue_led
1. "Initial connection to pc is needed to initialize otg state machine as a peripheral then switch to host by HNP. " Not exactly. The initial connection to PC is used to avoid a problem of changing "suspend"/"resume" modes in HW and SW - the accurate procedure programming without that will take time. The HNP negotiations happens with a target device (HUB, USB stick or hard disk). If you look into /proc/driver/musb_hdrc in a mean time (after writing 'H' and while cable is connected to PC or disconnected but not connected to HUB/disk) then you can see the DEVCTL state like '9b' which means that there is not yet 'HOSTMODE' bit set. Only after you connect to hub/disk then this bit shows 1. And VBUS is needed to prevent dropping session in 1707 while you reconnect cable. Why it is not set while connected to PC? - because HOSTREQ is activated only during transition to suspend mode but while N900 is connected to PC it is still active. And setting that bit while cable is not connected to anywhere doesn't start hostmode after subsequent connection to hub/disk. BTW, this is only intermediate stuff - I am on crash course to find out all potential problems. The real code may use 'FORCE_HOST'. For a moment we need to find out all missed stuff. 2. Charging. I looked into debug output while connect N900 to wall charger. The last message is "musb_stop()". HW effectively is stopped. Yes, specs allows charging while in USB working mode but that is not for high-performance charger. VBUS voltage is not enough - shortcut of D-/D+ is needed to prepare an effective charging. So, I suspect that BME is not fixed after Nokia added 1707 and removed TWL4030 from USB path. 1707 is able to start high-speed charging without software intervention but TWL4030 is not. So, BME just prepared USB subsystem for charging while it is absent and that preparation assumes that there is TWL4030, BQXXXXX chip and it knows nothing about 1707 and it's ability for charging high-speed without software. |
Re: N900 will not allow USB OTG!
we'll see. perhaps the device would not even boot?
but getting host-mode working at all would be a good start, even if conflicts with charging and other USB device functions. I'm just rebuild a kernel... EDIT: build fails with drivers/usb/musb/musb_core.c: In function 'musb_charger_detect': drivers/usb/musb/musb_core.c:244: error: 'struct musb' has no member named 'g' drivers/usb/musb/musb_core.c:245: error: 'struct musb' has no member named 'g' drivers/usb/musb/musb_core.c: In function 'musb_stage0_irq': drivers/usb/musb/musb_core.c:577: warning: unused variable 'r' drivers/usb/musb/musb_core.c: In function 'musb_connect_show': drivers/usb/musb/musb_core.c:1983: error: 'struct musb' has no member named 'softconnect' drivers/usb/musb/musb_core.c: In function 'musb_connect_store': drivers/usb/musb/musb_core.c:2014: error: 'struct musb' has no member named 'softconnect' drivers/usb/musb/musb_core.c: In function 'musb_irq_work': drivers/usb/musb/musb_core.c:2128: warning: unused variable 'old_suspend' drivers/usb/musb/musb_core.c: In function 'musb_init_controller': drivers/usb/musb/musb_core.c:2465: error: 'struct musb' has no member named 'g' drivers/usb/musb/musb_core.c:2466: error: 'struct musb' has no member named 'g' Quote:
|
Re: N900 will not allow USB OTG!
@ egoshin
Quote:
A ( time) ) A-device finishes using bus and stops all bus activity, (i.e. suspends the bus). This is pc doing someting on bus B time ) B-device ( N900 ) detects that bus is idle for more than TB_AIDL_BDIS min and begins HNP by turning off pull-up on D+ (*) . This allows the bus to discharge to the SE0 state so Q :WHo discharge the bus to SE0 state ? A: the two 15k resistors on datalines but when charging is running those resistors are disabled ! right ? and for high power charger detection a source current is applied on D+ ! right ? This curent source prevent switching to HOST by holding D+ high isn't this a heavy & long discussed hardware limitation ? By switching off charger & bme you allow bus discharge and reach nirvana your procedure absolutely have sense for "manual mode" HNP i was able to put state machine in wait to connect with ONLY a resistor of 1.5 k between vbus and D+ and a capacitor of 4.7 uF to ground but there is nobody connection capable ( for evident reason ) hnp fail. i thought to put a pic microcontroller doing hnp sequence on vbus and D+ but i have no time for that. * If the bus was operating in HS mode, the B-device will first enter the full-speed mode Quote:
|
Re: N900 will not allow USB OTG!
Quote:
Either way, as it is now, disabling OTG does more damage than help, as some interesting pieces of code are only built if it is enabled. |
Re: N900 will not allow USB OTG!
wrong post - sorry
|
Re: N900 does now allow USB hostmode!
Quote:
EDIT: USB memory stick, not hard disk. But self-powered hub still responds. |
Re: N900 will not allow USB OTG!
Success!
I just was able to mount USB stick via self-powered HUB and read it. Device - /dev/sda1 Details will be later, but now - modified kernel. I am looking into right modification. BTW, the USB stick problem with VBUS from BQxxxxx seems to be a connector problem - I was able to communicate with it too (USB stick directly connected to N900). |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
I just got a hostmode-only kernel running!
it boots up normally, battery info and USB charging is broken (as expected) WARNING: this is only for experienced developers! do not install as noob http://maemory.com/N900/kernel/hostmode/ you need to replace /etc/event.d/bme with my modified file (make a backup!). In the worst case it ends up in a reboot loop due to bme. you could uncomment the line "cp /etc/event.replace.d/..." in the script to restore the original at the first start. if it fails to boot you would only need to reflash the stock kernel. EDIT: bascially bme dies during boot but booting continues. so no workarounds for bme are needed :) now if I only had my USB F/F adapter here... |
Re: N900 will not allow USB OTG!
Quote:
Quote:
Quote:
So we still struggle to get GENERIC hostmode, not a tricky way to put OTG statemachine into a pathological state by fiddling with VBUS timings, where it detects a drive as another OTG peer. Quote:
cheers jOERG [edit] titan beat me on posting speed ;-) so please excuse if this sounds a bit weird, as I wasn't aware of his previous post when I hit the "reply" button |
Re: N900 will not allow USB OTG!
look into /etc/bme & /etc/event.d/bme.dpkg-new
at the end of bme f* script ! description "starting bme" author "Simo Piiroinen" console output start on started dsme stop on starting shutdown service nice -1 env LOGGER='/usr/bin/logger -s -tBME' env STOP_FLAG=/tmp/bme.was.stopped env SYSFS_VBUS_PATH=/sys/class/i2c-adapter/i2c-1/1-0048/twl4030_usb/vbus env BACKLIGHT_PATH=/sys/class/backlight/acx565akm/brightness pre-start script set +e $LOGGER -pdaemon.notice 'pre-start' EXPORT_CARDS=0 case $(cat /tmp/STATE) in USER) if [ -e /var/lib/ke-recv/usb_phonet_mode ]; then modprobe g_nokia || true initctl emit G_NOKIA_READY else modprobe g_file_storage luns=2 stall=0 removable || true fi ;; ACT_DEAD) modprobe g_file_storage luns=2 stall=0 || true EXPORT_CARDS=1 ;; *) $LOGGER -pdaemon.notice 'skip modprobe g_*' ;; esac DISC='/dev/mmcblk0p1' CARD='/dev/mmcblk1' LUN0='/sys/devices/platform/musb_hdrc/gadget/gadget-lun0/file' LUN1='/sys/devices/platform/musb_hdrc/gadget/gadget-lun1/file' if [ $EXPORT_CARDS -eq 1 ]; then if [ -b $DISC ]; then echo $DISC > $LUN0 || true fi if [ -b $CARD ]; then echo $CARD > $LUN1 || true fi fi if ! /usr/sbin/waitfordsme ; then $LOGGER -pdaemon.crit 'waitfordsme failed' exit 1 fi # check dead battery pre-charge # (or poweroff if battery can't be charged) if [ $(cat $SYSFS_VBUS_PATH) -eq 1 ]; then $LOGGER -pdaemon.notice 'starting battery precharge' # Minimize power usage during pre-charge echo 0 > $BACKLIGHT_PATH # Drive yellow led with device charging pattern to improve UX # Must be done before actually running the "bme-RX-51 -b" - its slow # Clearing LED-state to be sure echo "disabled" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_mode echo "disabled" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_mode echo 0 > /sys/class/leds/lp5523:r/brightness echo 0 > /sys/class/leds/lp5523:g/brightness echo 0 > /sys/class/leds/lp5523:b/brightness # Setting yellow light pattern and running it echo "load" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_mode echo "000001100" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_leds echo "9d804000427f0d7f7f007f0042000000" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_load echo "load" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_mode echo "000000000" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_leds echo "9d800000" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_load echo "run" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_mode echo "run" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_mode echo 20 > /sys/class/leds/lp5523:r/led_current echo 2 > /sys/class/leds/lp5523:g/led_current echo 0 > /sys/class/leds/lp5523:b/led_current /usr/sbin/bme_RX-51 -b case $? in 0) $LOGGER -pdaemon.notice 'precharge -> ok' ;; 2) $LOGGER -pdaemon.crit 'precharge -> power off' # power off request has been sent to dsme # Turn off charging-LED to avoid "ghost charging" when cable removed echo "disabled" > /sys/class/i2c-adapter/i2c-2/2-0032/engine1_mode echo "disabled" > /sys/class/i2c-adapter/i2c-2/2-0032/engine2_mode echo 0 > /sys/class/leds/lp5523:r/brightness echo 0 > /sys/class/leds/lp5523:g/brightness echo 0 > /sys/class/leds/lp5523:b/brightness exit 1 ;; *) $LOGGER -pdaemon.crit 'precharge -> failure' # some mystery failure, continue startup ;; esac fi end script script set +e $LOGGER -pdaemon.notice 'start' exec /usr/sbin/bme_RX-51 end script # create flag file if bme is stopped on purpose (via upstart) pre-stop script set +e $LOGGER -pdaemon.notice 'pre-stop' touch $STOP_FLAG end script # reboot the device if flag file is not present (bme crashed) post-stop script set +e $LOGGER -pdaemon.notice 'post-stop' if [ -e $STOP_FLAG ]; then rm $STOP_FLAG else $LOGGER -pdaemon.crit "crash detected -> rebooting" /usr/sbin/dsmetool --reboot fi end script |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Thanks all of you! I have no idea what anyone is talking about, but it looks like some real progress is being made :)
|
Re: N900 will not allow USB OTG!
Quote:
It's pretty clear bme needs to be started first, if it wants to tear down the device. So if we don't start it in init/upstart it probably won't reboot the kernel. I'm a little unsure though about that (from top): [2010-05-13 16:25:28] <DocScrutinizer> t-tan: [2010-05-13 00:41:14] <DocScrutinizer> PP:hald-runer PID:821 hald-addon-usb-cable: listening on /sys/devices/platform/musb_hdrc/usb1/../mode I.E. we don't know what relies on a working BME and in which way. There's one thing we can be sure though: battery will not explode or otherwise be killed when there's no bme. The bq24150 will wake up to sane safe defaults like max USB current 100mA, max battery charge voltage 3.7V, and it should start charging with these parameters, for at least 32min ("recover from flat battery" scheme). With a little luck (and support from a correctly configured 1707 PHY chip) the bq24150 will detect a dedicated charger (D+/- short) and crank up max USB current to 500mA. But no matter if it starts charging, and at which rate - it never will overcharge the battery unless there's a bme forcing it to do that. So removing / replacing bme is as safe as any other software project, you can do nasty things if you *want*, but they won't happen by accident. A failing or nonexistent bme will NOT cause any hazard. /j |
Re: N900 will not allow USB OTG!
2 Attachment(s)
Quote:
A. You need a modified kernel build from 2.6.28-20100903+0m5. A default kernel configuration arch/arm/configs/rx51_defconfig should be modified: 1 - remove CONFIG_USB_OTG_WHITELIST and CONFIG_USB_OTG_BLACKLIST_HUB options. 2 - Apply an attached patch (u.txt) to kernel sources. 3 - Build a kernel. B. Boot a kernel C. Connect to PC and answer "PC Suite" to mode question. D. echo host >/sys/devices/platform/musb_hdrc/mode You should see in /var/log/syslog a message "twl4030_set_host() after 4030 OTG_CTRL=0x26" - the '2' is a significant. E. echo H >/proc/driver/musb_hdrc F. reattach USB cable from PC to self powered USB hub with memory stick or to external hard disk. E. Look into /var/log/syslog - You can see a lot of messages and two are most valuable - "Initializing USB Mass Storage driver" and " USB Mass Storage support registered". And in between you may see "scsi0 : SCSI emulation for USB Mass Storage devices". F. After some time the scanning finishes and you may execute mount /dev/sda1 /mnt (check /dev/sda1 first!) Viola! If somebody could repeat it - it would be a very good information, I worries about some HW differences or wrong setup of D+/D-. I also attach a copy of my log for reference (a lot of debug output here). Note: ke_recv has some problem with storage recognition and it is a reason why a manual mount is needed. Don't forget to unmount before cable detachment. Or just switch N900 OFF. |
slightly off topic - make N900 charge without bme
first draft for putting bq24150 into fastcharge mode at a reasonable charge end voltage, and keep it in charge mode until battery is full:
Code:
i2cset -y -m 0x77 2 0x6b 0x04 0xc9;Code:
Nokia-N900-02-8:~# ~user/i2c/i2cdump -y -r 0-4 2 0x6bUsual disclaimer: this is addressed to developers only, who exactly understand the above code. ENDUSERS STAY AWAY cheers jOERG |
Re: slightly off topic - make N900 charge without bme
According to the wiki, the reason given for BME being closed source is:
Quote:
Failing that, maybe they would be so kind as to let a few people (egoshin / joerg / etc) have access to the code under an NDA... |
Re: N900 will not allow USB OTG!
sorry for the edits in post 2 above (charging), but while testing I found the registers need another sequence to be set correctly.
anyway now it is at least tested and working for what can be told by watching your shell /j |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
EDIT: I do not enable charge pump, it is impossible (read joerg). But to work as HOST some VBUS voltage is needed (read blue_led) and TWL4030 is an obvious candidate. I don't know - is it possible to use VBUS from 1707 chip (a real USB PHY) because checking it requires too much change in code - driver actively works with 1707 registers and intermixing both is difficult to predict. And of course - the procedure... it is not suitable for normal use because it requires PC initially. I am working on that stuff right now, and first - try to use FORCE_HOST. However, it is not simple as a success experiment, it doesn't see anything at all, so I am looking into code and acquiring logic. BTW, if joerg is successfull in setting VBUS charge voltage and workaround BME intervention it could be a solution for non-selfpowered hubs/HDs. I did an experiment with his command (first version) and it seems it works, at least until DSME shutdowns N900. I stopped do it for now because fast shutdown does too much confusion in results and I can't go far enough until mounting USB stick. |
Re: slightly off topic - make N900 charge without bme
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
And of course without the (even if it's broken) pump and without a host connection it's surely not asserted. Pumping even a measly 3,0 V might mean that the useless-for-charger-detection vbus sense in gaia gets asserted, and the PHY turns on. (Of course the less changes to the driver the better) Quote:
Quote:
|
Re: N900 will not allow USB OTG!
An updated version of the kernel with egoshin's patches and
CONFIG_USB_GPIO_VBUS=m CONFIG_USB_GADGET_DEBUG=y is now available. Quote:
|
Re: N900 will not allow USB OTG!
hi guys!
I've been following you on this thread for quite some time, and recently also in the chatroom. I'm really impressed by your work so far! Keep it going :) I would like to join you in testing, I have a rather good knowledge of linux and also some hardware-level-experience of USB. But I'd still like some advice:
I think that's it for now… Would be great if you could give me some hints :) Btw, it's not important if charging doesn't work, I have a desktop charger. |
Re: N900 will not allow USB OTG!
1) modprobe bq27x00_battery and check /sys/class/power_supply/bq27200-0
3) both are compiled in ls /sys/kernel/debug/usbmon/ 0s 0u 1s 1t 1u 5) always backup and be prepared to reflash :) Quote:
|
Re: N900 will not allow USB OTG!
Quote:
the current exposed by the bq27200 needs multiplied by (20/3.57)mA to get a current. It's a raw value from the chip. the '20' is arguable - but is at least more or less reasonable. This is as the chip really reads out in units of 3.57uV, and the resistor the battery current is applied across is 20mR in the datasheet recommendation. |
Re: N900 will not allow USB OTG!
FYI:
echo 5 > /sys/module/musb_hdrc/parameters/debug enables USB debugging in dmesg! it contains very interesting information incl. line numbers |
Re: N900 will not allow USB OTG!
Using egoshin's idea, I got a DisplayLink device working:
http://depot.javispedro.com/nit/usb/displaylink.jpg This is the same USB monitor shown at the DisplayLink homepage, connected to a N900, in dual screen "clone" mode (more accurately x11vnc, vnc2dl and libdlo, all on the N900). vnc2dl seems to have a 1280x1024 forced resolution. Basically the requirement of connecting the N900 to a host previously is the key. If you play your cards well you don't even need to patch the kernel (Y-cable, or fully self powered bug, etc.). I initially though that this requirement came from a g_mass_storage bug that seemingly also happens on the beagleboard, but I was wrong. Seemingly, DocScrutinizer is right: for some reason after repeating egoshin's steps the N900 seems incapable of closing any USB session, and thus after you unplug it from the host it still believes it's plugged into it, keeping everything powered on. This tricks the driver's OTG state machine into some weirdo state where something starts moving :). Also, with this method you cannot unplug the hub from the N900, as per the above the N900 will keep on thinking it's still connected to it, thus causing mayhem on the kernel. |
Re: N900 will not allow USB OTG!
|
Re: N900 will not allow USB OTG!
I cannot replicate this. btw, it is /proc/driver/musb_hdrc
Quote:
|
Re: N900 will not allow USB OTG!
Quote:
Btw, you might need the patches after all -- seems I had some previous leftover on my N900 (be careful as some settings survive rebooting and reflashing, forcing you to remove the battery). |
Re: N900 will not allow USB OTG!
Quote:
But there is still a possibility that some process like BME or DSME intervenes and creates a problem. BTW, did you see in log a message "twl4030_set_host() after 4030 OTG_CTRL=0x26"? |
Re: N900 will not allow USB OTG!
Quote:
echo peripheral >/sys/devices/platform/musb_hdrc/mode It will cancel VBUS and it immediately stops a session. BUT! It doesn't do the right stuff about DISK - you should unmount it first, especially if it is not ISO9660 format but some Linux file system. |
Re: N900 will not allow USB OTG!
Quote:
|
Re: N900 will not allow USB OTG!
fyi, just found a comparison chart of USB PHY:
http://www.ebv.com/fileadmin/product...sceivers_1.pdf and checked out the isp1704a because of its similarity to the 1707: http://www.stericsson.com/product/222222.jsp It is 100% pin-compatible to the chip in the N900-schematic (which only misses ID and PSW, in comparison to isp1704a, but ID should be present somehow, considering its an OTG chip…) happy reading :) |
| All times are GMT. The time now is 15:09. |
vBulletin® Version 3.8.8