Rockbox

  • Status Closed
  • Percent Complete
    100%
  • Task Type Patches
  • Category Battery/Charging
  • Assigned To No-one
  • Operating System Iriver H300 series
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by dohanc - 2006-03-04

FS#4770 - H3x0: New USB Charging Functionality

1.) USB charging for h3x0 by turning on MOSFET in PCF50606 initialization.
2.) USB_inserted also supplies the h300 with power as well as charges it. Before only USB_powered state was known to power/charge device. Added to powermanagement.
3.) Battery symbol in statusbar now animates while charging on USB_inserted. This changed USB_powered to
USB_inserted in statusbar info. *
4.) Added USB Inserted line to Debug Menu –> View Battery menu. This isn’t necessary, just maybe nice to have.

* Note when USB and Power Charger are both plugged in, statusbar symbol will show USB plugged in. It has to show one or the other, and it was easiest to leave it showing USB.

Hopefully we can get the boot loader to boot Rockbox on AC now that this is solved :P Unfortunetly, I am not brave enough to try it without a GDB to reprogram.

Closed by  pondlife
2007-02-01 10:49
Reason for closing:  Accepted
Additional comments about closing:  

Committed. Thanks pyro.

Good job for your patch pyro, thank you!

But I think I found a bug. After I had recharged my player, I plugued it to my computer to transfer some files. So it started to charge normally. I unpluged it and repluged it by holding REC to let it continue to charge without going in USB mode. It stopped charging few minutes later but I had started playing a file in the mainwhile. So when the hard drive started to spin after some time, it started to charge again for few minutes and stopped again. And it do this again and again everytime the hard drive spins.

I don't think it's a good thing for the battery… No ?

I have not tested this while the battery was 100% full. However, I believe this is normal and to be expected. The LX2201 charging IC (hardware charges the H3x0 series, not software) will go into a Voltage Monitoring Mode when the battery has reached 97% of full charge. Above 97% the battery will not charge. You should however see the small USB plug symbol when the battery is above 97% meaning the device is still partially powered from USB. When you run the hard disk the battery probably falls briefly under 97% and starts charging. We are simply reading the status of the hardware charging circuit.

I am curious if the iriver firmware does not do this? If it does not, I'm not sure why or how. I don't believe this is bad for the battery.

In iriver firmware, after a completed charge, the player never start to charge again untill you unplug and plug again the USB or the AC adapter. So after it finish recharging, it only use power from the AC Adapter or USB insteed of using the battery, untill you unplug them.

By the way thanks for the clarification! :-) So if I well uderstood, when it "seems" to start charging again it only read the status of the charging circuit and don't really start to charge again.

Project Manager

You said "In iriver firmware, after a completed charge, the player never start to charge again untill you unplug and plug again the USB or the AC adapter. So after it finish recharging, it only use power from the AC Adapter or USB insteed of using the battery, untill you unplug them."

How do you know this? have you disassembled the iriver firmware?

I'm pretty sure it keeps maintaining the battery charge, just like Rockbox does.

I only said this by what I saw in the original firmware. Obviously I never disassembled the iriver firmware! I just tried to help… So I imagine that the iriver firmware just don't show it.

Project Manager

pyro, I need your real name for the credits.

I wonder why you changed the statusbar code in that way? Is it compatible with the Archos Ondio, which doesn't have rechargeable batteries, but can be powered by USB?

Also, I believe we need to have an option for the USB charging mode, since having it always enabled might cause problems when connecting to an unpowered USB hub.

Real name is Chris Dohan.

I only have basic c knowledge and therefore there very well may be much better ways to program these changes. Let me try to explain my reasoning to see if you agree. in powermgmt.c the charger_input_state (0-No Charger, 1-Charge Unplugged, 2-Charger Plugged, 3-Charger) variable is determined by whether or not the AC/DC charger is plugged in or not. Lostlogic recently submitted and comitted a patch that added an OR statement to this variable. It now read charger_input_state got updated if charger_input_state || usb_powered. What is kind of misleading is that usb_powered mode does not mean the device is powered from USB. It is only active if you hold down the REC button. Regular USB transfer mode is considered usb_inserted and not usb_powered.

The question is whether to have the charger_input_state variable reflect (AC/DC charger || Power from USB) or just AC/DC Charger and have the usb charging modes handled seperatly.

But to directly answer your question, I only changed the usb_powered to usb_inserted in statusbar.c because the device is also charging in usb_inserted mode. The battery symbol would only animate in usb_powered mode before. Again, realize usb_powered is NOT "Powered from USB" but instead the mode when you hold the REC while inserting USB.

I am not 100% sure about if the Ondio will be affected by the change since the code still checks charging_state==CHARGING in which the Ondio should report back it is not charging. I would feel most confortable if someone could test it. I admit I have a hard time trying to distinguish between the different features of all the players.

We can add the option for USB charging mode = On/Off. Perhaps we'll wait to commit until that option is included in this patch? I also wish I could trace the signal from that LX2201 USB Hi/Low pin to maybe a GPIO pin. Lostlogic might be sending me a dead PCB to simply trace signals which would be helpful.

Feel free to change, modify, fix or recommend some other way to do it.

In case anyone cares, I will be away and most likely will not be able to do anything further with this until starting around March 20th.

I would like to add/ask: does this patch affect Firmware USB mode? It would be nice if it could charge the iriver without booting; this would make charging a completely flat iriver via USB possible, something you cant do with the iriver firmware.

As far as I can see this patch should behave like if the charger is plugged in as far as the backlight setting goes, but it does not. backlight stays on all the time when USB is plugged in

Had the last remark the wrong way around.. When USB is in, the non-plugged setting is used instead of the plugged time..

I modified the patch to work with the current CVS..

Project Manager

I believe we need an option for this, otherwise the player will attempt to draw too much power from an unpowered hub.

mmohr commented on 2006-04-02 19:58

I just tested the patch.

It's really good and I wonder why it did not get committed to the CVS???

One thing I noticed: when you set your config to see the battery numerical

in your status bar it still displays it graphical when you charge it via
USB.

Is this on intend or is this a bug?

Project Manager

The reason it isn't committed is that it always charges, and then the USB mode might not work on unpowered hubs, or any other USB host that doesn't give more than 100mA.

Has anyone else noticed how slow RockBox is to charge in comparison to the iriver firmware? It took over 12 hours to charge my player (not being used). Also, USB charge mode does not seem to switch off when the player is eventually full. I checked this by swapping DC input with USB. DC would show 100% and no charge indicator, USB would show 98% and a 1px charge indicator in the graphical display.

mmohr commented on 2006-04-11 10:55

pyro, are you still working on this?

Could you please extend it to make it optional with an extra option to set?

And maybe fix the problem, where it still displays a graphical symbol even
when it's configured to be numerical?

I also noticed something else which I believe it has something to do with
that code.
I had problems with my date/time settings (iRiver H300) which vanishes suddenly.
Now it reappears - and I'm nearly sure it vanishes because I didn't use
this patch and reappeared after I used it again… Please have a look at the (now closed) bug #4906:

http://www.rockbox.org/tracker/task/4906

Jason, I noticed that USB loading takes longer than loading with AC adaptor,
but I'm not sure if it's longer than with the original firmware
- I don't use it anymore :-D

mmohr commented on 2006-04-23 22:17

O.K. I produced a new patch.

This one adds an option (General/System/Battery/Charge During USB connection)
to switch the USB charging during disk mode on or off.
As the originally patch it only works with pcf50606 based devices
(is there any other device beneath iRiver's H3x0?).

Would be nice if some persons could test it -
I put it on my H340 and it seems to work but it's not very well tested… (actually I have no deep knowledge about the low level addresses
and settings and such, so there may be some problems which I don't see).

I also don't know how to add implementation for other targets
(BTW, for which is this useful and possible?)

Any comments are appreciated!

mmohr commented on 2006-04-23 23:16

Warning!
It seems my above patch has a secret problem!

My device hangs at the initial rockbox splash screen
when rebooting after I enabled and saved the settings
for the USB charging!

I have no idea why - maybe somebody else can have a look
at the sources and give me a hint what's going on…

[EDIT - 20060424:] Now it no longer hangs!

I had to reset the settings by clearing them inside 
the old (working) version. Pressing "REC" during
startup made the device hang with "Clearing" message :-(

Anyway - the hanging has nothing to do with the patch!

Works fine here

mmohr commented on 2006-04-24 07:38

Hmm - even an unpatched CVS build does hang my device now :(

Only if I go back to my previous version which is based on
a 20060418 CVS and includes a lot patches does work.

I'm not sure what's going on, but it seems it has nothing to do with the USB patch… (I already cleared my settings and deleted the tagcache files
- nothing helped…)

[EDIT: 20060424] Hanging is no longer a problem (see above)

try my latest experimental build, www.paulgeluid.nl/rockbox/rb-exp-2.4.17.zip .. it contains your patch and I have had no problems with it

mmohr commented on 2006-04-24 12:07

Here is an updated patch which removes some codelines from another patch
which accident found their way into this…

I didn't change any functionality!

It appears the patch does not function, no matter what setting you try, the 'power inserted' icons comes on, but no charging. original patch is fine..

mmohr commented on 2006-05-02 15:17

Here is a new version of the patch.
It changes two things:

  1. it makes sure, the IRQ is correctly set (thanks to amiconn for this)
  2. and it does (currently) not directly read the PCF50606 register,

this should fix the problem with wrong detection…

So please try it again and tell me if it works now!

mmohr commented on 2006-05-02 16:07

Another update - now it should really fix the above issue.
It also adds some more entries to the "Info/Debug/View Battery"
and to the "Info/Debug/View I/O ports" screens.
(just for debugging purposes)

Appears to work now..

Hi all!
With the new changes in the cvs, is this patch still necessary? The code was heavily reorganized, so patching the last version of the h300-usb-charge patch doesn't work, even trying to fix the rejects seems to be be non trivial.
Thanks a lot and all the best
Norbert

mmohr commented on 2006-06-11 14:33

Here is an updated patch for today's CVS And yes, it's still needed - USB charging is not enabled in official CVS!

dfpp commented on 2006-06-23 14:08

Is it possible with this patch to disable the USB connect mode in some way or have an option? I'd rather it to go into charge mode when usb is connected rather than connect mode by default as I often connect it to a USB charging device but it thinks its a PC and goes to connect mode. I know you can hold down rec to disable the connect but my preference would to have an option to disable USB connect mode entirely by default as USB power is often taken on and off (From a car usb charger)

mmohr commented on 2006-07-30 13:14

dwayne: I added an additional patch where you can choose
how the button press during plugging in your USB chord works.
Look at " FS#5744  — Button press for USB connection or USB power only" for further information.
(this one not only works for H300 devices, it should work for
alls devices which support USB power)

Unfortunately that patch overlapps in some lines with
this patch here, so if you try to include both, you'll
get patch failures :-(

Here is another patch which combines both patches:

dfpp commented on 2006-08-02 11:25

Good work, works extremely well!

USB charging works great for me.

One small thing that I noticed. Appart from the battery icon there is little feedback indicating it is charging. I'll make a feature request for this as it is not just for USB charging.

Anyway, thanks for the patch :-)

Works great, can we please have this added to CVS so we can have it included in the CVS or daily builds? Thanks!

mmohr commented on 2006-09-10 16:25

Well, I really don't know why this doesn't gets committed.
Ask Linus or some other core dev politely for inclusion…

BTW, if somebody can give me information which pins/levels are
used for the iAudio X5 I could add it as well
- but currently I miss that (and I don't own such a device ;)

Project Manager

I'll have a look at it ASAP. I'm a little busy with Real Life ™ at the moment. The X5 is totally different when it comes to charging, so this patch only applies to the H300.

dfpp commented on 2006-09-19 13:02

This is working quite well for me, but was also wondering if theres a way for this to disable it at USB bootloader level as well. When I apply power via usb from power off it would be great to not go to USB bootloader mode and directly to resuming audio playback.

That would be a good replacement for the DC charge port boot loader functionality… any takers? Would allow for a nice car mode startup/shutdown via DC.

mmohr commented on 2006-10-15 10:05

@dfpp: yes, it would be nice to also have it for the bootlader;
but I'm unable to do it (at least I fear to brick my device when trying ;)
→ some core dev should do it!

Here's another sync for today's CVS

Umpf, firmware/drivers/pcf50606.c is gone, can you please resync the patches. Thanks a lot!

Bye, Norbert

mmohr commented on 2006-10-28 21:25

Another sync for today's CVS… (I hope it will last a bit longer than the last one…)

mmohr commented on 2006-10-28 21:44

Sorry, the last patches had a small mistake.
Now (hopefully) fixed…

Unfortunately not that long…
In firmware/target/coldfire/iriver/h300/pcf50606-h300.c
+#include "logf.h"
+
+static bool usb_ch_enabled = false;

Fails because another include was added but this is an easy fix. The button press patch fails in many places which is to much for me to figure out.

It works very well thanks again for the patch :-)

mmohr commented on 2007-01-22 22:48

Sorry - I forgot to resync it :-( Here's the sync to today's repository…

And I _REALLY_ hope that it finally got included in the SVN -
or that someone tells me what's wrong with the patch.
I'm really bored to always resync it (for nine months now)…

Hi Matthias,

I've been testing the first patch on my H340 with a view to committing it. It seems that even with a fairly flat battery (e.g. reported at 40%), the USB current drain doesn't exceed 100mA. I know very little about the innards, but was expecting 500mA to be drawn. If this can be resolved or explained, I'll commit it.

I've resynced it to the new settings code and attached here.

mmohr commented on 2007-01-24 17:04

Hi Steve,

it would really be great if this patch finally got committed!

Actually, I only set the GPOOD2 to High-Z for USB charging at the PCF50606
and set it back to pulled down for disabling USB charging.
Everything else is done by the hardware…

Did you do tests with USB charging when using the original firmware?
If the original firmware is able to charge it better, we miss something :-(

Hi Matthias,

I'm only using Windows 2000 Device Manager to read current draw, but I'm not convinced it's telling the truth! I get the following figures:
Rockbox, USB Charging ON - 100mA
Rockbox, USB Charging OFF - 100mA
RetailOS, USB Charging ON - no connection is made, no figure available
RetailOS, USB Charging OFF - 100mA

Perhaps there is some better software available, or maybe some kind soul can put a meter in series and report back here (hint!).

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing