Commit Graph

59 Commits

Author SHA1 Message Date
Scott Worley
4e9588ddcf ec_chip_mchp: Add MCHP chip folder
BRANCH=none
BUG=
TEST=Review only. Committing small pieces until
all code passes review.

Change-Id: I9d16f95314a7c97b11c4fe61602c6db2621e6024
Signed-off-by: Scott Worley <scott.worley@microchip.corp-partner.google.com>
2017-12-28 12:35:07 -08:00
Stefan Reinauer
e11682bc01 BUILDCC fragments should include core/host
This will prevent userland code to pull in includes
from core/stm32 etc.

Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
BRANCH=none
BUG=none
TEST=make buildall -j

Change-Id: I450b17baf579cbaee04c253c1e86d998f6e329da
Reviewed-on: https://chromium-review.googlesource.com/618270
Commit-Ready: Stefan Reinauer <reinauer@google.com>
Tested-by: Stefan Reinauer <reinauer@google.com>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2017-08-21 14:47:27 -07:00
Che-yu Wu
1bf7abdc20 ec: Add analysis tool for firmware stack usage.
Add a static analysis tool for firmware stack usage.
Add an new Makefile rule to analyze the stack usages of firmwares.

Details about the tool can be found in extra/stack_analyzer/README.md.

BUG=chromium:648840
BRANCH=none
TEST=extra/stack_analyzer/stack_analyzer_unittest.py
     make BOARD=elm && make BOARD=elm build/elm/RW/ec.RW.taskinfo && \
         extra/stack_analyzer/stack_analyzer.py \
         --objdump=arm-none-eabi-objdump \
         --addr2line=arm-none-eabi-addr2line \
         ./build/elm/RW/ec.RW.elf ./build/elm/RW/ec.RW.taskinfo
     make BOARD=${BOARD} SECTION=${SECTION} analyzestack

Change-Id: Ifb1b5f5ad6be8f8b125b14d6ee03e25cb385895b
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/576411
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-08-14 05:54:35 -07:00
li feng
db6391a64f toolchain: set correct toolchain when buildall
In the "make buildall", since no BOARD is defined, core/minute-ia
has to use whatever toolchain value set by previous board build.
"arm-none-eabi-" is used instead of "i686-pc-linux-gnu-" and causes
build failed.

BUG=none
BRANCH=None
TEST=Including Soraka ISH board, make buildall passed.

Change-Id: I2682e4b73f608756842870e584f559166354b00b
Signed-off-by: li feng <li1.feng@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/595221
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Li1 Feng <li1.feng@intel.com>
Reviewed-by: Kyoung Il Kim <kyoung.il.kim@intel.com>
2017-08-01 16:22:05 -07:00
Che-yu Wu
9078f12394 core: Fix missing debug symbol when enabling LTO
Add "-g" to "LDFLAGS" for preserving debug symbol when enabling LTO.

BUG=chromium:742697
BRANCH=none
TEST=make BOARD=eve -j
     arm-none-eabi-objdump -h build/eve/RW/ec.RW.elf | grep debug_loc
  7 .debug_loc    00027bf0  00000000  00000000  0009a549  2**0

Change-Id: I6b2b00846ce71002262a10357fd4dccbe82b6e6f
Signed-off-by: Che-yu Wu <cheyuw@google.com>
Reviewed-on: https://chromium-review.googlesource.com/575312
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
2017-07-19 22:10:53 -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
Daisuke Nojiri
a82421df00 eCTS: Print start marker before sync
This patch makes each test print start marker before sync. This will
allow us to distinguish the failure before even sync is attempted
(CTS_RC_DID_NOT_START, thus probably caused by the previous test)
and the failure caused by the hanging partner, in which case the one
good and alive will be stuck in sync (and should return _DID_NOT_END
or even better _BAD_SYNC once we implement timeout in sync).

This patch also:

* Adds did_not_start_test to and removes debug_test from meta suite
* Consolidates test runner loops into common cts_main_loop
* Removes dut_common.h and th_common.h
* Removes debug print macro and CTS_DEBUG
* Replaces all infinite loops after tests with task_wait_event(-1)
* Removes meaningless comments and debug printfs
* Removes CTS_TEST_ID_*
* Adds sync() to task suite

BUG=chromium:736104
BRANCH=none
TEST=Run run_ects.sh and verify all tests pass

Change-Id: I6ccdf26afac6b8e8cb16483c5d75e4e77e7962f4
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/545176
2017-06-27 15:52:06 -07:00
Nicolas Boichat
896409ef79 Makefile: Allow different task list for RO and RW
This adds new macros for tasks (_RO and _RW), which allows to
enable a task only for RO or RW section.

We also create a new task_filter.h include file, that helps
pre-filter those tasks, and can be used either from Makefile,
or included from task_id.h.

BRANCH=none
BUG=b:35582031
TEST=make buildall -j; make savesizes
     Apply this CL
     make buildall -j; make newsizes => No size change

Change-Id: I472bc6d4ab250a0a0e1fa6aeb4b748ba6968bedf
Reviewed-on: https://chromium-review.googlesource.com/479491
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Reviewed-by: Nick Sanders <nsanders@google.com>
2017-04-25 05:52:34 -07:00
Randall Spangler
5e1c63f6eb Support alignment for EC host command structures
The host command parameter and response buffers should be explicitly
aligned by the LPC/SPI/I2C drivers.  But the host command handlers don't
know that, and the structs are all __packed, so the compiler generates
horribly inefficient ARM Cortex-M code to cope with unaligned accesses.

Add __ec_align{1,2,4} to force the param / response structs to be
aligned.  Use it in a few structs now which were straightforward to
test.  It should be added to more structs as space is needed, but that
would make this change unwieldy to review and test.

Add CONFIG_HOSTCMD_ALIGNED to enable the additional alignment.
Currently, this is enabled only for LM4 and samus_pd, so that EC code
can be tested without affecting other non-samus ToT development (none of
which uses LM4).

Fix the two handlers that weren't actually aligned (despite one of
them having comments to the contrary).

Also, add a CHROMIUM_EC define that can be used to determine if a file
is being compiled for an EC target.  We need that so that we only force
structure alignment for EC binaries.  On the AP side, buffers may not be
aligned, so we should not force alignment.

BUG=chromium:647727
BRANCH=none
TEST=Flash samus and samus_pd.  Boot samus and run a bunch of ectool
     commands (with and without --dev=1, so it tests both EC and PD).
     System boots and all commands return expected results.

Change-Id: I4537d61a75cf087647e24281288392eb85f22eba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/387126
2016-10-19 20:07:09 -07:00
Martin Roth
88428882b8 Makefile.toolchain: Add error if make version will not build the EC
If you try to build the EC codebase with GNU make version 3.81 or
less, you currently get an error:
Makefile.rules:286: *** multiple target patterns.  Stop.

Since this message isn't helpful in letting you know that the version
of make needs to be updated, let's print something more useful.
ERROR: GNU make version 3.82 or higher required. Stop.

TEST=Built with Make 3.81 and saw the new error message. Built with
make 3.82 and 4.0 and the EC built correctly.
BRANCH=None
BUG=None

Change-Id: I5813fd26fa8120742544567c5ae04af01f993f94
Signed-off-by: Martin Roth <martinroth@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367944
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2016-08-12 13:45:32 -07:00
Chris Chen
67f6964aef cts: Debug message support added to cts tests
You can now add debug messages into a cts test and
they will be displayed with the test report html page.

The macro to use is CTS_DEBUG_PRINTF

Adding debug messages can potentially change test
results by slowing down the test, so you can choose
when compiling a test suite if you want the debug
messages present or not by adding --debug as an
argument when you call ./cts --build.

BRANCH=None
BUG=None
TEST=Manual
- Add a debug statement to a test
- Build the test suite with --debug specified
- Flash the boards
- Run './cts/cts.py -r'
- Open /tmp/cts_results/<board_name>/<test_suite>.html
  to view see your debug message for the test

Change-Id: Icad8e0ac5cc905010caa4e7616f81572ce6ac771
Reviewed-on: https://chromium-review.googlesource.com/362475
Commit-Ready: Chris Chen <twothreecc@google.com>
Tested-by: Chris Chen <twothreecc@google.com>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-08-10 15:30:25 -07:00
Daisuke Nojiri
b3b92f45fd cts: Move C flags to cts/build.mk
We should separate global Makefile from CTS stuff as much as possible.
This makes reading and chaging code simpler.

BUG=none
BRANCH=none
TEST=make buildall

Change-Id: If9e99e0e9b660707b1e22f2362bd6f782930dc09
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/363006
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Chris Chen <twothreecc@google.com>
2016-07-26 15:16:46 -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
Chris Chen
aae621d6c5 cts: First patch flashes blank tests
The first time you use this with a particular th,
connect only th and run ./cts.py --th

Then connect both boards and you can run
./cts.py to build/flash both boards.

BRANCH=None
BUG=None
TEST=manual
- Enter chroot
- Navigate to ec/cts
- Connect only th
- 'sudo ./cts.py --th'
- './cts.py -b'
- Exit chroot
- Connect both boards
- './cts.py -f'
Each board should flash successfully

Change-Id: Ib14fccabcd9fdad04f9b92817da597bc0dcb3d89
Reviewed-on: https://chromium-review.googlesource.com/358100
Commit-Ready: Chris Chen <twothreecc@google.com>
Tested-by: Chris Chen <twothreecc@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-07-09 01:41:01 -07:00
Bill Richardson
7abeeeaad2 cleanup: Makefiles should check path assumptions
When compiling the EC firmware outside of the chroot, some
optional packages may not be installed. Let's be sure the tools
exist before we try to use them.

BUG=none
BRANCH=none
TEST=make buildall, both inside and outside of the chroot

Note that to build outside the chroot, we need to

1. Use GNU make verion 4.1 or later
2. Install the gcc-arm-none-eabi package

Change-Id: I78c75cb4ad658c003ded71b244b0458ae5532e0b
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/337341
Reviewed-by: Shawn N <shawnn@chromium.org>
2016-04-05 22:00:44 -07:00
Stefan Reinauer
bc404c94b4 Enforce compilation without system headers
This patch introduces HOST_CPPFLAGS to be used for all
objects being compiled with HOSTCC rather then the target
compiler.

Since glibc is not linked into the EC, no glibc include files
should be included in the EC code base. Hence, create local
definitions for clock_t and wchar_t that match what the glibc
include would have done, and remove some unneeded includes.

Due to very eager optimization, we have to give gcc a little
notch to not kick out memset.

Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
BUG=chrome-os-partner:43025
BUG=chrome-os-partner:49517
BRANCH=none
TEST=compile tested

Change-Id: Idf3a2881fa8352756b0927b09c6a97473358f239
Reviewed-on: https://chromium-review.googlesource.com/322435
Commit-Ready: Patrick Georgi <pgeorgi@chromium.org>
Tested-by: Patrick Georgi <pgeorgi@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@chromium.org>
2016-02-03 15:00:50 -08:00
Anton Staaf
7b89bb029e Build: Use ccache to speed up builds
This almost halves buildall times on my machine.  Aseda reminded me
of ccache.

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

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

Change-Id: I819eb1e9558a65fef5bd188c487115609da8ab92
Reviewed-on: https://chromium-review.googlesource.com/321911
Commit-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-01-19 14:24:45 -08:00
Bill Richardson
735e5a6ee2 Define SECTION=* and SECTION_IS_* when compiling
The linker scripts are passed through the preprocessor so that
they can distinguish between RO and RW images. This change makes
the same macros available when compiling, so that code can
contain directives like

  #ifdef SECTION_IS_RO

or

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

  int size = FW_SIZE(SECTION);

BUG=none
BRANCH=none
TEST=make buildall

Nothing uses this yet, so there's no change to the images.

Change-Id: I6e03cd07c134f4b86aeddd9d516b74bbdb95b8a8
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/301255
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-09-21 11:23:27 -07:00
Vadim Bendebury
9005ddd4bc cr50: add plumbing for signing CR50 RO images
The signer utility needs to be built and the flat image needs to be
signed. The signer utility is written in C++, supporting this required
adding a new make command to Makefile.rules and a build file for the
utility.

The signing now needs to be a part of generating the .flat file. To
achieve this an alternative set of rules is defined in Makfile.rules
for targets where RO image needs to be signed.

Rules for converting elf to hex have been consolidated as there is no
need to omit the --set-section-flags when it does not apply.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=as follows:
    - ran 'rm build/cr50; make BOARD=cr50'
    - observed that both build/cr50/ec.bin and
      build/cr50/RO/ec.RO.flat have the required signature header in
      the first 1024 bytes.
   - verified that the cr50 board can be booted over SPI using the
     image in build/cr50/RO/ec.RO.flat

Change-Id: Iacc22561de67fadfaf8e049bf9578cbd08cfad86
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/295291
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
2015-08-25 21:31:33 +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
Vincent Palatin
2650ff3d70 Add option to enable GCC LTO
Add CONFIG_LTO to use GCC Link-Time Optimizations to try to reduce the
flash footprint of the firmware.

Add additional protection to some functions/data to avoid removal by the
linker when their usage is not obvious.

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

BRANCH=none
BUG=none
TEST=make buildall (with and without LTO enable on all boards)

Change-Id: I586b8c1eda4592b416c85383b65153c1d5ab0059
Reviewed-on: https://chromium-review.googlesource.com/271291
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2015-05-19 02:46:27 +00:00
Vincent Palatin
24f4e36d82 Use GCC instead of LD to trigger the linker
Invoke the linker through gcc rather than directly with ld.
This will allow us to use some more advanced features : e.g. LTO.

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

BUG=none
BRANCH=none
TEST=make buildall
then compare manually old and new binaries

Change-Id: I101b1edbaebd5628624a5a8c12d5c0b5fa9e2c50
Reviewed-on: https://chromium-review.googlesource.com/271290
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
2015-05-15 19:15:32 +00:00
Vadim Bendebury
1f09bd7c46 make: add generation of sorted symbol maps
Sorted symbol maps are useful when one wants to look up an address to
associate it with a function or a variable, or to estimate how much
room certain components of the image take.

This patch adds a rule and creates a dependency to make sure that
sorted maps (assigned extension .smap) are generated during builds.

BRANCH=none
BUG=none
TEST=make buildall -j
   observed 91 .elf files and 89 .smap files generated.
   the two images not triggering .smap file generation are

    build/npcx_evb/chip/npcx/lfw/ec_lfw
    build/npcx_evb/chip/npcx/spiflashfw/ec_npcxflash

  they could be added in a follow up patch if deemed necessary.

Change-Id: I196a2ffe059a83481b7a313617d516634762dc60
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/270117
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-05-11 18:38:30 +00:00
Vincent Palatin
a97af9a8b2 Move target specific GCC code generation options
Move "-fno-delete-null-pointer-checks -fconserve-stack" to the
target-only portion of the CFLAGS as they are no needed for host tools
(and not supported by clang).

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

BRANCH=none
BUG=chromium:475960
TEST=make utils-host V=1
make BOARD=samus_pd V=1
and manually check the compilation flags

Change-Id: I001359621d60b5ad4e020f41fe2e97d4b7edec2a
Reviewed-on: https://chromium-review.googlesource.com/266212
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-04-18 01:26:55 +00:00
Vincent Palatin
ccb46f6d8e twinkie: build a combined firmware
Build a Twinkie firmware image with the regular Twinkie sniffer firmware
in the RO partition and a firmware behaving as a USB PD sink in the
RW partition.

The user can call the "twinkie sink" command to switch the USB PD sink
firmware in the RW partition (and call "reboot" if he changes his mind
and wants the sniffer back).

Restore the ability of building different tasklists which was broken
where the tests build was simplified.

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

BRANCH=none
BUG=none
TEST=make buildall
./board/twinkie/build_rw_variant
Try "twinkie sink" command on a Twinkie with the combined firmware.

Change-Id: Ie489ce97a774ae7a22ac639c49a3d6e412e62de8
Reviewed-on: https://chromium-review.googlesource.com/237221
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2015-01-08 23:55:58 +00:00
Alec Berg
e913bc15b8 samus: add host commands for flashing zinger RW
This adds a new host commmand for sending RW updates to PD devices.
The host command has a variety of sub-commands for performing the
update, including: erase RW, reboot, write new hash, write flash.

To program zinger RW, you should send host commands in this order:
write new hash to all 0's
reboot (zinger boots into RO since RW hash doesn't match)
erase RW
write flash
write new hash to match contents of RW
reboot

This also adds an ectool command to write a new RW. Just pass it
the RW .flat or .bin file.

BUG=chrome-os-partner:31361
BRANCH=none
TEST=ectool --dev=1 --interface=lpc flashpd 0 0 zinger.RW.flat

Change-Id: Ia81615001b83ad7ee69b1af2bf1d7059177cde04
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/213239
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-08-26 23:06:23 +00:00
Vincent Palatin
5fa52a895b stm32: add USB driver
Enough USB support to be able to enumerate the device and use bulk or
interrupt endpoints.

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

BRANCH=none
BUG=chrome-os-partner:28295
TEST=with the following USB console CL, connect a Fruitpie through USB
and use its console over USB.

Change-Id: I37b7f3b6a754cb82ab5f940ea20122d2e16b3b5b
Reviewed-on: https://chromium-review.googlesource.com/193983
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Todd Broch <tbroch@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2014-06-18 06:08:45 +00:00
Vincent Palatin
2476ae11fc discard unused functions at link time
Put each functions in a separate section by using -ffunction-sections,
then discard the non-referenced ones in the linker with -gc-sections.
Force keeping a few special symbols by using the KEEP() linker
directive.

This modification is not saving a lot of spaces per se, but will enable
larger code pruning with future optional features.

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

BRANCH=none
BUG=none
TEST=make buildall, manually check discarded symbols in the .map file
and run on Spring and Link.
The size delta is the following:
Link: total 85.7k -> 84.9k (.text 60.3k -> 59.5k)
Spring: total 59.2k -> 57.2k  (.text 44.4k -> 42.5k)

Change-Id: Ib6eb0d3f2cc4fc172c9fc26acac2e486921690a3
Reviewed-on: https://chromium-review.googlesource.com/189224
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
2014-03-11 05:53:53 +00:00
Alec Berg
89cae30e57 Added unit tests for lid angle calculation and acos
Added unit test for motion_sense lid angle calculations.
Added unit test for math_util arc_cos() function.

BUG=none
Original-BUG=chrome-os-partner:25640
BRANCH=rambi
TEST=make buildall

Original-Change-Id: I35debf6fc0e2d9996debc2ede175acaa060df627
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/186720
Reviewed-by: Vic Yang <victoryang@chromium.org>
(cherry picked from commit 55c3e8ee14693d6d667b5d21f0dcbb14d185ccbe)

Change-Id: I017315128f318424cd3000affae785c69afd29d6
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/187434
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-02-22 00:49:56 +00:00
Vic (Chun-Ju) Yang
61d2652ca4 Dump stack trace on emulator test failure
Emulator test failures are sometimes hard to debug, especially when the
test is stuck somewhere and times out. Let's have the emulator dump
stack trace when an assertion fails or a test times out.

The produced stack trace is in this format:
  #0  build/host/kb_8042/kb_8042.exe() [0x412421]
      /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:104
  #1  build/host/kb_8042/kb_8042.exe() [0x4124a9]
      /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:129
  #2  build/host/kb_8042/kb_8042.exe(run_test+0x3a) [0x412e2c]
      /home/victoryang/trunk/src/platform/ec/test/kb_8042.c:262
  #3  build/host/kb_8042/kb_8042.exe(_run_test+0x11) [0x4061de]
      /home/victoryang/trunk/src/platform/ec/core/host/task.c:90
  #4  build/host/kb_8042/kb_8042.exe(_task_start_impl+0x79) [0x406b72]
      /home/victoryang/trunk/src/platform/ec/core/host/task.c:408
  #5  /lib64/libpthread.so.0(+0x70b1) [0x7f6dc2fa10b1]
      ??:0
  #6  /lib64/libc.so.6(clone+0x6d) [0x7f6dc2cd8efd]
      ??:0
The file name and line number in the trace is generated by addr2line.

BUG=chrome-os-partner:19235 chromium:331548
TEST=Put in a infinite loop in a test, and see stack trace when it times
out.
TEST=Add a failing assertion, and see stack trace when it fails.
BRANCH=None

Change-Id: I4494ffd1ebc98081ce40e860a146202084aa2a1e
Signed-off-by: Vic (Chun-Ju) Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/181730
2014-01-08 16:39:24 +00:00
Randall Spangler
e5935f17d1 cleanup: Remove mixed-case macros
We've had uppercase macros (BOARD_FOO) for a week for

   PROJECT_
   BOARD_
   CORE_
   CHIP_
   CHIP_FAMILY_
   CHIP_VARIANT_

and I've just made a pass to fix the last leftover mixed-case usage
from changes that were in flight when I made the initial cleanup.  It
is now time to remove the old mixed-case macros (BOARD_foo).

BUG=chromium:322144
BRANCH=none
TEST=Build all boards.  Diff build/$(BOARD)/ec.RO.map before and after
     this change.  Should be no changes - indicating that the same code
     was compiled before and after.

Change-Id: Ic5a1e83d31be4b8e9fdbacc3eb10176fd126d84a
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/180384
2013-12-19 00:12:24 +00:00
Randall Spangler
f749c9363c Fix uppercased macros
The macros must be defined prior to evaluating config.h, since
test_config.h needs them.

Also define an uppercase version of the PROJECT variable, so that we
define TEST_FOO in addition to TEST_foo.

BUG=chromium:322144
BRANCH=none (but might need it if you later cherry-pick something with
       an uppercase #ifdef BOARD_FOO
TEST=Build each board with V=1 option: 'make V=1 BOARD=foo all tests'.
     Check that the compile command line has both mixed-case and
     uppercase defines.  Check that per-board tests from test/build.mk
     were built (for example, BOARD_PIT should compile kb_scan and
     stress, and BOARD_SAMUS should build none of them).

Change-Id: I029552cfdf90a4191cf7a61cdcc65fe75d3ca86c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179902
Reviewed-by: Vic Yang <victoryang@chromium.org>
2013-12-13 21:22:19 +00:00
Randall Spangler
bc11760a58 Add uppercase defined constants for BOARD_, CHIP_, etc.
Currently, per-board defines use mixed case (BOARD_pit).  This causes
the presubmit script to complain because that's a style violation.
Using --no-verify to bypass that also allows other style violations to
creep in.

This change adds uppercase variants (BOARD_PIT).  It also adds a CORE_
define with '-' changed to '_', since CORE_cortex-m isn't a valid
symbol but CORE_CORTEX_M is (so now we can #ifdef CORE_CORTEX_M).

This does not remove the old mixed-case defines yet, nor does it
find/replace them in the C source files.  This is intentional, so this
change can be cherry-picked into branches without needing to change
files in the branch that may have picked up new #ifdefs.

I will rename the constants in the C source files and remove the old
mixed-case defines in a follow-on CL, which should not need to get
picked into existing branches.

BUG=chromium:322144
BRANCH=none (but might need it if you later cherry-pick something with
       an uppercase #ifdef BOARD_FOO
TEST=Build each board with V=1 option: 'make V=1 BOARD=foo all tests'.
     Check that the compile command line has both mixed-case and
     uppercase defines.  Check that per-board tests from test/build.mk
     were built (for example, BOARD_PIT should compile kb_scan and
     stress, and BOARD_SAMUS should build none of them).

Change-Id: I5eb0d1fe57f1c694d7449e5f148e2f13fb290a39
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/179205
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-12-09 18:29:12 +00:00
Vincent Palatin
03de7bee72 Move core-specific toolchain configuration to core/ directory
This is preparatory work to introduce a second core architecture.

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

BRANCH=none
BUG=chrome-os-partner:23574
TEST=./util/make_all.sh

Change-Id: Icae8a7e475a4ba2a13f0d8f95629e8498a5a61da
Reviewed-on: https://chromium-review.googlesource.com/175419
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
2013-11-07 22:36:05 +00:00
Randall Spangler
2ad076f8a0 cleanup: Rename and move header files
Device-specific headers belong in driver/ or chip/.  The include/
directory should be for common interfaces.

Code should not normally need to include driver-specific headers.  If
it does, it should use the full relative path from the EC project root
(for example, drivers/charger/bq24715.h).

Change-Id: Id23db37a431e2d802a74ec601db6f69b613352ba
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/173746
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2013-10-23 21:27:40 +00:00
Vic Yang
19e30d9c7d Remove proxy config flags for unit tests
This moves per-test config flags from test_config.mk to test_config.h,
where one can define/undefine config flags for individual test.

BUG=chrome-os-partner:19235
TEST=Pass all tests
BRANCH=None

Change-Id: I096aded2007881433d3b6414d37f8bfdc6a2c45c
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/64367
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-08-04 13:11:08 -07:00
Vic Yang
2475cce9ad Add I8042 keyboard unit test
This tests I8042 scancode and typematic.

BUG=chrome-os-partner:19236
TEST=Pass all tests many times.
BRANCH=None

Change-Id: I8457b7b807b694b0bae32abf1647961f946dc5e1
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/61553
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2013-07-11 22:32:52 -07:00
Randall Spangler
d3dffe2532 stm32: Add CHIP_FAMILY defines
Previously, code which needed to work on all STM32F platforms needed
to specify them by name (CHIP_VARIANT_stm32f100 ||
CHIP_VARIANT_stm32f10x), and we needed extra symlinks in the
chip/stm32/ directory to allow the build system to find
family-specific files.

Add a CHIP_FAMILY level of abstraction, so that things which are
common across all STM32F platforms don't need to specify every STM32F
variant.  Make the chip build look for family-specific filenames
instead of variant-specific filenames (except for config*.h, which is
actually variant specific).

In the few places where things actually are variant-specific, keep
using the existing CHIP_VARIANT defines.

Code refactoring only; no functional changes.

BUG=chrome-os-partner:20567
BRANCH=none
TEST=build all platforms

Change-Id: I1da831aadabf8b8dd9dfde423cac13c9f43eb953
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60247
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2013-07-01 10:19:49 -07:00
Vic Yang
aaac3935d2 Make target for test coverage report generation
By 'make coverage', lcov is used to generate test coverage report in
HTML format stored in coverage_rpt folder.

BUG=chrome-os-partner:19235
TEST=Generate a report.
BRANCH=None

Change-Id: I44142eaaeb897cf09179764781120370920144cd
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/58203
2013-06-16 20:14:01 -07:00
Vic Yang
ce9d7ca9e9 Revert "Revert "Scale timer for emulator""
This reverts commit c58c01b14c.

Let's add time scaling back, but keep the default scale to 1. The
emulator behavior should be entirely the same. If a test need to be
speeded up, the scale can then be set for that test only.

BUG=chrome-os-partner:19235
TEST=Pass all tests.
BRANCH=None

Change-Id: I648780577a1ae2f964c30c71077ccf9bf38b9735
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/51550
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-17 09:52:25 -07:00
Vic Yang
c58c01b14c Revert "Scale timer for emulator"
This is causing instability on buildbot. Let's revert until we can make it more stable.

This reverts commit 3615ac4c0b

Change-Id: I0bd65832cc3706a24284ada80e2fb5102fa705cf
Reviewed-on: https://gerrit.chromium.org/gerrit/51479
Commit-Queue: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-16 10:08:22 -07:00
Vic Yang
3615ac4c0b Scale timer for emulator
The timer is the only source of timing for the emulator. This means we
can make it go faster without breaking the tests. This CL sets the
default scale to be 3x faster than normal time.

BUG=chrome-os-partner:19235
TEST=Pass all tests. Check the tests run faster.
BRANCH=None

Change-Id: Ib9035884b34f41c4e9aa2206284b5f1ec8fc0d1f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50956
2013-05-14 00:31:40 -07:00
Vic Yang
5007bbc009 Use uintptr_t when converting integer from/to pointer
Perviously we use uint32_t for this, but this doesn't compile for 64-bit
environment (and likely doesn't for 16-bit either.) Use uintptr_t so that
we don't get size mismatch errors.

BUG=chrome-os-partner:19257
TEST=Run host emulated tests
BRANCH=None

Change-Id: I3cd66a745fa171c41a5f142514284ec106586acb
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/50358
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-07 20:59:53 -07:00
Vic Yang
0a45fa1708 Pthread-based emulator for unit testing
This is the first version of pthread-based RTOS emulator. With this, we
will be able to test high-level modules entirely on the host machine.

BUG=chrome-os-partner:19325
TEST='make runtests' and see tests passing.
BRANCH=None

Change-Id: I1f5fcd76aa84bdb46c7d35c5e60ae5d92fd3a319
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49954
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
2013-05-07 09:09:50 -07:00
Todd Broch
357e508392 Allow either libftdi or libftdi1 at compile time.
Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=none
BUG=chromium:222299
TEST=manual, from chroot:

1. Install libftdi1 (https://gerrit.chromium.org/gerrit/#/c/44731/)
2. cd <path>/ec && make -B
   - compiles successfully
3. Install libftdi
4. cd <path>/ec && make -B
   - still compiles successfully

Change-Id: I6818d53faa1389937872b0a9826534db4760e448
Reviewed-on: https://gerrit.chromium.org/gerrit/47875
Tested-by: Todd Broch <tbroch@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Todd Broch <tbroch@chromium.org>
2013-04-16 09:43:45 -07:00
Vic Yang
8a06eb1d35 Only includes necessary tasks for test binaries
This changes current TASK() syntax to TASK_BASE() and TASK_NORMAL(),
where TASK_BASE is necessary for the EC to boot on a board and
TASK_NORMAL represents the task that can be removed in a test binary.

Tasks introduced by a test should be listed as TASK_TEST().

Note that this CL breaks current tests (many of them are broken anyway),
which will be fixed in up coming CLs.

BUG=chrome-os-partner:18598
TEST=Build link/bds/spring/snow/daisy/mccroskey. (mccroskey failed for
unrelated issue)
BRANCH=none

Change-Id: Ic645cdae0906ed21dc473553f1f43c2537ec4bb9
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/47531
2013-04-10 01:08:45 -07:00
Vincent Palatin
fbfd828b9a simple and self-contained EC flashing tool
This produces a host binary running on the application processor and
which is able to re-flash th EC firmware over the AP-to-EC link (either
LPC or I2C).
The payload (ie the EC firmware) to use is embedded inside the flasher
binary.

This is just aimed at testing and developer upgrade. The auto-update
flow is using flashrom.

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

BUG=None
TEST=build for link/daisy/snow/bds and tests
On Snow, run burn_my_ec from the serial console and see that the EC was
correctly re-flashed.

Change-Id: I7f90e773678a7ef3d8dc6dbacf54e80f3294607b
Reviewed-on: https://gerrit.chromium.org/gerrit/24236
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
2012-05-31 16:28:06 -07:00
Vic Yang
b8a2a4b575 Add a way to pass in define flag when 'make'
In order to pass in different config from ebuild and enable easier
debugging/testing, let's add a way to pass in define flags to make.

BUG=chrome-os-partner:9936
TEST='V=1 EXTRA_CFLAGS=-DFACTORY_MODE make' and see '-DFACTORY_MODE'.

Change-Id: I18dc5a3dc61bda1e63e96081def3f077ba431938
2012-05-24 23:06:28 +08:00
Bill Richardson
8101b71316 Enable verified boot for EC firmware
BUG=chrome-os-partner:7459
TEST=manual

In the chroot:

  cd src/platform/ec
  make BOARD=link

The firmware image (build/link/ec.bin) is signed with dev-keys. Reflash the
EC and try it, and it should verify and reboot into RW A.

Additional tests (setting USE_RO_NORMAL, poking random values into VBLOCK_A
or FW_MAIN_A to force RW B to run, etc.) are left as an exercise for the
reader. I've done them and they work, though.

Change-Id: I29a23ea69aef02a11aebd4af3b043f6864723523
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
2012-05-10 17:27:36 -07:00
Vincent Palatin
a9ceb116c7 introducing chip variant for stm32 family [2/3]
Add a parameter to define the chip variant and pass it to build/make
processes.

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

BUG=chrome-os-partner:9057
TEST=make BOARD=daisy ; make BOARD=adv ; make BOARD=discovery

Change-Id: I87b65b582ed5fc2cf5966446e15224ac15e328e9
2012-05-01 17:13:33 -07:00