Commit Graph

7310 Commits

Author SHA1 Message Date
Vadim Bendebury
e7ebdfeefc g: cr50: update INFO1 mask when corrupting the second image
The INFO1 mask field contents serves as input for the rollback
protection mechanism, when the RO decides if an RW is allowed to run
on the device.

The existing code updates INFO1 mask to match the lowest rollback
priority of the two images (RW_A and RW_B) present on the device.

INFO1 mask should be also updated when the current image is endorsed
by the host. In this case the alternative RW is destroyed, so the
INFO1 mask could be set based solely on the currently running image.

This patch refactors the code to allow setting INFO1 mask based on one
or both RW headers' contents.

BRANCH=cr50
BUG=b:62138152

TEST=verified that "normal" INFO1 mask updates still work as before,
     the mask is modified to match the image with the lowest rollback
     priority.

     Also verified that when the VENDOR_CC_INVALIDATE_INACTIVE_RW
     command is received the INFO1 mask is updated based on the
     currently running image.

Change-Id: I23172388674e1f3a4c2489e139dd197a84029f54
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/541738
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-21 18:48:05 -07:00
Prathmesh Prabhu
c6a8c03ac9 Add fizz-no-vmtest-pre-cq to the pre-cq set
Because ec is used by the fizz board

BUG=chromium:734783
TEST='cbuildbot --remote fizz-no-vmtest-pre-cq' passes
BRANCH=None

Change-Id: Ib3f7cf5b798e805ed197c79999ff6fc61b07f561
Reviewed-on: https://chromium-review.googlesource.com/540287
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
2017-06-21 20:05:02 +00:00
Divagar Mohandass
9fb10386a7 Poppy: Configure camera PMIC to low power mode.
This change will configure camera PMIC to low power mode
in S3 and S0ix sleep state and resumes it in S0 state.

BUG=b:62779726
BRANCH=None
TEST=`Build/Flash EC and verify the PP3300_DX_CAM signal is
toggling during S3/S0ix cycle.`

Change-Id: I9f376762100ac9b208df4a39160e4acd3b7b925e
Signed-off-by: Divagar Mohandass <divagar.mohandass@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/539316
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-21 04:19:06 -07:00
Shawn Nematbakhsh
0cf4ec5bae rwsig: Fix mapped read location for rwsig / pubkey
Mapped reads are relative to CONFIG_EC_*_STORAGE_OFF, not
CONFIG_R*_MEM_OFF. The previous implementation happened to work for
internal mapped storage (eg. stm32) but failed for external mapped
storage which is copied to SRAM before execution (eg. npcx).

BUG=b:62841029
TEST=Verify sysjump works again on eve/poppy/soraka. Verify sysjump
and sig verification continues to work on fizz and stm32.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Id51ce5697555eea38b246b58dbf47f22d4befaa7
Reviewed-on: https://chromium-review.googlesource.com/541861
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-21 01:03:00 -07:00
Wei-Ning Huang
7eae5a320f stm32f4: clock stm32f412 at 96MHz
On stm32f412, AHB prescaler must be 1 in order for stm32f412 to be
clocked at greater than 50MHz. APBX prescaler must be 2 so the clocks
can be in the right range.  When APBX prescaler != 1, it results in 2x
timer clocks on both APB1 and APB2. We added a new
clock_get_timer_freq() function for stm32 to get timer specific clock
frequency so we can return 2x timer clocks when APBX != 1.

Flash latencies also need to be changed when we clock at 96MHz, the
FLASH_ACR_LATENCY defines are moved into the variant-specific switches
so each board can defined latency when setting CPU clocks.

BUG=b:38077127
TEST=`make BOARD=rose -j`, touch performance improved by 2x.

Change-Id: Ieb211ad80c168d3f57e72a8d16b954b703ee1444
Reviewed-on: https://chromium-review.googlesource.com/539375
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-06-21 01:02:59 -07:00
Caveh Jalali
053cb4bb24 ps8751: assert reset for at least 1ms.
the 1ms reset hold time isn't in the ps8751 datasheets (yet), but
that's what our parade support contact recommended.  i'm applying this
fix to reef (electro) and coral as these two boards were missing any
sort of reset hold time.  other boards using the ps8751 seem to
already have a 1ms or 10ms delay.

TEST=rebuilt, reload EC image on electro... no ill effects noted.

BUG=b:62642003
BRANCH=reef

Change-Id: I39a989375e789118d062f82e9baaa041e5e6b033
Signed-off-by: Caveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/540742
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-20 17:24:17 -07:00
Marius Schilder
cd6c3a0fef g: remove obsolete dcrypto_init definition
No boards are referencing old dcrypto_init at this point; all have
moved to dcrypto_init_and_lock

BUG=none
BRANCH=cr50
TEST=buildall

Change-Id: I04c96608c5459470d87e67046912ca7c02e6332a
Reviewed-on: https://chromium-review.googlesource.com/540779
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-20 15:28:49 -07:00
Wei-Ning Huang
5f523464bb stm32: flash: enable data and instruction cache properly
The flash controller of STM32F4 and STM32L4 supports data and
instruction caching. Enable them properly.

BRANCH=none
BUG=b:38077127
TEST=on rose,
      > rw 0x40023c00
      read 0x40023c00 = 0x00000701

     Touch process loop is 5% faster.

Change-Id: Ibb28c0ed0c6a293547d5f0f7c6962f36fa417dd3
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/497230
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-20 04:12:14 -07:00
Duncan Laurie
ced1b4f90a ec_commands: Fix portability issues
Recent changes broke the portability of this header file.

Fix the ACPI guards so it can be used in coreboot.

BUG=b:36024430
BRANCH=none
TEST=make -j buildall (as usual many haven boards fail)

Change-Id: I0d737e7aad7ead90289b43db09352092ef7e3e98
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/539135
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-06-20 02:31:49 -07:00
Nicolas Boichat
1442cbdebb hammer: Adjust trackpad dimensions
BRANCH=none
BUG=b:35582031
TEST=Flash and boot hammer, no more trackpad dimension mismatch error.

Change-Id: If4bd9db456617a52d1890543e7cae34a563122dd
Reviewed-on: https://chromium-review.googlesource.com/523502
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-19 21:03:33 -07:00
Daisuke Nojiri
cdaca7c97e Add system_can_boot_ap API
This API checks battery charge level and current power supply
to determine whether the AP has enough power to boot or not.

BUG=b:38462249
BRANCH=none
TEST=make buildall

Change-Id: I489f7ea92f230701b8f18c94d3e698aad90b4a03
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/517272
2017-06-19 21:03:30 -07:00
Daisuke Nojiri
5ce3d32538 Fizz: Verify and jump to RW image
BUG=b:37316498
BRANCH=none
TEST=Boot Fizz

Change-Id: Iaceb64bcf5d54145c26e86ce62a14d5732a22e78
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/517406
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-19 21:03:30 -07:00
Daisuke Nojiri
627f3a8ac2 KBL/SKL: Add wait between DSW_PWROK and PWRBTN
This patch adds wait between DSW_PWROK and PWRBTN assert. It is
required to be 95 msec or longer for Kaby Lake and Sky Lake.
Refer to the timing diagram for G3 to S0 on Sky Lake or Kaby Lake
platform design guide for details.

BUG=b:62584658
BRANCH=none
TEST=On Fizz, measured time between DSW_PWROK high and PWRBTN assert
for 1:AC plug-in, 2:recovery+power press, 3: reboot ec command.

Change-Id: I89a14ac9a49e20a332bd662d90be62f8ea23b003
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/534901
2017-06-19 21:03:29 -07:00
Mary Ruthven
1a09831d0f g: upgrade_fw: limit updates after a hard reset
Reject updates for the first 60 seconds after a hard reboot. This should
prevent people from using the reboot at the end of an update to get
around the update rate limiting. Reboots don't happen during normal cr50
operation, so this should not prevent updates. It will just prevent
updating cr50 many times in a row.

This change does not limit updates after deep sleep or POR.

BUG=b:62097097
BRANCH=cr50
TEST=Try to update cr50 two times. Verify that on the second time the
update is rejected. Put cr50 into deep sleep, wake it up and verify it
can be updated immediately. Get cr50 to do a POR and verify it can be
updated immediately.

Change-Id: I828ef210e1c5bcf59d4753b8178ee4e1369d5d36
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520727
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-19 15:33:13 -07:00
Shawn Nematbakhsh
8a16e6483a task: Wait for HOOK_INIT completion before scheduling tasks
Until HOOK_INIT has completed, do not allow any tasks other than HOOKS
or IDLE to be scheduled. Programmers often make the assumption that
a HOOK_INIT function is guaranteed to be run before task code that depends
on it, so let's make it so.

BUG=chromium:649398
BRANCH=None
TEST=Manual on kevin, compare boot without patch:

...
[0.004 power state 0 = G3, in 0x0008] <-- from chipset task
RTC: 0x00000000 (0.00 s)
[0.004 power state 4 = G3->S5, in 0x0008]
RTC: 0x00000000 (0.00 s)
[0.005 clear MKBP fifo]
[0.006 clear MKBP fifo]
[0.006 KB init state: ... <-- from keyscan task
[0.012 SW 0x05]
[0.155 hash start 0x00020000 0x00019a38]
[0.158 HOOK_INIT DONE!]

... to boot with patch:

...
RTC: 0x58cc614c (1489789260.00 s)
[0.004 clear MKBP fifo]
[0.005 clear MKBP fifo]
[0.010 SW 0x05]
[0.155 hash start 0x00020000 0x000198e0]
[0.157 HOOK_INIT DONE!]
...

Also, verify kevin boots to OS and is generally functional through
sysjump and basic tasks, and verify elm (stm32f0 / cortex-m0) boots.

Change-Id: If56fab05ce9b9650feb93c5cfc2d084aa281e622
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/456628
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-19 15:33:10 -07:00
Shawn Nematbakhsh
90167c1764 math_util: Use HW instruction for int_sqrtf when available
Cortex-M4 supports a floating point square root function that takes 14
cycles to execute, which is a speed improvement over the existing binary
search, and saves flash space.

BUG=chromium:687624
BRANCH=None
TEST=On kevin, verify that both sqrtf methods (binary search vs HW
instruction) have identical results for fractional input (eg.
sqrt(15.999999) = 3), except when floating point representation of
square root rounds up to an integer. Verify identical results for all
integers [-100, 16793602). Note that 16793602 is the first integer for
which the floating point representation of sqrt rounds up to an integer.
Also verify basic motion sense functions on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8521c9a28c958b340ca83c37342253e424df0c91
Reviewed-on: https://chromium-review.googlesource.com/537734
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-06-19 15:33:09 -07:00
Daisuke Nojiri
0696dd1e68 eCTS: Refactor return code handling
This patch adds host only return codes to cts.rc and derive names
from there.

BUG=chromium:664309
BRANCH=none
TEST=cts.py -m task, interrupt, gpio
        test name                         TH            DUT
	debug_test                      SUCCESS       SUCCESS
	success_test                    SUCCESS       SUCCESS
	fail_dut_test                   SUCCESS       FAILURE
	fail_th_test                    FAILURE       SUCCESS
	fail_both_test                  FAILURE       FAILURE
	bad_sync_and_success_test      BAD_SYNC      BAD_SYNC
	bad_sync_both_test             BAD_SYNC      BAD_SYNC
	bad_sync_failure_test           FAILURE      BAD_SYNC
	hang_test                       SUCCESS     NO_RESULT
	post_corruption_success       NO_RESULT     NO_RESULT

Change-Id: I169b2466646d6236571a8a4c5d3e208d928b9dd2
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410282
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-17 01:12:42 -07:00
Vadim Bendebury
12fd77967f cr50: handle board ID mismatch gracefully
If Cr50 happens to start on a chip where Board ID programmed in INFO1
does not match the contents of the RW header, it means that for some
reason the other RW is not operational and the current image is the
only viable one.

In this case the Cr50 starts but operates in limited mode (only
commands for updating the image and reporting state are handled). In
this case the reason for recovery could be seen on the Recovery
screen, and the update could be done once Chrome OS boots in recovery
mode.

BRANCH=none
BUG=b:35586335
TEST=verified the following:
  - if an image with wrong board ID is started, it tries to fall back
    (sets the counter to a value above threshold and reboots)

  - if the fallback fails, the image keeps running in the limited
    capabilities mode but the update is possible, observed that the
    new image took over worked after powercycling the device.

  - observed proper error message on the recovery screen showing where
    the error comes from

Change-Id: I46ba75392f8e891bb8503fb15aea2c56b5805e83
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/535978
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-16 21:10:54 -07:00
Daisuke Nojiri
3bb2d756e5 eCTS: Limit tty reads by boot counts
Currently, read_tty reads characters from tty as long as there
is something to read. This causes read_tty to loop forever if the board
is in reboot loop.

This patch makes cts.py stop reading tty if boot count exceeds
max_boot_count. Reboot is detected by detecting REBOOT_MARKER.

This patch also does:
- Remove debug option: This adds complexity for no real value. Developers
should debug tests using regular tools (make, uart console, etc.).
- Remove html output. Nobody use it. Should be redone when it's needed
using proper libraries.

BUG=chromium:664309
BRANCH=none
TEST=cts.py -m task/gpio/interrupt

Change-Id: I51d1dd51c4097e8115ef04ad46853720295141b4
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/410281
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-16 21:10:54 -07:00
Daisuke Nojiri
3e4d3fd712 eCTS: Hide expected messages
This patch hides expected messages from output to the terminal
and reorganizes log directory as follows:

- All test output goes under /tmp/ects/$dut/$module
- Openocd output is recorded in openocd.log
- uart outputs are recorded in uart_th.log and uart_dut.log
- build output is recorded in build.log
- Check exit code from all subprocess calls
- Dump build log if build fails
- Dump openocd log if openocd fails

BUG=chromium:664309
BRANCH=none
TEST=cts.py --setup and build images in chroot then run cts.py -m meta
outside chroot.

Change-Id: I13294c3bf777ad7ae590459d3cf5aea405d59f96
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/409536
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-16 21:10:54 -07:00
Nick Sanders
fd528684dd mn50: fix usb_update
Add support for update related vendor commands in mn50 by relocating
relevant code from board/cr50 to chip/g.

BUG=b:36910757
BRANCH=None
TEST=./extra/usb_updater/usb_updater -d 18d1:502a build/mn50/ec.bin

Change-Id: Iec0fe5585b5b6eb099f9254dfb0e5b02d5106abc
Reviewed-on: https://chromium-review.googlesource.com/537999
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-16 17:24:28 -07:00
Scott Collyer
28167cbc26 eve: Make sure both LEDs are updated when charger is connected
When an external charger is connected, only the LED on the side the
charger is connected should be on, the other side should be off. The
existing LED behavior was incorrect in that only the side that was
charging was being updated and the other side would remain in its
previous state.

This CL adds a fix so that if only one LED is being controlled, the
other side is always turned off. In addition, the logic for double tap
events was changed slightly so that if a double tap event is in
progress and a charger is connected, the new state will be updated as
soon as the charge state is changed instead of waiting for the double
tap event to complete.

BUG=b:62481906
BRANCH=eve
TEST=Manual With battery level < 15% so that both LEDs are red when
the charger isn't connected, connect charger and verified that the LED
on the side the charger is connected turns white and the LED on the
other side turns off.

Change-Id: I7462629409496383adb43445e732dd6ca2f9f589
Signed-off-by: Scott Collyer <scollyer@google.com>
Reviewed-on: https://chromium-review.googlesource.com/537960
Commit-Ready: Scott Collyer <scollyer@chromium.org>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
2017-06-16 17:24:27 -07:00
Bernie Thompson
deeb0ac7de Use celes-pre-cq instead of strago-pre-cq
The stago build is not well kept after, as it is not used in production,
celes however is.

BUG=chromium:734103
TEST=None

Change-Id: Ie62a4729192fe63d18348f47105a2585c9e4f5be
Reviewed-on: https://chromium-review.googlesource.com/538571
Commit-Ready: Bernie Thompson <bhthompson@chromium.org>
Tested-by: Bernie Thompson <bhthompson@chromium.org>
Reviewed-by: Yixiang Li <yixiang@google.com>
2017-06-16 17:24:25 -07:00
Vadim Bendebury
023a1cb2b3 cr50: prepare to release version 0.0.21
BRANCH=cr50
BUG=None
TEST=built an image, observed version number.

Change-Id: I2717530abb92383e1d0260580bed81e00f4f21bb
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/538162
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2017-06-16 17:09:36 +00:00
CHLin
ee089e62a7 npcx: i2c: change i2c settings for better timing.
The setup time of original i2c setting which i2c freq is 1MHz is closed
to the margin of the spec. This CL improves the setup time with a new
setting. (For example, in npcx evb, measured setup time now is about
480 ns.)
This CL also removes the timing settings of higher i2c source clock
frequencies which are not used so far to save the code size.

BRANCH=none
BUG=b:38217035
TEST=No build error for make buildall; run stress test with i2cxfer and
i2cscan on gru with 400K and 1MHz i2c freq.

Change-Id: I5428a7dab1d935fd428ee9012604813e752cead8
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/527739
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-06-15 23:54:02 -07:00
Shawn Nematbakhsh
89b8ff1cba cleanup: motion_sense: Remove driver data structure externs
Driver data structs are now accessed through the drv_data pointer.

BUG=chromium:733352
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I8fedb425708a08ae6900ade6f17967fe2bc75ebf
Reviewed-on: https://chromium-review.googlesource.com/537217
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-15 23:54:00 -07:00
Furquan Shaikh
7651e32a95 power/skylake: Ensure panic data is backed up before PMIC reset
On PMIC reset, VCC power rail goes down thus resulting in loss of
panic data. Thus, provide a chance to the chip to backup panic data if
available.

BUG=b:62076222
BRANCH=None
TEST=make -j buildall

1. > crash divzero
   > panic
   === PROCESS EXCEPTION: 06 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :00000001 r5 :00000000 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :
   Divide by 0
   mmfs = 2000000, shcsr = 0, hfsr = 0, dfsr = 0

2. > crash assert
   > panic
   === PROCESS EXCEPTION: 00 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :dead6663 r5 :000000a4 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :

   mmfs = 0, shcsr = 0, hfsr = 0, dfsr = 0

3. > crash watchdog
   > panic
   === PROCESS EXCEPTION: 3c ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :dead6664 r5 :0000000a r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :

   mmfs = 0, shcsr = 0, hfsr = 0, dfsr = 0

4. > crash unaligned
   > panic
   === PROCESS EXCEPTION: 06 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :200c0d9e r5 :00000000 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :
   Unaligned
   mmfs = 1000000, shcsr = 0, hfsr = 0, dfsr = 0

Change-Id: Ife5c9bbc12dcf6c4922f18b7530b21a3b87e65b3
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530138
2017-06-15 20:13:56 -07:00
Marius Schilder
0153e43f7f g: broaden dcrypto mutex safety
Holding the mutex just around the dcrypto_call is not enough: dcrypto
instruction memory content might change in presence of multiple calling
tasks.

Switching to broad acquire/release pattern instead.

Note to sub-projects: pair your dcrypto_init(_and_lock) w/ matching dcrypto_unlock

BUG=none
BRANCH=cr50
TEST=tcg_tests pass

Change-Id: Idb7f2d79ce533db95cab51d89e3869ecf9f3d499
Reviewed-on: https://chromium-review.googlesource.com/535916
Commit-Ready: Marius Schilder <mschilder@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Nadim Taha <ntaha@chromium.org>
2017-06-15 20:13:53 -07:00
Vadim Bendebury
c54375df26 cr50: check for board ID match at startup
When starting up the Cr50 should check if this image is supposed to
run on a chip with the board ID value read from INFO1.

If it is not supposed to run on this chip, and there is no rollback
counter overflow, set the rollback counter to a value which will
trigger a rollback and reboot.

If rollback counter has already exceeded the threshold - set a flag
indicating that the image is running in the "mismatch" mode and
continue.

BRANCH=cr50
BUG=b:35586335
TEST=with the rest of the patches applied verified both falling back
      to an older image and continuing running with the flag set if
      rollback is not possible.

Change-Id: I58d97de61dc446aaf1dd06b6e2b6bb426c14a172
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/535977
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-15 20:13:51 -07:00
Vadim Bendebury
4af07d9b00 g: provide an API to set rollback counter to ensure rollback
with the board ID match happening in the RW we need to be able to set
the rollback counter to a value which would guarantee a fallback
during the next boot.

BRANCH=cr50
BUG=b:35586335
TEST=with the rest of the patches verified the ability to set the
     counter to trigger a fallback on the next reboot.

Change-Id: I161f39354e5523121e26e8ad84a791a8b06e5123
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/535976
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-15 20:13:51 -07:00
Vadim Bendebury
dcca1de528 g: add a function to report current board ID mismatch status
Until the Board ID check is moved to RO, it is possible to start an RW
with a mismatching Board ID.

Let's add a function to check for mismatch and report the status.

Also eliminating the unnecessary check for empty header Board ID field
- it is going to match any board ID anyways and fixing a CPRINTF
statement in read_board_id().

BRANCH=cr50
BUG=b:35586335
TEST=verified that empty board ID header does not trigger a mismatch
     on a board with a non-empty INFO1. With the rest of the patches
     applied verified that board ID mismatch is reported properly.

Change-Id: Ie03f8137e494117b7a238e3af72527e0a46369e1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/535975
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-15 20:13:51 -07:00
Furquan Shaikh
94a9cfc02f eve/fizz/poppy: Enable panic backup/restore
BUG=b:62076222
BRANCH=None
TEST=make -j buildall

Change-Id: Id1482cc959233b41b0d917e8650866651d9a61fe
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530137
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 17:27:53 -07:00
Furquan Shaikh
98b58b5b69 chip/npcx: Add support for saving/restoring panic data
For some platforms like poppy/eve where a PMIC reset is required on
reboot/panic to ensure a complete power-cycle of the AP, there is a
drop on VCC power rail thus resulting in a loss of panic data. For
such cases, provide API to backup panic data in BBRAM before
performing a PMIC reset. Additionally, check for panic data in
system_pre_init and restore if available from BBRAM.

BUG=b:62076222
BRANCH=None
TEST=make -j buildall

1. > crash divzero
   > panic
   === PROCESS EXCEPTION: 06 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :00000001 r5 :00000000 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :
   Divide by 0
   mmfs = 2000000, shcsr = 0, hfsr = 0, dfsr = 0

2. > crash assert
   > panic
   === PROCESS EXCEPTION: 00 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :dead6663 r5 :000000a4 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :

   mmfs = 0, shcsr = 0, hfsr = 0, dfsr = 0

3. > crash watchdog
   > panic
   === PROCESS EXCEPTION: 3c ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :dead6664 r5 :0000000a r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :

   mmfs = 0, shcsr = 0, hfsr = 0, dfsr = 0

4. > crash unaligned
   > panic
   === PROCESS EXCEPTION: 06 ====== xPSR: ffffffff ===
   r0 :         r1 :         r2 :         r3 :
   r4 :200c0d9e r5 :00000000 r6 :00000000 r7 :00000000
   r8 :00000000 r9 :00000000 r10:00000000 r11:00000000
   r12:         sp :00000000 lr :         pc :
   Unaligned
   mmfs = 1000000, shcsr = 0, hfsr = 0, dfsr = 0

Change-Id: I95cdd55e260487903e089653a47d3995d177daed
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530136
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-15 17:27:53 -07:00
Furquan Shaikh
7e59da99a2 panic: Provide declarations for chip panic data backup/restore
Provide APIs that allow chips to implement their own version of
backing up/restoring panic data to persistent storage.

BUG=b:62076222
BRANCH=None
TEST=make -j buildall

Change-Id: Idda2d55703d4fe7e0a8d6305695fbf4e193b596b
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530196
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 15:17:17 -07:00
Shawn Nematbakhsh
520f1aff77 coral: Remove unused / unassigned variables
Defects reported by Coverity.

BUG=None
BRANCH=None
TEST=`make buildall -j`

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I083ef9e499076f7009717ccbe0a3ab0a055e1bed
Reviewed-on: https://chromium-review.googlesource.com/535836
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
2017-06-15 15:17:15 -07:00
Shamile Khan
fcf7edff8c poppy: Enable ship mode on rev1.
rev1 (Soraka) was using proto settings. Instead use the settings described
in fuel gauge specification.

BRANCH=none
BUG=b:62552007
TEST=On soraka, check that the system goes to ship mode and no error
     messages appear, using "ectool batterycutoff" from OS or "cutoff"
     from EC console.

Change-Id: I04e6b08265d20395d13e28e93cb14c1d49b376df
Signed-off-by: Shamile Khan <shamile.khan@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/531736
Reviewed-by: Vijay Hiremath <vijay.p.hiremath@intel.corp-partner.google.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 15:17:14 -07:00
Vincent Palatin
16683c3c1e cr50: update U2F transport to usb-internal
In the FIDO U2F Authenticator Transports Extension, the list of
transports will be extended to:
FIDOU2FTransports ::= BIT STRING {
  bluetoothRadio(0), -- Bluetooth Classic
  bluetoothLowEnergyRadio(1),
  uSB(2),
  nFC(3),
  uSBInternal(4)
}
Given our implementation is internal, update the value from bit(2) uSB
to bit(4) uSBInternal.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve
and manually verify the individual attestation certificate
with an ASN.1 parser.

Change-Id: I62fe72ffed9b7eb34e31164fded46f458e5cbc16
Reviewed-on: https://chromium-review.googlesource.com/536775
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-15 13:24:29 -07:00
Vincent Palatin
5dcff8b079 g: add chip unique id generation
Implement system_get_chip_unique_id() for the g hardware.
It includes the hardware revision, the chip device id and
the read-only key id.
The key-id is included because this unique id is used as serial number
inside certificates and for security reason, we want a different id if
the RO has changed (e.g Node locked firmware).
The id is also 32-byte long for convenience reason when used for
certificates, but the high 16 bytes are currently zeros.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=cr50
BUG=b:35545754
TEST=dump the x.509 individual attestation certificate which includes
the unique id as serial number.

Change-Id: If24597d0de696d2700122d425724f14703fc5256
Reviewed-on: https://chromium-review.googlesource.com/536774
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-15 13:24:29 -07:00
Nicolas Boichat
a9364ca5d4 hammer: Add support for base pairing
x25519 requires quite a bit more stack size (1696/2048), so
increase its size.

BRANCH=none
BUG=b:38486828
TEST=Flash hammer, ./usb_updater2 -c always reports the same
     device public key, and authenticator is correct.

Change-Id: I51dff9f10167d654561ef7f199b9b9206511b7e9
Reviewed-on: https://chromium-review.googlesource.com/532476
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-15 09:37:57 -07:00
Nicolas Boichat
77e7913b69 usb_update: Add handler for pairing challenge command
Handle UPDATE_EXTRA_CMD_PAIR_CHALLENGE command, where the
lid sends a random x25519 public key, and nonce, and the base
replies with its own (stable) x25519 public key, and computes
a shared secret using its private key to verify its identity.

BRANCH=none
BUG=b:38486828
TEST=Flash hammer, ./usb_updater2 -c always reports the same
     device public key, and authenticator is correct.

Change-Id: Ida60ffa7476794ee92669951c740dbe35950fb9c
Reviewed-on: https://chromium-review.googlesource.com/532475
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-15 07:07:40 -07:00
Wei-Han Chen
7bfbedc266 flash_ec: fix for SERVO_TYPE=toad
In CL:503475, SERVO_TYPE is initialized *after* toad cable detection.
This make flash_ec failed to update plankton EC.
This CL adjust the timing of SERVO_TYPE detection, so toad cable
detection can work properly.

BUG=b:35648297
BRANCH=plankton
TEST=utils/flash_ec --board=plankton

Change-Id: I08a11b99109454096949b3ff64ed1c4d5f9891df
Reviewed-on: https://chromium-review.googlesource.com/535381
Commit-Ready: Wei-Han Chen <stimim@chromium.org>
Tested-by: Wei-Han Chen <stimim@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-15 04:39:31 -07:00
Furquan Shaikh
c860bc15c5 poppy: Add LED support for sysrq debug mode
BUG=b:37970194,b:36394093
BRANCH=None
TEST=Verified that LED blinks when in debug mode and stops blinking on
exit from debug mode.

Change-Id: I536d0eeffdc59bef940ea1f0f01d7c595320d9c4
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/529766
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 04:39:31 -07:00
Furquan Shaikh
5ed0e0f76f button: Implement emulated debug mode using buttons for detachables
BUG=b:36394093
BRANCH=None
TEST=make -j buildall. Verified following actions:
Vup+Vdn (10 seconds) --> Vdn --> Vup : Warm reset AP
Vup+Vdn (10 seconds) --> Vdn -> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vdn : Restart chrome
Vup+Vdn (10 seconds) --> Vup --> Power : Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vdn : No action defined
Vup+Vdn (10 seconds) --> Vup --> Vup --> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vdn : Kernel panic
Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Power: Exit debug state

Vup+Vdn (10 seconds) --> Vup --> Vup --> Vup --> Vup: Exit debug state
Vup+Vdn (10 seconds) --> Vdn --> Vdn : Exit debug state

Change-Id: Ic49cc7463f6d8a00f3b4586754feeb3a7d23c371
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/520564
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-15 01:48:26 -07:00
Carl Hamilton
60ce79badd Allow dcrypto_call() to be invoked from any task.
Before this change, the current task id was cached in dcrypto_init() if
it hadn't already been called. This resulted in the task id of the first
caller to dcrypto_init() being cached until reset.

The cached task id was used when generating notifications that hardware
crypto operations were complete. This was fine as long as the task that
invoked dcrypto_init() was also the task that invoked dcrypto_call(). If
this wasn't the case, the task that invoked dcrypto_init() would be
notified of an event it wasn't expecting and the task that invoked
dcrypto_call() would not be notified and would time out.

This change locks a mutex and then caches the current task id in
dcrypto_call() before invoking the hardware operation so that the
correct task will be notified when the operation has completed.

BRANCH=none
BUG=none
TEST=make -j buildall

Change-Id: I30a920d85359cc990d77c88b1607bbe4cf674206
Reviewed-on: https://chromium-review.googlesource.com/522350
Commit-Ready: Carl Hamilton <carlh@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Tested-by: Carl Hamilton <carlh@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-14 10:19:19 -07:00
Nicolas Boichat
c5b31e3868 sha256: add support for hmac_sha256, and add test for sha256
BRANCH=none
BUG=b:38486828
TEST=make run-sha256
TEST=make buildall -j

Change-Id: I4c5b5d81ae5650ebfbdc989a0d860eeb0a60f68b
Reviewed-on: https://chromium-review.googlesource.com/530207
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-14 05:59:37 -07:00
Furquan Shaikh
98dc270b23 power_button_x86: Save and restore power button pulse setting
This change ensures that the power button pulse setting is saved and
restored across a sysjump. It uses the SYSJUMP_TAG "PB" (0x5042).

BUG=b:62445190
BRANCH=None
TEST=The condition mentioned in the bug could be reproduced using
following steps:
1. reboot on EC console
2. Use Vup/Vdn to select any option other than Power off.
3. Press power button

After step #3 above, device would shut down instead of selecting the
option. Verified that with this change, the device does not power off
anymore at step #3.

Change-Id: Icebe9c17d39a82fc3854dd75cc3a1dea032a234a
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/533921
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-14 01:19:33 -07:00
Nicolas Boichat
b9b431557e rollback: Add function to fetch secret
BRANCH=none
BUG=b:38486828
TEST=Flash hammer

Change-Id: I50088a78e75d6ea8d62e439fdc8bf18d46319462
Reviewed-on: https://chromium-review.googlesource.com/532474
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-14 01:19:31 -07:00
Nicolas Boichat
43391ca415 poppy: Increase base debounce time to 20ms
From our testing, 5ms seems a little short: 20ms is probably better.

BRANCH=none
BUG=b:62393957
BUG=b:35586668
TEST=Test that base is always detected.

Change-Id: I8d0041fc387568cfa0983584ca1d68711c70d9cf
Reviewed-on: https://chromium-review.googlesource.com/535214
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-06-14 01:19:31 -07:00
Philip Chen
9f37e4a655 scarlet: Turn on CONFIG_TABLET_MODE_SWITCH
BUG=b:62594071
BRANCH=scarlet
TEST=boot scarlet and confirm it's in tablet mode

Change-Id: I85cc53bb66d70acc9f5c77bd7c428447159dabb0
Reviewed-on: https://chromium-review.googlesource.com/534937
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-13 23:30:11 -07:00
Marius Schilder
03036903f2 cr50: accelerated sha512 option
Provides ~5.7x speedup (per console cmd sha512_bench).
Controlled by CONFIG_DCRYPTO_SHA512

TEST=console cmd sha512_test
BRANCH=none

Change-Id: Ibd0b6e8b5283a947d858905124b4221c63ac621f
Reviewed-on: https://chromium-review.googlesource.com/525056
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
Commit-Queue: Marius Schilder <mschilder@chromium.org>
Trybot-Ready: Marius Schilder <mschilder@chromium.org>
2017-06-14 04:34:31 +00:00