[Nook Color Android Development] MedLine:
PBD REPORT FORM

TEST CONFIGURATION:

BOOT DEVICE: eMMC

MLO: BN 1.2 stock

U-BOOT: BN 1.2 from Nightly 86

KERNEL: uImage 2.6.32.9 from Nightly 86

OVERCLOCKED?: to 1200/300

GOVERNOR: Conservative

SYSTEM: CM7 Nightly 86

PBD: NO

TEST COUNT: 3x

TRIED REVERTING TO OLDER HC/CM7: YES

TRIED WIPING CACHE/DATA?: NO

DID IT WORK? YES

PREVIOUSLY INSTALLED:

☐ Stock 1.0

☑ Stock 1.1

☐ Stock 1.2

☐ Nookie Froyo (any)

☐ Honeycomb (any)

☑ CM7 2.29 (any)

☑ CM7 2.32 beta 3

☑ CM7 nightlies > 84 (or whenever .32 appeared)

NOTES: I don't have an explanation for PBD, but I've done some testing today and maybe can offer some useful observations. I had PBD as described here, which resolved after round-tripping through an SD installation of CM7 beta 3 as described here and here, reminiscent of what others had reported booting through HC, and it has not recurred since. Here are my observations:

1. Technically, if you didn't drain to a reported battery level < 1%, you've had a PBD. That means most everybody who has posted here so far. This is because AFAIK, there are only 2 parameters for graceful low-power shutdown: battery level = 0%, and battery temperature > 68C. These are defined in "frameworks/base/services/java/com/android/server/BatteryService.java", viewed here at CM7 github. Basically you're getting PBD because battery level calibration is off and the Nook never reports a 0%. Even if your Nook died at 3% or 4%, it's still a PBD.

For illustration, I've ran down my battery twice today, with Battery Monitor Widget reports posted at pastebin here and here, showing that I reached 0% (< 1%) at 3250mV and 3400mV. Importantly, rather than abrupt shutdown I got a "Power Off" warning dialog. This was accompanied by a logcat posted here that looked like a normal shutdown sequence. Some salient features from the logcat, obtained by issuing in terminal "logcat > /mnt/sdcard/logcat.txt" before shutdown and retrieved at reboot, are as follows:

I/ActivityManager( 1043): Starting: Intent { act=android.intent.action.ACTION_REQUEST_SHUTDOWN flg=0x10000000 cmp=android/com.android.server.ShutdownActivity (has extras) } from pid 1043
I/ShutdownActivity( 1043): onCreate(): confirm=false
D/ShutdownThread( 1043): Notifying thread to start radio shutdown
I/ShutdownThread( 1043): Sending shutdown broadcast...
I/ShutdownThread( 1043): Shutting down activity manager...
I/UsageStats( 1043): Writing usage stats before shutdown...
W/BatteryStats( 1043): Writing battery stats before shutdown...
I/ShutdownThread( 1043): Radio and Bluetooth shutdown complete.
I/ShutdownThread( 1043): Shutting down MountService

2. If you didn't get this shutdown sequence and died at ~3000mV, does that mean that your Nook died fully discharged? I think so. To test this I removed the "shutdownIfNoPower" function from BatteryServices.java and recompiled CM7 from source as per the wiki, syncing the repo up to "settings: Updated Italian translations" and flashed to verygreen 1.2.1 SD. I ran down the battery and the Battery Monitor Widget report is posted here. I hit 0% at ~3350mV but, with no shutdownIfNoPower call, it kept going and didn't shut down until 6 minutes later at ~3050mV, abruptly and with no warning. Logcat, posted here, was similar to what sinanju had reported, stopping in the middle of garbage collection with no prior shutdown intent. To me this suggests that my Nook lost all battery power and just died at ~3050mV.

3. In summary, I think PBD is widespread and looks to involve BN1.2 stock (all of you going that workaround route and shutting down at 4%) as well as CM7 (phiremod as well as 2.6.32). This is if you consider anything other than drain to a reported level of 0% and graceful shutdown a PBD, which we should, because that's how Android low-power shutdown was coded.

THEORY: Obviously there's a problem in translation between voltage and current drain with calculated battery level, but in my research I've come up against a blank wall. This is an area that looks exceptionally well undocumented. I'm sure the CM7 devs will come up with a solution, but in the meantime I think everybody who gets PBD is shutting down with a fully discharged battery. This may not be desirable, and difficult to avoid when it hits unexpectedly at 20-30%. An immediate workaround is to add a function to shutdown for low voltage, ala what this fellow suggested here. I've tested one implementation of this by modifying the BatteryServices.java file, as shown posted here, and recompiled CM7 from source and flashed to SD. Basically I added the following:

private final void shutdownIfLowVoltage() {
// shut down gracefully if our battery voltage is critically low and we are not powered.
// wait until the system has booted before attempting to display the shutdown dialog.
if (mBatteryVoltage < 3500 && !isPowered() && ActivityManagerNative.isSystemReady()) {
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);

A battery rundown with this custom CM7 build showed that graceful shutdown occurred after the voltage dropped to < 3500 mV, as intended, with battery level still 7%. Battery Monitor Widget report and logcat posted here and here. In existing installs, I think a modified /system/framework/sevices.jar file can achieve the same thing. Something like this should allow everybody to at least gracefully shutdown before complete battery discharge. In practice, a shutdown threshold of 3200mV might be more reasonable.

hth