Commit Graph

88 Commits

Author SHA1 Message Date
Nicolas Boichat
76927bdc5a stm32/usb: Add HOOK_USB_PM_CHANGE, called when USB is resumed/suspended
In particular, this will allow touchpad driver and keyboard matrix
scanning to be powered off/disabled when the USB interface is
disabled without setting the remote wake feature
(USB_REQ_FEATURE_DEVICE_REMOTE_WAKEUP), as events would be
ignored anyway.

BRANCH=none
BUG=b:72683995
TEST=With next CLs, touchpad and keyboard matrix scanning are disabled
     when lid is closed.

Change-Id: I3750bfaf8c31cde075adf9da4fef39753b8981c5
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/897067
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-02-02 10:17:30 -08:00
Shawn Nematbakhsh
8d29b3dae7 stm32: Fix bkpdata accounting
stm32f0 has 20 bytes (not 20 words) of VBAT-backed RAM. Make more
efficient use of our limited storage to prevent trying to use storage
that doesn't exist.

BUG=b:71333840
BRANCH=None
TEST=Negotiate PD, run "reboot" on scarlet EC console, verify reset path
is taken in pd_partner_port_reset().

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ie4c303b74a1b82b84ec971cdcc19c2b21a0032e7
Reviewed-on: https://chromium-review.googlesource.com/885461
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2018-01-30 14:54:17 -08:00
Philip Chen
0037fb8dfc system: Log PC and task id on watchdog
For debug, in common code let's log the watchdog PC
and task id as our SW panic params.

BUG=chromium:790006
BRANCH=none
TEST=manually test scarlet rev2 from a1-a3, b1-b2:

(a1) Add 'while(1);' in button ISR
(a2) Boot and press the button
(a3) When watchdog is triggeried, check with 'panicinfo'
that saved R5 is the PC for button ISR.

(b1) 'crash watchdog' in EC console
(b2) Check with 'panicinfo' that CONSOLE task id is saved in
EXCEPTION and PC is saved in R5.

Change-Id: I64d2fcf594dd24b0951e002ab8e80ebcac2d1def
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/803618
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-12-11 15:16:23 -08:00
Gwendal Grignou
2590ce9538 common: Add software CTZ implementation when needeed
CTZ - Count Trailing Zero - is not implemented in hardware on cortex0 or
nds32.

Used in ST sensor drivers.

BUG=none
BRANCH=none
TEST=compile

Change-Id: I2d62fd60f05169189b24ba2a3308bec69ed9de9c
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/767609
Commit-Ready: Ely Vazquez <nadia198877@gmail.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-11-16 23:32:11 -08:00
Paul Kocialkowski
e5c69151df cortex-m0: Use assembly exception handlers for task switching
The way Cortex processors handle exceptions allows writing exception
routines directly in C, as return from exception is handled by providing
a special value for the link register.

However, it is not safe to do this when doing context switching. In
particular, C handlers may push some general-purpose registers that
are used by the handler and pop them later, even when context switch
has happened in the meantime. While the processor will restore {r0-r3}
from the stack when returning from an exception, the C handler code
may push, use and pop another register, such as r4.

It turns out that GCC 4.8 would generally only use r3 in svc_handler and
pendsv_handler, but newer versions tend to use r4, thus clobbering r4
that was restored from the context switch and leading up to a fault
when r4 is used by the task code.

An occurrence of this behaviour takes place with GCC > 4.8 in __wait_evt,
where "me" is stored in r4, which gets clobbered after an exception
triggers pendsv_handler. The exception handler uses r4 internally, does
a context switch and then restores the previous value of r4, which is
not restored by the processor's internal, thus clobbering r4.
This ends up with the following assertion failure:
'tskid < TASK_ID_COUNT' in timer_cancel() at common/timer.c:137

For this reason, it is safer to have assembly routines for exception
handlers that do context switching.

BUG=chromium:631514
BRANCH=None
TEST=Build and run speedy EC with a recent GCC version

Change-Id: Ib068bc12ce2204aee3e0f563efcb94f15aa87013
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Reviewed-on: https://chromium-review.googlesource.com/362830
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-08-28 10:55:41 -07:00
Stefan Reinauer
9939855231 Fix inconsistent task function declarations
Tasks are defined inconsistently across the code base.

Signed-off-by: Stefan Reinauer <reinauer@google.com>
BRANCH=none
TEST=make buildall -j, also verify kevin boots to OS
BUG=none

Change-Id: I19a076395a9a8ee1e457e67a89d80d2f70277c97
Reviewed-on: https://chromium-review.googlesource.com/602739
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-08-08 14:56:13 -07:00
Patrick Georgi
1a67ac2ad6 Allow core code to request its cross compiler
Instead of having to pass in both the board and the arch used there
(which might be complicated in the light of different ECs with different
arches), allow passing in the board and a set of cross compilers.

The core/*/build.mk then pick the compiler that is responsible for them.
The current method works just the same: If you've already set
CROSS_COMPILE, no override happens. If you set neither CROSS_COMPILE nor
CROSS_COMPILE_$arch, the same default as before this CL is set.

BUG=none
BRANCH=none
TEST=emerge-{samus,kevin} chromeos-ec behave reasonably with adapted
ebuild

Change-Id: Icf1866f296412dd92ecfe134394224c49f7c3df5
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/549344
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@google.com>
2017-07-19 05:01:02 -07:00
Nicolas Boichat
d68b1ca803 core/cortex-m0/curve25519: Remove unused variants
Remove code related to DH_SWAP_BY_POINTERS and
DH_REPLACE_LAST_THREE_LADDERSTEPS_WITH_DOUBLINGS, as they are
not really worth it (code size increase of 60/100 bytes respectively
for 1000/500 us time gain).

BRANCH=none
BUG=b:62813194
TEST=make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, taskinfo

Change-Id: If21948bb2c7c20f97ba8b321dd2688cd3d0ba74a
Reviewed-on: https://chromium-review.googlesource.com/554440
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:00 -07:00
Nicolas Boichat
edc668ea6c core/cortex-m0/curve25519: Integrate fast curve25519 implementation
- Move generic implementation to curve25519-generic.o
- Always use optimized version on cortex-m0.

- Rename .s files to .S, remove unnecessary lines in assembly files.
- Rename crypto_scalarmult_curve25519 to x25519_scalar_mult to match
  the signature provided by the generic implementation.
- Replace some handcoded memcpy with function calls
- Remove unnecessary "volatile" specifications in the code.

BRANCH=none
BUG=b:62813194
TEST=To test old implementation only:
        - Increase CONFIG_RO_SIZE to 60kb
        - Increase console stack size to 2048
     make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, taskinfo
     => Used to takes ~4'17" to run (X25519 duration 256347 us).
        1496/2048 stack size usage in CONSOLE task
     => Now takes ~1'25" to run (X25519 duration 84520 us)
        732/2048 stack size usage in CONSOLE task
TEST=In test/x25519.c, uncomment #define TEST_X25519_1M_ITERATIONS
     make BOARD=hammer PROJECT=x25519 TEST_BUILD=y
     ./util/flash_ec --board=hammer --image=build/hammer/x25519.bin
     EC console: runtest, wait ~23 hours, test passes.
TEST=- Define CONFIG_CURVE25519_CORTEXM0 (next patch)
     makes newsizes
     build/hammer/RW/ec.RW.flat shrank by 1888 bytes: (52208 to 50320)

Change-Id: Icce38d3c32f431a85ac0f951cf34456b490dc665
Reviewed-on: https://chromium-review.googlesource.com/540962
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-03 21:44:34 -07:00
Nicolas Boichat
6d912fa841 core/cortex-m0/curve25519: Import fast curve25519 implementation
Import finely tuned curve25519 implementation from
https://munacl.cryptojedi.org/curve25519-cortexm0.shtml
(http://munacl.cryptojedi.org/data/curve25519-cortexm0-20150813.tar.bz2)
which is released in the public domain for some files, CC0 for others.

This is a plain copy (only doing a pass of dos2unix conversion
and removing trailing tabs/spaces), later patches integrate the
code with the rest of the EC code.

BRANCH=none
BUG=b:62813194
TEST=None (see next patch)

Change-Id: Ibd394d031433c31d4755a880b0e8d74b63540fbf
Reviewed-on: https://chromium-review.googlesource.com/540961
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-06-22 03:34:46 -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
Nicolas Boichat
629c3964a2 common: Split rwsig parts from rsa.h header
We're going to add more rwsig-related functions, and adding them
to rsa.h seems increasingly incorrect.

BRANCH=none
BUG=b:35587171
TEST=make buildall -j

Change-Id: I334c1774ce9a6ed8e219140f65ebe94d653e22d2
Reviewed-on: https://chromium-review.googlesource.com/468708
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-04-11 20:22:32 -07:00
Shawn Nematbakhsh
e025e17b33 system: Use stored size in image_data for determining image_used
Image used size is now part of the image_data struct present in all
images at a fixed offset, so use it rather than scanning from the end of
the image.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that system_get_image_used() returns
the same value as the old implementation, for both RO and RW images.
BRANCH=None

Change-Id: I35f0aa87f5ab1371dbd8b132f22b9d0044358223
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/450859
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-03-16 00:11:41 -07:00
Shawn Nematbakhsh
3c4c83b8c3 version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now
renamed to image_data). This will allow us to more efficiently determine
the size of an image in a follow-up CL.

Note that compatibility is broken for old ROs that do not include this
CL.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that stored image size matches
output of system_get_image_used() for both RO and RW images.
BRANCH=None

Change-Id: I7b8dc3ac8cf2df3184d0701a0e0ec8032de8d81b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/450858
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-03-16 00:11:41 -07:00
Nick Sanders
31b5ce49c6 stm32: never pad usb descriptor length
This marks decriptor length as byte accurate, by
aligning the "__usb_desc_end" label by byte rather
than short or word.

BUG=chrome-os-partner:62873
TEST=servo_v4 doesn't crash adb anymore
BRANCH=None

Change-Id: I643bae2c59e81ce0c03d9026f4a5d7933ba4c891
Reviewed-on: https://chromium-review.googlesource.com/442012
Commit-Ready: Nick Sanders <nsanders@chromium.org>
Tested-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-02-23 16:02:05 -08:00
Sam Hurst
edf46467b9 cleanup: Remove charge_state_v1
All boards have been transitioned to charge_state_v2.c
So charge_state_v1.c, HOOK_CHARGE_STATE_CHANGE, and
CONFIG_CHARGER_TIMEOUT_HOURS can be removed

BUG=chrome-os-partner:36272
TEST=make -j buildall
BRANCH=none

Change-Id: I3f20c5198ea75185f9894deb792575a1be31432a
Reviewed-on: https://chromium-review.googlesource.com/435467
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-02-06 14:50:32 -08:00
Vadim Bendebury
11704ae6e9 Revert "version: Store image size data in version struct"
This is a dependency of the uderlyaing patch which breaks header
composition of g chip based boards.

This reverts commit 7cbb815732.

Change-Id: I4d94647cf5cb09fd338e5a581c956df6b5d83081
Reviewed-on: https://chromium-review.googlesource.com/435551
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-01 06:36:18 +00:00
Vadim Bendebury
9fc399a0aa Revert "system: Use stored size in image_data for determining image_used"
This breaks header composition of g chip based boards.

This reverts commit 93951a491d.

Change-Id: Ia52cf1d9c56fbb588317cec73487b2c9e89b7234
Reviewed-on: https://chromium-review.googlesource.com/435550
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2017-02-01 06:35:57 +00:00
Shawn Nematbakhsh
93951a491d system: Use stored size in image_data for determining image_used
Image used size is now part of the image_data struct present in all
images at a fixed offset, so use it rather than scanning from the end of
the image.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that system_get_image_used() returns
the same value as the old implementation, for both RO and RW images.
BRANCH=None

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: Ic8db5c706d82f7ca2ded2e90129747e7fbefdb38
Reviewed-on: https://chromium-review.googlesource.com/427959
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-01-30 16:48:41 -08:00
Shawn Nematbakhsh
7cbb815732 version: Store image size data in version struct
Store our image size (known at build time) in our version struct (now
renamed to image_data). This will allow us to more efficiently determine
the size of an image in a follow-up CL.

Note that compatibility is broken for old ROs that do not include this
CL.

BUG=chromium:577915
TEST=Verify on kevin + lars + lars_pd that stored image size matches
output of system_get_image_used() for both RO and RW images.
BRANCH=None

Change-Id: I49ea5fc27a7f11f66daba485a87d0dfe7d0c770f
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/427408
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2017-01-30 16:48:40 -08:00
Sam Hurst
a7bf207add iec: Improve efficiency of host command dispatcher
Use binary search in host command lookup dispatcher

BUG=chromium:570895
TEST=manual testing on kevin
      - Kevin boots
      - ectool hello
      make buildall -j
      Verify *.smap hcmds section is sorted:

      BOARD with host commands and private host commands
      0004d0ec R __hcmds
      0004d0ec R __host_cmd_0x00000x0000
      0004d0f8 R __host_cmd_0x00000x0001
      0004d104 R __host_cmd_0x00000x0002
      0004d110 R __host_cmd_0x00000x0003
      0004d11c R __host_cmd_0x00000x0004
      0004d128 R __host_cmd_0x00000x0005
      0004d134 R __host_cmd_0x00000x0007
      0004d140 R __host_cmd_0x00000x0008
      0004d14c R __host_cmd_0x00000x000a
      0004d158 R __host_cmd_0x00000x000d
      0004d164 R __host_cmd_0x00000x0010
      0004d170 R __host_cmd_0x00000x0011
      0004d17c R __host_cmd_0x00000x0012
      0004d188 R __host_cmd_0x00000x0013
      0004d194 R __host_cmd_0x00000x0015
      0004d1a0 R __host_cmd_0x00000x0016
      0004d1ac R __host_cmd_0x00000x0017
      0004d1b8 R __host_cmd_0x00000x0087
      0004d1c4 R __host_cmd_0x00000x008c
      0004d1d0 R __host_cmd_0x00000x008f
      0004d1dc R __host_cmd_0x00000x0092
      0004d1e8 R __host_cmd_0x00000x0093
      0004d1f4 R __host_cmd_0x00000x0097
      0004d200 R __host_cmd_0x00000x0098
      0004d20c R __host_cmd_0x00000x00b6
      0004d218 R __host_cmd_0x00000x00d2
      0004d224 R __host_cmd_0x00000x00d3
      0004d230 R __host_cmd_0x3E000x0000
      0004d23c R __host_cmd_0x3E000x0002
      0004d248 R __evt_src_EC_MKBP_EVENT_HOST_EVENT
      0004d248 R __hcmds_end

      BOARD with host commands only
      100bc888 R __hcmds
      100bc888 R __host_cmd_0x00000x0000
      100bc894 R __host_cmd_0x00000x0001
      100bc8a0 R __host_cmd_0x00000x0002
      100bc8ac R __host_cmd_0x00000x0003
      100bc8b8 R __host_cmd_0x00000x0004
      100bc8c4 R __host_cmd_0x00000x0005
      100bc8d0 R __host_cmd_0x00000x0006
      100bc8dc R __host_cmd_0x00000x0007
      100bc8e8 R __host_cmd_0x00000x0008
      100bc8f4 R __host_cmd_0x00000x0009
      100bc900 R __host_cmd_0x00000x000a
      100bc90c R __host_cmd_0x00000x000b
      100bc918 R __host_cmd_0x00000x000d
      100bc924 R __host_cmd_0x00000x0010
      100bc930 R __host_cmd_0x00000x0011
      100bc93c R __host_cmd_0x00000x0012
      100bc948 R __host_cmd_0x00000x0013
      100bc954 R __host_cmd_0x00000x0015
      100bc960 R __host_cmd_0x00000x0016
      100bc96c R __host_cmd_0x00000x0017
      100bc978 R __host_cmd_0x00000x0025
      100bc984 R __host_cmd_0x00000x0026
      100bc990 R __host_cmd_0x00000x0029
      100bc99c R __host_cmd_0x00000x002a
      100bc9a8 R __host_cmd_0x00000x002b
      100bc9b4 R __host_cmd_0x00000x002c
      100bc9c0 R __host_cmd_0x00000x0044
      100bc9cc R __host_cmd_0x00000x0045
      100bc9d8 R __host_cmd_0x00000x0046
      100bc9e4 R __host_cmd_0x00000x0047
      100bc9f0 R __host_cmd_0x00000x0061
      100bc9fc R __host_cmd_0x00000x0062
      100bca08 R __host_cmd_0x00000x0064
      100bca14 R __host_cmd_0x00000x0065
      100bca20 R __host_cmd_0x00000x0067
      100bca2c R __host_cmd_0x00000x0087
      100bca38 R __host_cmd_0x00000x008c
      100bca44 R __host_cmd_0x00000x008d
      100bca50 R __host_cmd_0x00000x008f
      100bca5c R __host_cmd_0x00000x0092
      100bca68 R __host_cmd_0x00000x0093
      100bca74 R __host_cmd_0x00000x0096
      100bca80 R __host_cmd_0x00000x0097
      100bca8c R __host_cmd_0x00000x0098
      100bca98 R __host_cmd_0x00000x0099
      100bcaa4 R __host_cmd_0x00000x009e
      100bcab0 R __host_cmd_0x00000x00a0
      100bcabc R __host_cmd_0x00000x00a1
      100bcac8 R __host_cmd_0x00000x00a8
      100bcad4 R __host_cmd_0x00000x00a9
      100bcae0 R __host_cmd_0x00000x00b6
      100bcaec R __host_cmd_0x00000x00b7
      100bcaf8 R __host_cmd_0x00000x00d2
      100bcb04 R __host_cmd_0x00000x00d3
      100bcb10 R __host_cmd_0x00000x00db
      100bcb1c R __host_cmd_0x00000x0101
      100bcb28 R __host_cmd_0x00000x0102
      100bcb34 R __host_cmd_0x00000x0103
      100bcb40 R __host_cmd_0x00000x0104
      100bcb4c R __host_cmd_0x00000x0110
      100bcb58 R __host_cmd_0x00000x0111
      100bcb64 R __host_cmd_0x00000x0112
      100bcb70 R __host_cmd_0x00000x0113
      100bcb7c R __host_cmd_0x00000x0114
      100bcb88 R __host_cmd_0x00000x0115
      100bcb94 R __host_cmd_0x00000x0116
      100bcba0 R __host_cmd_0x00000x0117
      100bcbac R __host_cmd_0x00000x0118
      100bcbb8 R __host_cmd_0x00000x011a
      100bcbc4 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX
      100bcbc4 R __hcmds_end
BRANCH=none

Change-Id: I5d13d2a7fe7fa9a0fbeed43177cc612f572a58bb
Reviewed-on: https://chromium-review.googlesource.com/419702
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2017-01-06 11:10:03 -08:00
Mulin Chao
266b36d54b core: Fix bug will cause tasks sleep forever by mutex_unlock in task.c.
If there's a task switching occurred between loading waiter and
unlocking the lock, the task with higher priority won't wake up since
the local variable, waiter, doesn't contain its ID bit before task
switching. In this situation, the higher priority task only can be
awakened when the other tasks execute mutex_unlock() again.

But consider the following conditions: (For example, the driver of
charger bd9995x.)
1. There are more than one mutex for the usage path of i2c port.
2. There are more than one task access this usage path of i2c port and
   one of these tasks, task A, met the situation above.
3. The other tasks have no chance to execute mutex_unlock() of i2c since
   the task A still occupied the mutex of charger.

All the tasks used the same i2c port or the other hardware will sleep
forever. This CL makes loading waiter and unlocking the lock as atomic
to solve this issue.

BRANCH=none
BUG=chrome-os-partner:60617
TEST=make BOARD=snappy; make BOARD=oak; Executed charger factory test on
4 units of snappy for 3 days and no symptom occurred.

Change-Id: Id976fc47955b33ca83bb2182b197d9f2781c341b
Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Reviewed-on: https://chromium-review.googlesource.com/423285
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
2017-01-05 11:01:54 -08:00
Vadim Bendebury
b3a9852122 Revert "ec: Improve efficiency of host command dispatcher"
This reverts commit c459c8278e 
as the fix is not straightforwad, some host command codes in 
private repos are expressed using C preprecessor which 
breaks the assumption of this patch that all host commands 
are expressed as four digit hex numbers.

Change-Id: I922de9ae8dbab6eef048463c5c09b1f338152083
Reviewed-on: https://chromium-review.googlesource.com/414492
Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Commit-Queue: Vadim Bendebury <vbendeb@chromium.org>
Tested-by: Vadim Bendebury <vbendeb@chromium.org>
2016-11-26 01:29:24 +00:00
Sam Hurst
c459c8278e ec: Improve efficiency of host command dispatcher
Use binary search in host command lookup dispatcher

BUG=chrome-os-partner:570895
TEST=manual testing on kevin
      - Kevin boots
      - ectool hello
      make buildall -j
      Verify *.smap hcmds section is sorted:
         100bca94 R __hcmds
         100bca94 R __host_cmd_0x0000
         100bcaa0 R __host_cmd_0x0001
         100bcaac R __host_cmd_0x0002
         100bcab8 R __host_cmd_0x0003
         100bcac4 R __host_cmd_0x0004
         100bcad0 R __host_cmd_0x0005
         100bcadc R __host_cmd_0x0006
         100bcae8 R __host_cmd_0x0007
         100bcaf4 R __host_cmd_0x0008
         100bcb00 R __host_cmd_0x0009
         100bcb0c R __host_cmd_0x000a
         100bcb18 R __host_cmd_0x000b
         100bcb24 R __host_cmd_0x000d
         100bcb30 R __host_cmd_0x0010
         100bcb3c R __host_cmd_0x0011
         100bcb48 R __host_cmd_0x0012
         100bcb54 R __host_cmd_0x0013
         100bcb60 R __host_cmd_0x0015
         100bcb6c R __host_cmd_0x0016
         100bcb78 R __host_cmd_0x0017
         100bcb84 R __host_cmd_0x0025
         100bcb90 R __host_cmd_0x0026
         100bcb9c R __host_cmd_0x0029
         100bcba8 R __host_cmd_0x002a
         100bcbb4 R __host_cmd_0x002b
         100bcbc0 R __host_cmd_0x002c
         100bcbcc R __host_cmd_0x0044
         100bcbd8 R __host_cmd_0x0045
         100bcbe4 R __host_cmd_0x0046
         100bcbf0 R __host_cmd_0x0047
         100bcbfc R __host_cmd_0x0061
         100bcc08 R __host_cmd_0x0062
         100bcc14 R __host_cmd_0x0064
         100bcc20 R __host_cmd_0x0065
         100bcc2c R __host_cmd_0x0067
         100bcc38 R __host_cmd_0x0087
         100bcc44 R __host_cmd_0x008c
         100bcc50 R __host_cmd_0x008d
         100bcc5c R __host_cmd_0x008f
         100bcc68 R __host_cmd_0x0092
         100bcc74 R __host_cmd_0x0093
         100bcc80 R __host_cmd_0x0096
         100bcc8c R __host_cmd_0x0097
         100bcc98 R __host_cmd_0x0098
         100bcca4 R __host_cmd_0x0099
         100bccb0 R __host_cmd_0x009e
         100bccbc R __host_cmd_0x00a0
         100bccc8 R __host_cmd_0x00a1
         100bccd4 R __host_cmd_0x00a8
         100bcce0 R __host_cmd_0x00a9
         100bccec R __host_cmd_0x00b6
         100bccf8 R __host_cmd_0x00b7
         100bcd04 R __host_cmd_0x00d2
         100bcd10 R __host_cmd_0x00d3
         100bcd1c R __host_cmd_0x00db
         100bcd28 R __host_cmd_0x0101
         100bcd34 R __host_cmd_0x0102
         100bcd40 R __host_cmd_0x0103
         100bcd4c R __host_cmd_0x0104
         100bcd58 R __host_cmd_0x0110
         100bcd64 R __host_cmd_0x0111
         100bcd70 R __host_cmd_0x0112
         100bcd7c R __host_cmd_0x0113
         100bcd88 R __host_cmd_0x0114
         100bcd94 R __host_cmd_0x0115
         100bcda0 R __host_cmd_0x0116
         100bcdac R __host_cmd_0x0117
         100bcdb8 R __host_cmd_0x0118
         100bcdc4 R __host_cmd_0x011a
         100bcdd0 R __evt_src_EC_MKBP_EVENT_KEY_MATRIX
         100bcdd0 R __hcmds_end
BRANCH=none

Change-Id: Ideb9951b318763f71915e2c4e5052f4b4bfab173
Reviewed-on: https://chromium-review.googlesource.com/405528
Commit-Ready: Sam Hurst <shurst@google.com>
Tested-by: Sam Hurst <shurst@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-11-23 15:36:00 -08:00
Shawn Nematbakhsh
907c09ee38 task: Don't propagate TASK_EVENT_TIMER between between waits
In __wait_evt(), if a timer expiration occurs after we read event
status, before the timer is canceled, then TASK_EVENT_TIMER will be
propagated to the next task wait, likely leading to premature timeout.
Prevent this by clearing TASK_EVENT_TIMER after canceling our timer.

BUG=chrome-os-partner:58658
BRANCH=gru
TEST=Manual on gru, run 'pd # hard' for 12 hours with charger attached,
verify no TCPC I2C read errors occur.

Change-Id: Iac2f05a768b4ef29f82e7c3eb899f4c7dd5c3744
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400968
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-10-26 01:45:25 -07:00
Gwendal Grignou
4848d7e8fa common: Add TABLET_MODE hook.
Add a hook to act when the a device is going in tablet mode and back.

BUG=chromium:606718
BRANCH=kevin
TEST=Test with evtest that an event is sent to the AP.

Change-Id: Ic9c3b158f1178504af41abff18b28de8e07fc7a7
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/380412
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-09-07 14:01:18 -07:00
Bill Richardson
bb15561db5 cleanup: DECLARE_CONSOLE_COMMAND only needs 4 args
Since pretty much always, we've declared console commands to take
a "longhelp" argument with detailed explanations of what the
command does. But since almost as long, we've never actually used
that argument for anything - we just silently throw it away in
the macro. There's only one command (usbchargemode) that even
thinks it defines that argument.

We're never going to use this, let's just get rid of it.

BUG=none
BRANCH=none
CQ-DEPEND=CL:*279060
CQ-DEPEND=CL:*279158
CQ-DEPEND=CL:*279037
TEST=make buildall; tested on Cr50 hardware

Everything builds. Since we never used this arg anyway, there had
better not be any difference in the result.

Change-Id: Id3f71a53d02e3dc625cfcc12aa71ecb50e35eb9f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/374163
Reviewed-by: Myles Watson <mylesgw@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-24 16:30:10 +00:00
Shawn Nematbakhsh
1fac917071 core: Don't discard irqprio table entries due to LTO
Add __keep attribute to irqprio entries to ensure they are not dropped
when CONFIG_LTO is enabled.

BUG=chrome-os-partner:55920
BRANCH=None
TEST=Manual on kevin. Check build/RO/ec.RO.map, verify that
.rodata.irqprio section is not empty.

Change-Id: I51ae23556d6f46b2cd7ba098f0e7a785292b2853
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/366571
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-08-07 21:43:53 -07:00
Daisuke Nojiri
afa53e3950 Add cts.tasklist
cts.tasklist contains tasks run only for CTS. These tasks are added to the
tasks registered in ec.tasklist with higher priority. This design allows
board directories to be free from CTS stuff.

cts.tasklist can be placed in each suite directory (cts/suite/cts.tasklist).
If a suite does not define its own cts.tasklist, the common list is used
(i.e. cts/cts.tasklist).

BUG=chromium:624520
BRANCH=none
TEST=Ran the followings:
make buildall
make CTS_MODULE=gpio BOARD=nucleo-f072rb
make CTS_MODULE=gpio BOARD=stm32l476g-eval

Change-Id: Ibb242297ee10a397a8fcb6ff73d8cbc560daa885
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/359445
Reviewed-by: Chris Chen <twothreecc@google.com>
2016-07-11 21:27:46 -07:00
Shawn Nematbakhsh
0e532c6044 cleanup: Remove SHIFT_CODE_FOR_TEST handling
SHIFT_CODE_FOR_TEST images were used for an old FAFT test but is no
longer in use today.

BUG=chromium:616806
BRANCH=None
TEST=`make buildall -j`
CQ-DEPEND=CL:349281

Change-Id: I1b4e8c2560e2a7ff507cf2275dbbbdabf435866b
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/349272
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Tom Tam <waihong@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2016-06-03 03:00:08 -07:00
Stefan Reinauer
b5c56aba6f core: cortex-m0: Fix task routine prototypes
The task routines are void func(void), not int func(void *).

BUG=none
BRANCH=none
TEST=compile tested on chell
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>

Change-Id: I599ff2433d821bfb446fbb4f84a803c6feffa0b3
Reviewed-on: https://chromium-review.googlesource.com/343213
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-06-03 03:00:06 -07:00
Anton Staaf
95858f385c Deferred: Remove hard coded number of deferreds
Previously the maximum number of deferred routines was specified by the
the default maximum number of deferred routines you had to override
this, and if you wanted fewer, you still payed the price of having the
defer_until array statically allocated to be the maximum size.

This change removes that define and instead creates the RAM state of
the deferred routine (the time to wait until to call the deferred) when
the deferred is declared.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

BRANCH=None
BUG=None
TEST=make buildall -j
     manually test on discovery-stm32f072

Change-Id: Id3db84ee1795226b7818c57f68c1f637567831dc
Reviewed-on: https://chromium-review.googlesource.com/335597
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2016-04-19 12:23:52 -07:00
Patrick Georgi
e7b5e7b050 core/*/ec.lds.S: quote paths containing OUTDIR
If OUTDIR brings in a "@", the build breaks because that delimits the
path, leading to invalid file names.
This can happen (and happened) when building on a Jenkins CI instance
which uses jobname@number as path for parallel checkouts on a
single build node.

BRANCH=none
BUG=none
TEST=build with make out=foo@bar ... failed and works now.

Change-Id: Id0594f0d7312419110091443755ec11b5f8ee2d8
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/327110
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Martin Roth <martinroth@chromium.org>
2016-02-10 12:44:15 -08:00
Duncan Laurie
97713dba84 ec: Add a chipset reset hook
There are hooks for chipset power sequencing but not one to indicate
that the system has reset at runtime.  Add a hook for this and
implement for lm4 and mec1322.  The hook is notified on any platform
reset, including those that happen on the way into S3/S5 state.

There is a new config variable added because the hook is notified in
the interrupt handler and needs a deferrable function that needs to
be added to every board.

BUG=chrome-os-partner:46049
BRANCH=none
TEST=tested on glados and samus

Change-Id: I3be639414e18586344e0ec84632a50dfc1df586b
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/315221
Commit-Ready: Aaron Durbin <adurbin@chromium.org>
Tested-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-01-25 21:46:48 -08:00
Shawn Nematbakhsh
6e4848c200 task: Don't discard events on mutex contention
On mutex contention, call task_wait_event_mask(), which will wait for
a mutex event without clearing other pending events.

BUG=chrome-os-partner:47918,chromium:435611,chromium:435612
BRANCH=None
TEST=Manual on snoball. Verify samus can successfully negotiate PD power
contract when attached to snoball.

Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I85cd32f2670246da9e4787025390aba2c93f9c36
Reviewed-on: https://chromium-review.googlesource.com/314492
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
2015-11-30 12:27:58 -08:00
Vadim Bendebury
a8f2e3625e add the 'extension' command framework
This patch introduces a facility which would allow to compile in
callbacks for arbitrary commands passed over various communication
protocols.

Typically this will be used for testing, when various test commands
are multiplexed over an existing protocol.

The callbacks are associated with 16 bit command codes. On input the
callback receives a buffer, containing the command's argument, the
size of the command argument and the maximum size of the buffer. On
output the callback stores processing result in the same buffer and
updates the size to the actual amount of returned data.

Callback descriptors are stored in a dedicated read only section which
is scanned by extension_route_command() to find a callback associated
with a certain command code.

A console channel is also being introduced to allow controlling
console output generated by extension commands handlers.

BRANCH=none
BUG=chrome-os-partner:47524
TEST=none yet

Change-Id: I8ae16a78ca7d72176a5e7f74dd7a232078e7c06c
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/312586
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-17 14:40:26 -08:00
Aseda Aboagye
fe3189a56f cortex-m0: Ensure .bss.slow section is cleared.
The .bss.slow input section needs to be included before __bss_end,
otherwise it won't get cleared to zero.

BUG=None
BRANCH=None
TEST=Build jerry.  Verify that __bss_end is at the end of the .bss.slow
section.
TEST=make -j buildall tests

Change-Id: I41d028ee166d05b34a889499cdcb0254341be1b6
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/312404
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-11-12 16:13:51 -08:00
Shawn Nematbakhsh
1ade79a8e6 cleanup: Fix gcc 5.2.1 compile errors
BUG=chromium:552006
BRANCH=None
TEST=`make buildall -j` and also verify panic reporting works on
glados_pd.

Change-Id: Ic9f1ec6b5297389df0d46bb38a67c156901ed956
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/311253
Commit-Ready: Shawn N <shawnn@gmail.com>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2015-11-11 11:00:56 -08:00
Bill Richardson
094a81f5de cleanup: Handle signed RW images a bit cleaner
For signed EC RW images (CONFIG_RWSIG), there's no point in
embedding the public key or signature into the image itself since
it will just be replaced by the signer (either as the next step
in the build process, or after the fact for MP releases). This
takes that out and just points to where the pubkey and signature
will be placed.

BUG=none
BRANCH=none
TEST=make buildall

I also checked the signatures with

  futility show -t build/*/ec.bin

They still look good, and the one signed image I booted (Cr50)
works as before.

Change-Id: Ib39b7c508914851f81a1bebb2450e08ef0def76c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302630
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-25 19:36:37 -07:00
Bill Richardson
4ae115e145 Fix typo when building with CONFIG_SHAREDLIB
The board-specific board.h defines things like this:

  #define CONFIG_RO_SIZE 1000
  #define CONFIG_RW_SIZE 1000
  #define CONFIG_SHAREDLIB_SIZE 200

And in the linker scripts we define some preprocessor macros like
so:

  #define FW_SIZE_(section) CONFIG_##section##_SIZE
  #define FW_SIZE(section) FW_SIZE_(section)

So that we can say things like this:

    FLASH (rx) : ORIGIN = FW_OFF(SECTION), LENGTH = FW_SIZE(SECTION)

Note that we have to use FW_SIZE, not FW_SIZE_

The difference is only noticeable when SECTION is #defined. If
${CFLAGS} has

  -DSECTION=RW

Then the expansion is this:

  FW_SIZE_(SECTION)    =>   CONFIG_SECTION_SIZE
  FW_SIZE_(RW)         =>   1000

There's no difference in the output for this particular CL, but
we should use the correct macro anyway to avoid confusion.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: I61edc76a1aaeb1c675b384371700f37dda39ed47
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302150
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-09-23 21:26:21 -07:00
Gwendal Grignou
1d8fcfcd0d common: Add __fls function
Returns the most significant bit set.
Replace 31 - __builtin_clz(x), so x must be different from 0.
Use get_next_bit when not on the performance path,
on performance path set the bit field just after reading it.

BRANCH=smaug
BUG=none
TEST=compile, check Ryu still works.

Change-Id: Ie1a4cda4188f45b4bf92d0549d5c8fb401a30e5d
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301300
2015-09-21 01:13:54 -07:00
Shawn Nematbakhsh
d58e54730c cleanup: Rename geometry constants
Rename and add geometry constants to match spec doc -
https://goo.gl/fnzTvr.

CONFIG_FLASH_BASE becomes CONFIG_PROGRAM_MEMORY_BASE
CONFIG_FLASH_MAPPED becomes CONFIG_MAPPED_STORAGE

Add CONFIG_INTERNAL_STORAGE, CONFIG_EXTERNAL_STORAGE and
CONFIG_MAPPED_STORAGE_BASE where appropriate.

This CL leaves chip/npcx in a broken state -- it's fixed in a follow-up
CL.

BRANCH=None
BUG=chrome-os-partner:23796
TEST=With entire patch series, on both Samus and Glados:
- Verify 'version' EC console command is correct
- Verify 'flashrom -p ec -r read.bin' reads back EC image
- Verify software sync correctly flashes both EC and PD RW images

Change-Id: Idb3c4ed9f7f6edd0a6d49ad11753eba713e67a80
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297484
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-16 14:49:31 -07:00
Bill Richardson
15fcbc9596 Cleanup: Remove COMPILE_FOR_RAM option from linker scripts
This option was added way back in January 2012 for early EC
bringup, and never used since. We can probably remove it.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: Idc8c3099388f2e28d620848a0e78b555b02fba9c
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/297334
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
2015-09-08 10:38:21 -07:00
Anton Staaf
7bdb69c464 UART: Remove unused uart.h header includes
Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: Ife068807f79f6435292643c49afa1a9a30ae7080
Reviewed-on: https://chromium-review.googlesource.com/296733
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-08 10:38:20 -07:00
Anton Staaf
fba4f335a9 cortex-m0: Constrain target register in atomic read
One more register constaint needed to be added to the cortex-m0 atomic
inline assembly.  Vincent fixed all the others.  The requirement for
ARMv6-m includes that the target load register be one of the low
registers as well.

Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: Ie44e824cafcc9b862ade664e3016cc34886cdf6e
Reviewed-on: https://chromium-review.googlesource.com/292435
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-08-11 19:52:40 +00:00
Anton Staaf
4626177c3b Atomic: Mark the modified uint32_t volatile
The atomic_* functions are often used in contexts where the data they
will operate on are volatile (due to being shared between tasks or a
task and an interrupt handler).  Adding volatile here makes using the
atomic_* functions a little easier in those cases and removes a cast
from the call sites (which could be obscuring a bug, if for instance
the variable was modified to be a uint16_t).

Signed-off-by: Anton Staaf <robotboy@chromium.org>

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

Change-Id: I71356eb3cf2c0506df38532eee767c7d78f9240e
Reviewed-on: https://chromium-review.googlesource.com/287516
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
2015-07-27 19:30:44 +00:00
Aseda Aboagye
ce063e0829 build-infr: Add support for shared RO library.
This commit introduces the build infrastructure changes needed for
creating a shared RO library. (libsharedobjs).  The end goal is for the
library to contain various objects that can be shared with both the RO
and RW EC images.

Now, there are 3 make goals: ro, rw, and libsharedobjs.

In order for changes that are only specific to a single image (ie: RW
only) to be applied correctly, the object files are now built separately
for the RO, RW, shared objects library targets.

NOTE: Certain EC targets are incompatible with this model due to the
fact that only one image is present within flash at a time.

BRANCH=none
BUG=None
TEST=make -j buildall tests
TEST=make -j BOARD=cr50 xrefs
TEST=make BOARD=samus dis
TEST=Built samus EC image and compared that the final EC image was
identical to the upstream version (except for the git SHAs & version
strings).

CQ-DEPEND=CL:285934

Change-Id: I8e67f089710be9c6d7017718109262394bdad2f5
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/274079
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
2015-07-17 03:17:50 +00:00
Aseda Aboagye
fbc84dc565 hooks: Move HOOK_INIT to after task switching.
This commit changes the way in which tasks are started.  Instead of
having all tasks marked as ready to run upon initialization, only the
hooks task is marked as ready to run.  HOOK_INITs are now run at the
beginning of the hooks task.  After the HOOK_INITs, the hooks task calls
back to enable the rest of the tasks, reschedules, and proceeds as
usual.  This also allows the removal of checks for task_start_called().

BUG=chrome-os-partner:27226
BRANCH=None
TEST=Built and flash EC image for samus and verified that EC boot was
successful as well as AP boot.  Additionally, verified that charging,
keyboard, tap-for-battery were all still functional.
TEST=make -j buildall tests

Change-Id: Iea53670222c803c2985e9c86c96974386888a4fe
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/283657
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
2015-07-13 18:43:56 +00:00
Bill Richardson
104f811e67 cleanup: fix all the header guards
This unifies all the EC header files to use __CROS_EC_FILENAME_H
as the include guard. Well, except for test/ util/ and extra/
which use __TEST_ __UTIL_ and __EXTRA_ prefixes respectively.

BUG=chromium:496895
BRANCH=none
TEST=make buildall -j

Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Change-Id: Iea71b3a08bdec94a11239de810a2b2e152b15029
Reviewed-on: https://chromium-review.googlesource.com/278121
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-06-18 19:07:00 +00:00