Commit Graph

2178 Commits

Author SHA1 Message Date
Shawn Nematbakhsh
d483c289a9 npcx: gpio: Clear GPIO interrupt if no ISR is available
If we have no ISR for an enabled GPIO interrupt (eg. for a UART GPIO
interrupt that wakes from low-power idle) then clear it, to avoid
interrupt storm.

BUG=b:63958831
BRANCH=eve
TEST=Verify we can repeatedly wake from low-power idle on eve by hitting
'enter' on the EC console.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I6a01cae33e3bf1a3b5b42c0389c4613dc1cb9b7d
Reviewed-on: https://chromium-review.googlesource.com/584011
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Duncan Laurie <dlaurie@google.com>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2017-07-25 14:04:08 -07:00
Nick Sanders
9e1e58b62a sweetberry: allow larger sense resistors
Currently sweetberry hits an integer truncation issue
at 2.4 ohm when uA per div goes below 1. We can use 100ths
of a uA as the current per div scale.

BRANCH=None
BUG=chromium:608039
TEST=log from sweetberry with 10 ohm config.

Signed-off-by: Nick Sanders <nsanders@chromium.org>

Change-Id: I9e9216230329483fd0bfcb44ce23cd15bae864b3
Reviewed-on: https://chromium-review.googlesource.com/577051
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2017-07-24 22:54:04 -07:00
Shawn Nematbakhsh
94896eaae6 g: hwtimer: Improve accuracy of hwtimer and ensure minimum udelay() wait
hwtimer ticks at 8 * 32768 Hz rather than 250 KHz, so adjust our timing
appropriately. Also ensure that udelay() will delay for at least the
requested time, taking into account our timer precision.

BUG=b:63858553
TEST=Generate square wave with 1000us udelay between GPIO edge toggle,
verify period is 1000us + code overhead. Also verify timer behavior on
overflow with 'forcetime' command. Also verify accuracy of system clock
to 0.2% with `timerinfo` and a stopwatch.
BRANCH=None

Change-Id: I5da41bd7250db87de5143cc54ebd0bb750fb7003
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/578551
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-07-21 21:24:12 -07:00
Gwendal Grignou
4e3970529b stm32f4: Set unique ID properly
Unique device ID register (96 bits) is at a different place on STM32F4
compared to other STM32.

BUG=none
BRANCH=none
TEST=Using board_read_serial() from hammer/board.c in
sweetberry/board.c, confirmed that we can extract and assign a unique
USB serial number.

Change-Id: Idb257f0f20422482c729a2b97b4b16ee231ca4d9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/579575
Commit-Ready: Gwendal Grignou <gwendal@google.com>
Tested-by: Gwendal Grignou <gwendal@google.com>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-20 16:41:25 -07:00
Wei-Ning Huang
412093d046 stm32: gpio: implement gpio_disable_interrupt
gpio_disable_interrupt is missing for stm32, add it so board functions
can use it.

BRANCH=none
BUG=b:63685022
TEST=`make BOARD=rose -j`

Change-Id: Ibbdd8506540e7949fa110c26131dca028671be06
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/573981
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2017-07-17 07:21:48 -07:00
CHLin
c721060be1 npcx: Add support for chip variant npcx7m6g
This CL adds CHIP_VARIANT_NPCX7M6G to support another npcx7 ec SKU.

Please note that the default setting in npcx7_evb is npcx7m6f.
For the EVB using the 128-pins EC package, please change CHIP_VARIANT
from npcx7m6f to npcx7m6g in build.mk.

BRANCH=none
BUG=none
TEST=No build errors for make buildall; Set CHIP_VARIANT=npcx7m6g in
board/npcx7_evb/build.mk; Build the image and test on EVB.

Change-Id: I2f857e4f6524eab45930bac3cc209409d4a53ee8
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/569320
Commit-Ready: Jun Lin <riverq@gmail.com>
Tested-by: Jun Lin <riverq@gmail.com>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
2017-07-16 08:14:53 -07:00
Daisuke Nojiri
34fed775b6 npcx: Build RW_B and support sysjump to it
This patch allows a board to include another RW image in ec.bin.
The size of each copy is a quarter of the flash size on Fizz.

BUG=b:38462249
BRANCH=none
CQ-DEPEND=CL:568297
TEST=Run sysjump RW/A/B. Verify there is no size change by running
make savesizes/newsizes. Run objdump -h build/fizz/ec.obj:

Idx Name          Size      VMA       LMA       File off  Algn
  0 .image.RO     0001700c  10088000  10088000  00008000  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .image.RO.key 00000340  1009f00c  100a7c40  0001f00c  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .image.RW     00016ddc  1009f34c  100c8000  0001f34c  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, CODE
  3 .image.RW.sign 000001b8  100b6128  100e7c00  00036128  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .image.RW_B   00016ddc  100b62e0  100e8000  000362e0  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, CODE
  5 .image.RW_B.sign 000001b8  100cd0bc  10107c00  0004d0bc  2**0
		  CONTENTS, ALLOC, LOAD, READONLY, DATA
  6 .padding      00000001  100cd274  10107fff  0004d274  2**0
		  CONTENTS, ALLOC, LOAD, DATA
  7 .ARM.attributes 00000014  00000000  00000000  0004d275  2**0
		  CONTENTS, READONLY

Change-Id: Iaa687c1d7d704fec4cccfa127376c8db102267fa
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/557305
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-13 19:45:57 -07:00
Nick Sanders
1106dea40d servo_micro: add parity setting
Add a control interface to set parity
for USB-UART bridge.

BRANCH=None
BUG=b:37513705
TEST=parity settable on command line or by servod

Signed-off-by: Nick Sanders <nsanders@chromium.org>
Change-Id: Ib859a70981162be58edfa79c7cb267e0084e05e6
Reviewed-on: https://chromium-review.googlesource.com/564150
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-13 17:30:40 -07:00
Nicolas Boichat
5e6f9a2b38 chip/stm32/i2c-stm32f0: Adjust 400kHz setting (48Mhz clock source)
STM32 I2C frequency can be computed as such:
tSCL = tSYNC1 + tSYNC2 + { [(SCLH+1) + (SCLL+1)] x
          (PRESC+1) x tI2CCLK }

The default values we use come from the datasheet, which assume,
for 400 kHz setting, that tSYNC1 + tSYNC2 = 750 ns, and therefore
set tSCLH as 500 ns and tSCLL as 1250ns.

On hammer, we measured a total tSCL of ~2150 ns (465 kHz) with
these settings, so we can easily slow it down to ~2500 ns (400 kHz)
by increasing tSCLH to 750 ns (SCLH = 0x5).

As highlighted in 48b2edf031
"stm32f0/i2c: adjust the 100kHz setting to never go above 100kHz"
this has the disadvantage of slowing down other boards where
the RC value on the I2C bus are different, but slowing down should
always be safe, and is the best we can do without adding config
defines for the fall/rise time.

BRANCH=none
BUG=b:36172041
TEST=Flash hammer, measure SCL frequency to be about 400 kHz

Change-Id: Ia2cac9fb09228abd8a318d57335855be529485c2
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/563219
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-10 11:22:35 -07:00
Nicolas Boichat
241e7e3a01 chip/stm32/flash-f: Clear option byte write enable/erase operation when done
Before
72afc55bd9 "stm32: cleanup flash-f by using constant from register.h"
lock() function would simply do:
STM32_FLASH_CR = FLASH_CR_LOCK;

which would clear all other bits in STM32_FLASH_CR, including
FLASH_CR_OPTER and FLASH_CR_OPTWRE.

This allow preserve_optb to work, as it does:
 1. erase_optb
   a. unlock()
   b. Set FLASH_CR_OPTER
   c. lock() (clears FLASH_CR_OPTER!)
 2. write_optb
   a. unlock()
   b. Set FLASH_CR_OPTPG
   c. Write option byte
   d. Clear FLASH_CR_OPTPG
   e. lock()

After the patch, we now have:
STM32_FLASH_CR |= FLASH_CR_LOCK;
which seems more correct. However, 1.c. does not clear FLASH_CR_OPTER,
and 2.b. ends up with both FLASH_CR_OPTPG and FLASH_CR_OPTER set,
and the programming operation does not do anything.

This patches does 3 things:
 - Rename FLASH_CR_OPTSTRT to FLASH_CR_OPTER, as that's the correct
   register name for STM32F0 and STM32F3.
 - Fix the above by clearing FLASH_CR_OPTER in erase_optb
 - Also clear FLASH_CR_OPTWRE in lock(). Not strictly necessary,
   but this seems to be the right thing to do.

BRANCH=none
BUG=chromium:739608
TEST=On hammer, type flashwp true; reboot; flashwp all; reboot
     flashinfo => All flash is protected

Change-Id: Ic276545ae3c0bdb685c7b117a7f896ec341731bb
Reviewed-on: https://chromium-review.googlesource.com/562839
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-07 02:40:03 -07:00
Marius Schilder
bdd39d51a3 g: RSA randomization
Split bn_modexp() into three variants:
bn_modexp() for large exponents (as before)
bn_modexp_word() for single word public exponents
bn_modexp_blinded() for large exponents w/ randomization

We randomize bn_modexp_blinded() with:
1) pick 64 bit random R1 and compute R1 ** -1 and R1 ** pubexp, mod N.
2) multiply input by R1 ** pubexp
3) pick 64 bit random R2 and add (e*d*R2 - R2) to private exponent (i.e.
a random multiple of phi(N))
4) exponentiate
5) multiply output w/ R1 ** -1 to obtain expected result

Since we enlarge the exponent, bn_modexp_blinded() is slower than
bn_modexp(). We only use bn_modexp_blinded() when private exponents are
in play and we have phi(N) available.

Also refactored the combined p256 and rsa dcrypto binary blob into two
parts. And added unique first word to each dcrypto blob to make code
caching reliable.

The TPM task stack maxes out at 8040/8192 in tcg_test due to increased
stack usage of bn_modexp_blinded() but is still within safe bounds,
with 88 byte redzone.

BRANCH=cr50
BUG=b:35587382,b:35587381
TEST=buildall, tcg_test (200+)

Change-Id: Ied1f908418f31f8025363179537aa4ebd2c80420
Reviewed-on: https://chromium-review.googlesource.com/540684
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Marius Schilder <mschilder@chromium.org>
2017-07-06 21:53:35 +00:00
Nicolas Boichat
a58f5545c6 chip/stm32/flash-f: Fix incorrect WP computation
PSTATE is already included in WP_BANK_OFFSET + WP_BANK_COUNT,
so this change is not only unnecessary, but also harmful.

BRANCH=none
BUG=chromium:739608
TEST=Flash hammer, flashwp true; reboot; flashinfo
     => RO is protected

Change-Id: I31048c0156eff354fbcc6ae5828a6ef313b56b97
Reviewed-on: https://chromium-review.googlesource.com/561037
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-06 05:00:28 -07:00
Nicolas Boichat
c869b0f15c chip/stm32/registers.h: Fix STM32_FLASH_OPT_LOCKED polarity
We currently set STM32_FLASH_OPT_LOCKED
to (STM32_FLASH_CR & FLASH_CR_OPTWRE), however the bit is set
when option byte are _unlocked_.

From STM32F0 Reference Manual:

Bit 9 OPTWRE: Option byte write enable
  When set, the option byte can be programmed. This bit is set
  on writing the correct key sequence to the FLASH_OPTKEYR register.
  This bit can be reset by software

BRANCH=none
BUG=chromium:739608
TEST=Flash hammer, flashwp true; reboot; flashinfo
     => hammer does not hang on reboot, RO is protected

Change-Id: I1b6eb5d638534ece90d6d5164586f49bdb0c151d
Reviewed-on: https://chromium-review.googlesource.com/561036
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-06 05:00:28 -07:00
Vincent Palatin
9f59c3df75 g: mitigate deep-sleep abortions when using USB
After entering prepare_to_sleep() and doing interrupt_disable(), if an
interrupt happens, it will stay pending (as the handler is masked).
Then, when calling 'wfi' in __idle(), we will go through the instruction
rather than entering deep-sleep (if requested) as we have a pending
interrupt.
The downside of this corner case is that we never undo the actions done
to prepare for deep-sleep in the IDLE_DEEP_SLEEP clause of
prepare_to_sleep(). For USB suspend, this means that on the subsequent
deep-sleep entry, we are going to try to save GR_USB_CFG/the USB
device address while the USB controller is already in reset/power-down,
recording a null value in SCRATCH18. Then, at resume time, we will
restore 0 in USB_CFG and the USB device will no longer work.
As the USB configuration is difficult to restore in case of deep-sleep
abortion, simply skip writing a bogus value in SCRATCH18 on the real
deep-sleep entry happening afterwards. This is good enough to resume
properly on USB.

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

BRANCH=cr50
BUG=b:38160821
TEST=manual: add a (long) panic_printf trace in prepare_to_sleep() in
order to dramatically increase the probability of getting an
interruption pending after entering the function. On cr52, trigger USB
suspends by suspending the host, and see we no longer regularly get a
null USB device address at USB resume.

Change-Id: Ied3fc003eefe7fc164a320b15b5f9d400551198e
Reviewed-on: https://chromium-review.googlesource.com/559332
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Marius Schilder <mschilder@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-07-05 16:45:33 -07:00
Nicolas Boichat
e3336f4c8d chip/stm32/pwm: Prevent sleeping while PWM output is active
STM32F0 cannot keep PWM output active when chip is in deep sleep.

The only other board that uses both CONFIG_LOW_POWER_IDLE
and CONFIG_PWM on stm32 is jerry, and this logic should also apply
to it.

Also, switch using_pwm from array to bitmask to simplify handling.

BRANCH=none
BUG=b:36173380
TEST=On AP, tell it to autosuspend hammer:
     echo auto > /sys/bus/usb/devices/1-2/power/control
     Then see, using idlestats, that hammer does to deep sleep.
     In hammer console: pwm 0 50, see that PWM output is stable,
     idlestats shows EC does not sleep.
     In hammer console: pwm 0 -1, idlestats shows EC sleeps again.

Change-Id: Ic74c1905364fe4335239da95a99193d0e3e979f7
Reviewed-on: https://chromium-review.googlesource.com/541115
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-07-04 06:51:01 -07:00
CHLin
5e5788f3ca npcx: Clear IBBR to have BBRAM back to be functional
In the CL:505861, we print the warnning message to indicate that the VBAT
has ever dropped if the IBBR bit is set but do not clear the IBBR. This
forbid the access to BBRAM until EC power-on reset.
In this CL, we clear the IBBR bit to make BBRAM work again without the
need of EC power-on reset.

BRANCH=none
BUG=none
TEST=No build error for make buildall; Check warining messages are
printed and IBBR bit is cleared.

Change-Id: I58a0370c1c496b3c1208d9d5ac6b55c4d66fe8b6
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/542976
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-06-29 22:01:15 -07:00
Dino Li
dc53959997 tcpm: it83xx: Use pd common code macro to analyze message header
Use existed macro instead of creating new one.

BRANCH=none
BUG=none
TEST=plug USB-C power adapter and USB-C to hdmi adapter, both work.

Change-Id: I133142232ac6abfa7f285c289eb03c4d65e84d5f
Signed-off-by: Dino Li <Dino.Li@ite.com.tw>
Reviewed-on: https://chromium-review.googlesource.com/554655
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-29 22:01:13 -07:00
Daisuke Nojiri
031dccad78 vboot_ec:Read try slot from BBRAM
This patch makes EC read the slot to verify and jump to from the
battery backed up RAM (BBRAM).

BUG=b:38462249
BRANCH=none
TEST=Boot Fizz

Change-Id: I0c78861ea3ccdc45d0aa08e690e3a68f53658409
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/518255
2017-06-28 23:23:41 -07:00
Daisuke Nojiri
3a4298ef48 npcx: Make system stay off after clean shutdown
This patch sets/clears RESET_FLAG_AP_OFF on S5<->S3 transitions.
It's set when the system gracefully shuts down and cleared when the
system boots up. The result is EC tries to go back to the
previous state upon AC plug-in on battery-less systems.

This is required for digital signage and kiosk.

This also reverts: CL 514209, 486946, and 486945.

BUG=b:37536389
BRANCH=none
TEST=Tested as follows:

A. Boot to S0
A.1. Unplug AC while system is in S0 then plug in - PASS
A.2. Unplug AC while system is in S3 then plug in - PASS
A.3. Press recovery+power in S0 - PASS
A.4. Press recovery+power in G3 - FAIL (To be fixed)
A.5. Execute reboot console command - PASS
A.6. Execute reboot OS command - PASS
A.7. Execute reboot console command in G3 - PASS

B. Boot to G3
B.1 Unplug AC while system is in G3 then plug in - PASS
B.2 Unplug AC after B.1 then plug in - PASS
B.3 Shutdown by power button on recovery screen then unplug
    plug in AC - PASS
B.4 Execute reboot ap-off console command - PASS
B.5 Execute shutdown command from OS then plug in AC - PASS

Change-Id: Iaa6f930585050fdd3511c711b449dff47525066d
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/517287
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-06-28 21:50:51 -07:00
Wei-Ning Huang
5dd150f073 stm32f4: fix flash_physical_protect_now behavior
flash_physical_protect_now(), which is called when
EC_FLASH_PROTECT_ALL_NOW is set, should protect the entire flash
temporarily until reboot. Current behavior enable flash protect on all
region permanently. The correct implementation should be writing an
invalid key to the flash controller to disable flash flash only
temporarily until reboot.

Since the implementation of flash-stm32f3 and flash-stm32f4 is almost
the same after restoring the changes made in commit
35f4d8acaa, we merge to file by creating a
symlink from flash-stm32f3.c to flash-stm32f4.c to reduce code
duplication.

BRANCH=none
BUG=b:37584134
TEST=on eve:
     1) `ectool --name=cros_tp flashprotect`
        Flash protect flags: 0x00000008 wp_gpio_asserted
     2) `flashrom -p ec:type=tp --wp-enable
     3) `ectool --name=cros_tp reboot_ec`
     3) `flashrom -p ec:type=tp --wp-status`
        WP: status: 0x80
        WP: status.srp0: 1
        WP: write protect is enabled.
        WP: write protect range: start=0x00000000, len=0x00040000
     4) `ectool --name=cros_tp flashprotect`, all_now should present
        Flash protect flags: 0x0000000f wp_gpio_asserted ro_at_boot ro_now \
        all_now
     5) `ectool --name=cros_tp reboot_ec; sleep 0.3; \
         ectool --name=cros_tp rwsigaction abort` to stay in RO.
        In EC console, `flashinfo`, should show that only RO is actually
        flash protected:
        Protected now:
            YYYYYY..
     6) `flashrom -p ec:type=tp -w ec.bin -i EC_RW` works
     7) `make BOARD=ryu -j` works (for testing flash-stm32f3.c)

Change-Id: Ia7a60ae8b3084198abb468e4fc8074b4445d6915
Signed-off-by: Wei-Ning Huang <wnhuang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/549681
Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org>
Tested-by: Wei-Ning Huang <wnhuang@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
2017-06-28 00:58:59 -07:00
Shawn Nematbakhsh
ceb3e318c8 watchdog: Don't discard irqprio data due to CONFIG_LTO
Don't discard irqprio data when the IRQ_PRIORITY macro is used directly
(for watchdog / watchdog timer).

This change is probably a NOP for all platforms, since the power-on
default for the IRQ prio register seems to be zero, which is the same
priority we're setting in our direct use of IRQ_PRIORITY.

BUG=chromium:634701
BRANCH=None
TEST=Verify 'prio_44' entry exists in irqprio section by checking
ec.RO.map on kevin.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Idaffc484a2ce4749c18212f179b3951ff570aed0
Reviewed-on: https://chromium-review.googlesource.com/545201
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-26 11:12:07 -07:00
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
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
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
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
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
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
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
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
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
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
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
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
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
Vadim Bendebury
68079d94a6 g: show RW headers' Board ID fields in 'version' output
The contents of the board ID fields of the Cr50 image headers is an
important piece of information which determines if an image can run on
a particular H1 chip.

This patch adds this information to the output of the 'version'
command, printing both the contents of the fields of the RW images and
if the image would run with the current INFO1 board ID contents (Yes
or NO).

The board_id feature is in fact g chipset specific, this is why
board_id support files are being moved from the cr50 board scope to
the g chip scope.

BRANCH=cr50
BUG=b:35587387,b:35587053
TEST=observed expected output in the version command:
  > bid
  Board ID: 000000fa, flags 000000ff
  > vers
  Chip:    g cr50 B2-C
  Board:   0
  RO_A:  * 0.0.10/29d77172
  RO_B:    0.0.10/c2a3f8f9
  RW_A:  * 0.0.20/DBG/cr50_v1.1.6542-856c3aff4
  RW_B:    0.0.20/DBG/cr50_v1.1.6543-2c68a2630+
  BID A:   00000000:00000000:00000000 Yes
  BID B:   000000ea:0000fffc:000000ff  No
  Build:   0.0.20/DBG/cr50_v1.1.6542-856c3aff4
           tpm2:v0.0.289-cb2de5a
           cryptoc:v0.0.8-6283eee
           2017-06-09 15:34:19 vbendeb@eskimo.mtv.corp.google.com
  >

Change-Id: I5b283abf304a7408ca8f424407044fca238185e1
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/530033
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-13 21:23:59 -07:00
Nicolas Boichat
d132e5ecbd stm32/usb: Add support for board-specific serial number
By default, read USB serial number from flash, but provide a way
for boards to override the function (e.g., to read serial number
from unique chip id).

BRANCH=none
BUG=b:62280271
TEST=Flash hammer
     lsusb -d 18d1:5022 -v -v | grep iSerial
     shows different chip IDs on different boards.

Change-Id: I0917752bb8e04c1eff4dffc0b3714f63dcd942b0
Reviewed-on: https://chromium-review.googlesource.com/523045
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-13 21:23:56 -07:00
Mary Ruthven
1cd8daa664 g: don't enable interrupts in gpio_set_flags_by_mask
All other chips rely on gpio_enable_interrupt to enable interrupts. They
aren't enabled by default. This changes chip/g to match that.

If chip/g boards have interrupts, they also enable them in the
init_interrupts function in board.c. Nothing needs to be added to enable
interrupts.

BUG=b:35587228
BRANCH=cr50
TEST=use 'gpiocfg' to verify the setup hasn't changed.

Change-Id: I1e975999e0174b9dcbbe63c09c6110dc4161f8ff
Reviewed-on: https://chromium-review.googlesource.com/530006
Commit-Ready: Mary Ruthven <mruthven@chromium.org>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-13 15:12:33 -07:00
Vincent Palatin
c4f4651852 cr50: add derivation functions using the key-ladder
Add functions to do key derivation for the U2F code,
using the hardware key-ladder.

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

BRANCH=cr50
BUG=b:35545754
TEST=with follow-up CLs, run U2FTest on Eve

Change-Id: I5960fb9baa7ca555423a956fb97ef2bdee82feee
Reviewed-on: https://chromium-review.googlesource.com/525539
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Nagendra Modadugu <ngm@google.com>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Nagendra Modadugu <ngm@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-06-13 03:45:15 -07:00
Nicolas Boichat
aa15b8621d stm32: Add function to fetch unique id
BRANCH=none
BUG=b:62280271
TEST=Flash hammer
     lsusb -d 18d1:5022 -v -v | grep iSerial
     shows different chip IDs on different boards.

Change-Id: Id56b4509f184eb722d04fef94079c150dc2016e2
Reviewed-on: https://chromium-review.googlesource.com/523044
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
2017-06-12 20:27:55 -07:00
Mulin Chao
206f1dd93b npcx: gpio: Lock VCC_RST# alternative bit of DEVALTA.
This CL locks VCC_RST# alternative bit, NO_VCC1_RST, of DEVALTA
in case the developers switch it to GPO77 unexpectedly by setting
VCC1_RST_LK bit in DEV_CTL4.

BRANCH=none
BUG=none
TEST=Use rw console command to make sure NO_VCC1_RST bit is
locked on npcx7_evb.

Change-Id: Ic7882ef1c8050c3daca85bd241d5368f009e4e2e
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/522206
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-10 01:30:23 -07:00
Mulin Chao
a08d004e97 npcx: clock: Add support for external 32kHz crystal osc.
In this CL, we add selecting LFCLK sources functionality for npcx7 ec
series. (Please notice not all of npcx7 ec series support this feature.)
Beside internal LFCLK source, ec also can choose the external 32kHz
crystal oscillator as LFCLK source for the specific application. We also
introduce a new definition, CONFIG_CLOCK_SRC_EXTERNAL, to switch this
feature in the board level driver.

This CL also adds:
1. LFCG register definitions in registers.h.
2. Change the order of each npcx modules by memory address.

BRANCH=none
BUG=none
TEST=Output LFCLK source through GPIO75. Compare with external 32kHz
crystal osc. on npcx7_evb and make sure the sources are the same.

Change-Id: I137146bf51ccb51266b9aac1e2e28bcea87dc4f5
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/520745
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-06-09 21:44:06 -07:00
Vadim Bendebury
61b87c56b6 g: do not invoke signer with sudo unless it is necessary
Invoking signer with sudo is required only when signing requires a USB
fob. Let's not use it in unless necessary.

BRANCH=cr50
BUG=chromium:728751
TEST=verified that Cr50 build succeeds when both using and not using
     the signing fob.

Change-Id: I8f40bd52f1752bfd88ec002f298b991faf7a2512
Reviewed-on: https://chromium-review.googlesource.com/528373
Commit-Ready: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
2017-06-08 18:52:40 -07:00
CHLin
e806e20c03 npcx: system: fix the incorrect checking of invalid BBRAM(IBBR) bit.
This CL adds:
1. Fixed the incorrect address of BKUP_STS register.
2. Cleared the IBBR bit of BKUP_STS register at initial because
its default value is 1(means the content of BBRAM is invalid) whenever
VBAT is powered up.
3. Add debug msg when IBBR bit is set to indicate the BBRAM's
corruption.
4. Modified the valid BBRAM offset from 1 to 0 and size from 63 to 64.

BRANCH=none
BUG=b:38187362
TEST=No build error for make buildall; Check IBBR is cleared at initial.
Check IBBR is set by changing the VBAT voltage below VBAT MIN.
Test console command "reboot ap-off" on poppy.

Change-Id: I69d98b50d4e0aec17b55a4a9b5e8f1a412a3fe45
Signed-off-by: CHLin <CHLIN56@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/505861
Commit-Ready: CH Lin <chlin56@nuvoton.com>
Tested-by: CH Lin <chlin56@nuvoton.com>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
2017-06-08 02:35:38 -07:00
Aseda Aboagye
27a39b44d1 g: uart_bitbang: Keep debug stuff off by default.
There are some useful UART bitbang commands, statistics, and logs and
such.  These shouldn't be enabled by default, and this commit makes it
so.

BUG=b:35648297
BRANCH=cr50
TEST=Build an image that enables UART bit banging with BITBANG_DEBUG set
to 0.  Verify that the associated debug commands and statistics are not
present.

Change-Id: Ic0348a6fb1620229e2ed601e0ff549596d814e1e
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/527605
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
2017-06-07 23:45:30 -07:00
Gwendal Grignou
7719869dac board: Add support for nucleo-f411re
Add nucleo-f411re for testing STM32F411.
Fix registers.h to include F411 specific features.

TEST=Check uart,gpio works. Check BMI160 accel/gyro sensor works over
i2c
Install firmware with "make BOARD=nucleo-f411re flash"

BUG=b:38018926
BRANCH=none

Change-Id: I8514d1aa48e06708053e72f8d4be15738eda6cf4
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/249994
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
2017-06-06 17:09:28 -07:00
Vadim Bendebury
a75f7c8680 cr50: usb_upgrade: allow responses lager than requests
When invoking vendor command handlers in try_vendor_command(), the
buffer containing the command is passed to the handler to communicate
the command contents and to hold the command execution return data. It
was fine when invoking vendor command handlers from the TPM stack, as
the receive buffer is 4K in size and is large enough for any expected
vendor command response.

It is different in case of USB: the command is in the receive buffer
of the USB queue, and the response data could easily exceed the
command size, which would cause corruption of the USB receive queue
contents when the response data is placed into the same buffer where
the command is.

Let's introduce a local storage to pass the command and receive the
response data from the handler. 32 bytes is enough for the foreseeable
future, should a need arise for a larger buffer, testing would result
in an error (a new error type is added to indicate insufficient buffer
space for command processing).

BRANCH=none
BUG=b:35587387,b:35587053
TEST=with the rest of the patches applied verified proper processing
     of the 'Get Board ID' command for which response size exceeds the
     request size.

Change-Id: I2131496f3a99c7f3a1869905120a453d75efbdce
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/525092
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2017-06-06 14:36:28 -07:00