Author: wmb
Date: Thu Feb 25 23:16:34 2010
New Revision: 1759
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1759
Log:
OLPC trac 10022 - Power wait must happen before turning off the EC, otherwise you can't read the AC and battery state.
Modified:
cpu/x86/pc/olpc/keyject.fth
Modified: cpu/x86/pc/olpc/keyject.fth
==============================================================================
--- cpu/x86/pc/olpc/keyject.fth Thu Feb 25 01:54:44 2010 (r1758)
+++ cpu/x86/pc/olpc/keyject.fth Thu Feb 25 23:16:34 2010 (r1759)
@@ -168,7 +168,6 @@
\ Firmware is in flash-buf
: update-firmware ( -- )
- wait-enough-power
write-firmware
['] verify-firmware catch if
@@ -185,6 +184,7 @@
\ Get the new firmware first, so any security checks use the old keys
get-new-firmware
do-keyject? if
+ wait-enough-power
flash-write-enable
inject-keys
new-firmware? if update-firmware then
@@ -194,6 +194,7 @@
\ we get into an infinite reboot cycle.
new-firmware? if
." Updating firmware ..." cr
+ wait-enough-power
flash-write-enable
update-firmware
flash-write-disable \ Should reboot
Author: wmb
Date: Fri Feb 19 00:34:41 2010
New Revision: 1757
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1757
Log:
OLPC trac 10022 - XO 1.0 Keyjector - power state check before bootfw2.zip
Modified:
cpu/x86/pc/olpc/keyject.fth
Modified: cpu/x86/pc/olpc/keyject.fth
==============================================================================
--- cpu/x86/pc/olpc/keyject.fth Thu Feb 18 23:24:50 2010 (r1756)
+++ cpu/x86/pc/olpc/keyject.fth Fri Feb 19 00:34:41 2010 (r1757)
@@ -139,8 +139,36 @@
2drop
;
+: ac-connected? ( -- flag ) bat-status@ h# 10 and 0<> ;
+
+\ Empirically, a weak-but-present battery can present the "trickle charge" (80)
+\ but not present the "present" bit (01).
+: battery-present? ( -- flag ) bat-status@ h# 81 and 0<> ;
+
+\ Similarly, a weak-but-present battery can present the "trickle charge" (80)
+\ but not present the "battery low" bit (04).
+: battery-strong? ( -- flag ) bat-status@ h# 84 and 0= ;
+
+: wait-enough-power ( -- )
+ ac-connected? 0= if
+ ." Please connect the AC adapter to continue..."
+ begin d# 100 ms ac-connected? until
+ cr
+ then
+ battery-present? 0= if
+ ." Please insert a well-charged battery to continue..."
+ begin d# 100 ms battery-present? until
+ cr
+ then
+ battery-strong? 0= if
+ ." The battery is low. Please insert a charged one to continue..."
+ begin d# 100 ms battery-present? battery-strong? and until
+ then
+;
+
\ Firmware is in flash-buf
: update-firmware ( -- )
+ wait-enough-power
write-firmware
['] verify-firmware catch if