Go Back   maemo.org - Talk > Devices > Nokia N900
 
Register FAQ Community Calendar Today's Posts Search

Closed Thread
 
Thread Tools
  #861  
Old 2010-05-14, 12:56
joerg_rw's Avatar
joerg_rw joerg_rw is offline
 
Join Date: Mar 2010
Location: SOL 3
Posts: 2,222
Thanks!: 3,399
Thanked 12,651 Times in 1,970 Posts
Default 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

Last edited by joerg_rw; 2010-05-14 at 13:13.
The Following 18 Users Say Thank You to joerg_rw For This Useful Post:
  #862  
Old 2010-05-14, 13:09
cb22 cb22 is offline
 
Join Date: Jan 2010
Location: Cape town
Posts: 82
Thanks!: 32
Thanked 214 Times in 51 Posts
Default 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...
The Following 2 Users Say Thank You to cb22 For This Useful Post:
  #863  
Old 2010-05-14, 13:20
joerg_rw's Avatar
joerg_rw joerg_rw is offline
 
Join Date: Mar 2010
Location: SOL 3
Posts: 2,222
Thanks!: 3,399
Thanked 12,651 Times in 1,970 Posts
Default 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
  #864  
Old 2010-05-14, 14:02
javispedro's Avatar
javispedro javispedro is offline
 
Join Date: Jan 2009
Location: Barcelona
Posts: 2,355
Thanks!: 2,145
Thanked 5,249 Times in 1,344 Posts
Default Re: N900 will not allow USB OTG!

Quote:
Originally Posted by egoshin View Post
...
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...
The Following User Says Thank You to javispedro For This Useful Post:
  #865  
Old 2010-05-14, 16:24
egoshin egoshin is offline
 
Join Date: Dec 2009
Location: California
Posts: 992
Thanks!: 389
Thanked 995 Times in 404 Posts
Default Re: N900 will not allow USB OTG!

Quote:
Originally Posted by javispedro View Post
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.

Last edited by egoshin; 2010-05-14 at 16:49. Reason: syntax
The Following User Says Thank You to egoshin For This Useful Post:
  #866  
Old 2010-05-14, 16:39
egoshin egoshin is offline
 
Join Date: Dec 2009
Location: California
Posts: 992
Thanks!: 389
Thanked 995 Times in 404 Posts
Default Re: slightly off topic - make N900 charge without bme

Quote:
Originally Posted by joerg_rw View Post
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?
The Following User Says Thank You to egoshin For This Useful Post:
  #867  
Old 2010-05-14, 17:41
javispedro's Avatar
javispedro javispedro is offline
 
Join Date: Jan 2009
Location: Barcelona
Posts: 2,355
Thanks!: 2,145
Thanked 5,249 Times in 1,344 Posts
Default Re: N900 will not allow USB OTG!

Quote:
Originally Posted by egoshin View Post
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 View Post
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 View Post
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.
The Following 2 Users Say Thank You to javispedro For This Useful Post:
  #868  
Old 2010-05-15, 15:30
titan titan is offline
 
Join Date: Oct 2009
Location: Germany
Posts: 946
Thanks!: 216
Thanked 1,650 Times in 417 Posts
Default 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 View Post
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!
The Following 7 Users Say Thank You to titan For This Useful Post:
  #869  
Old 2010-05-15, 17:37
hcm hcm is offline
 
Join Date: Jan 2010
Location: Germany
Posts: 75
Thanks!: 26
Thanked 78 Times in 32 Posts
Default 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?

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.
  #870  
Old 2010-05-15, 18:23
titan titan is offline
 
Join Date: Oct 2009
Location: Germany
Posts: 946
Thanks!: 216
Thanked 1,650 Times in 417 Posts
Default 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 View Post
  • 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?
The Following 3 Users Say Thank You to titan For This Useful Post:
Closed Thread

Tags
awesomeness in the works, boulevard of broken deals, host, i am the dealbreaker, inspector gadget lies, mobidapter is a scam, nokia fanbois, otg, over 9000, usb, usbcontrol


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 19:57.