maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   N900 will not allow USB OTG! (https://talk.maemo.org/showthread.php?t=31921)

joerg_rw 2010-05-14 12:56

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;
# next register 0x03 is device ID, always 4b and r/o; so we skip to 0x04
i2cset -y -m 0xff 2 0x6b 0x02 0x8c;
# 0x8c = 3v5 + .640 + .040 + .020 = 4V200, BE CAREFUL and DON'T CHANGE
# unless you know what you're doing. 4V2 is ABS MAX!
i2cset -y -m 0xff 2 0x6b 0x01 0xc8;
i2cset -y -m 0xc0 2 0x6b 0x00 0x00;

# tickle watchdog, while status indicates 'charging from wallcharger'
while [ $(i2cget -y 2 0x6b 0x00) = 0x90 ] ; do
  sleep 28;
  # reset watchdog timer:
  i2cset -y -m 0x80 2 0x6b 0x00 0x80;
done
echo "charging finished, status(reg0)=$(i2cget -y 2 0x6b 0x00)"

above code not yet tested, but should result in

Code:

Nokia-N900-02-8:~# ~user/i2c/i2cdump -y -r 0-4 2 0x6b
No size specified (using byte-data access)
    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 90 c8 8c 4b c9                                    ???K?

which is what bme sets bq24150 to, during normal charge process

Usual disclaimer: this is addressed to developers only, who exactly understand the above code. ENDUSERS STAY AWAY


cheers
jOERG

cb22 2010-05-14 13:09

Re: slightly off topic - make N900 charge without bme
 
According to the wiki, the reason given for BME being closed source is:
Quote:

bme - Battery Management Entity: Security. A misuse of the could lead to serious battery damages that could result in liabilities for Nokia. hald-addon-bme is a related package, also closed.
Maybe a well written comment on the existing open source request for it (https://bugs.maemo.org/show_bug.cgi?id=9314) with info about what's been happening in this thread could help.

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...

joerg_rw 2010-05-14 13:20

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

javispedro 2010-05-14 14:02

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by egoshin (Post 657866)
...

So basically there's NO changes other than enabling the charge pump? Dang it, so my supposed self-powered hub is a not as selfpowered as I though...

egoshin 2010-05-14 16:24

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by javispedro (Post 658368)
So basically there's NO changes other than enabling the charge pump? Dang it, so my supposed self-powered hub is a not as selfpowered as I though...

Yet another changes to avoid whitelist and blacklist problems.

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.

egoshin 2010-05-14 16:39

Re: slightly off topic - make N900 charge without bme
 
Quote:

Originally Posted by joerg_rw (Post 658278)
first draft for putting bq24150 into fastcharge mode at a reasonable charge end voltage, and keep it in charge mode until battery is full:

Joerg, double check - is this code a replacement of BME which is supposed to be stopped by earlier published script?

javispedro 2010-05-14 17:41

Re: N900 will not allow USB OTG!
 
Quote:

Originally Posted by egoshin (Post 658557)
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)

That's my issue here, I though you don't need vbus at all for certain devices. In fact I'm not still sure about this. I know that the driver as is disables the PHY when gaia's vbus sense is not asserted -- you must have seen this.
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:

Originally Posted by egoshin (Post 658557)
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.

You mention that you need to select PC Suite mode. Does it work with USB STorage Mode? If it works only with PC Suite mode, I think it might have to do with g_mass_storage (weird suspicion). rmmod it and modprobe g_zero before switching to host.

Quote:

Originally Posted by egoshin (Post 658557)
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.

DSME reboots can be entirely disabled via a /etc file. The issue iirc is the rest of watchdogs, and even those can be disabled by a r&d flag.

titan 2010-05-15 15:30

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:

Originally Posted by titan (Post 654575)
I have build a special version of the power-user kernel with USB debugging and verbose enumeration enabled, and the USB blacklist+whitelist disabled.
Modules for all common USB device classes are already included (for USB/IP).
I hope it can help you to get USB hostmode working on the N900.

download and install in this order
http://maemory.com/N900/kernel/testi...mo28_armel.deb
http://maemory.com/N900/kernel/testi...mo28_armel.deb
http://maemory.com/N900/kernel/testi...mo28_armel.deb
the kernel configuration is http://maemory.com/N900/kernel/testi...ower_defconfig

good luck!


hcm 2010-05-15 17:37

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:
  • What would you recommend for checking the device health during testing, i.e. battery voltage/current(in/out)/temperature, VBUS level, etc. What are some interesting procfs/sysfs files to monitor?
  • Are there any important I2C registers to monitor? From the bq24150 (0x6b) or other I2C devices?
  • To which degree is debugfs and usbmon working in titans new kernel? Any (special) setup needed? (except mounting debugfs and modprobing usbmon)
  • Are there datasheets for the TWL4030 and the 1707 (could only find one for TPS65950 which is apparently similar (?) to the TWL)
  • And finally: do you know a (working) way to save/restore the whole filesystem in case anything goes wrong? :rolleyes:

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.

titan 2010-05-15 18:23

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:

Originally Posted by hcm (Post 659843)
  • What would you recommend for checking the device health during testing, i.e. battery voltage/current(in/out)/temperature, VBUS level, etc. What are some interesting procfs/sysfs files to monitor?
  • Are there any important I2C registers to monitor? From the bq24150 (0x6b) or other I2C devices?
  • To which degree is debugfs and usbmon working in titans new kernel? Any (special) setup needed? (except mounting debugfs and modprobing usbmon)
  • Are there datasheets for the TWL4030 and the 1707 (could only find one for TPS65950 which is apparently similar (?) to the TWL)
  • And finally: do you know a (working) way to save/restore the whole filesystem in case anything goes wrong? :rolleyes:



All times are GMT. The time now is 23:23.

vBulletin® Version 3.8.8