Chrome EC

From coreboot
Revision as of 00:28, 16 January 2016 by Stepan (talk | contribs) (Building outside of the ChromiumOS chroot)
Jump to: navigation, search

The wiki is being retired!

Documentation is now handled by the same processes we use for code: Add something to the Documentation/ directory in the coreboot repo, and it will be rendered to https://doc.coreboot.org/. Contributions welcome!

Chrome EC

The Chrome EC is used in almost all Chrome OS devices, and an increasing number of accessories, like Google's Type C chargers. It is based on the Chromium EC code base.

Building the Chrome EC

Building in the ChromiumOS environment

Getting started building EC images quickly

Building outside of the ChromiumOS chroot

You will need:

  • GNU Make 4.1 (older versions are having trouble with the Makefiles)
  • an ARM cross compiler (I used coreboot's armv7-a-eabi- toolchain)

Patching up the code:

diff --git a/Makefile.toolchain b/Makefile.toolchain
index f015726..759dfb0 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -48,6 +48,9 @@ CFLAGS=$(CPPFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEBUG) $(CFLAGS_WARN) $(CFLAGS_y)
 CFLAGS+= -ffunction-sections -fshort-wchar
 CFLAGS+= -fno-delete-null-pointer-checks -fconserve-stack
 
+CFLAGS+= -ffreestanding
+CPPFLAGS+= -ffreestanding
+
 FTDIVERSION=$(shell $(PKG_CONFIG) --modversion libftdi1 2>/dev/null)
 ifneq ($(FTDIVERSION),)
   LIBFTDI_NAME=ftdi1

and

diff --git a/include/timer.h b/include/timer.h
index 5f92207..1a43604 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -8,7 +8,7 @@
 #ifndef __CROS_EC_TIMER_H
 #define __CROS_EC_TIMER_H
 
-#include <sys/types.h>
+typedef long clock_t;
 
 #include "common.h"
 #include "task_id.h"

Let's go:

$ sudo aptitude install libftdi-dev
$ git clone https://chromium.googlesource.com/chromiumos/platform/ec
[..]
$ cd ec
$ CROSS_COMPILE=armv7-a-eabi- HOST_CROSS_COMPILE= make BOARD=chell
[..]
$