xref: /aosp_15_r20/external/gsc-utils/docs/getting_started_quickly.md (revision 4f2df630800bdcf1d4f0decf95d8a1cb87344f5f)
1# Get Started Building EC Images (Quickly)
2
3[TOC]
4
5The
6[Chromium OS Developer Guide](https://chromium.googlesource.com/chromiumos/docs/+/main/developer_guide.md)
7and [README](../README.md) walk through the steps needed to fetch and build
8Chromium OS source. These steps can be followed to retrieve and build EC source
9as well. On the other hand, if your sole interest is building an EC image, the
10general developer guide contains some extra unneeded steps.
11
12The fastest possible way to build an EC image is to skip the Chromium OS chroot
13install entirely. The following steps have been tested on an Ubuntu 15.10 (Wily
14Werewolf) 64-bit host machine. Other distros / versions may be used, but
15toolchain incompatibilities may require extra debug.
16
17## Building
18
191.  Install build / dev tools:
20
21    ```bash
22    sudo apt-get install git libftdi-dev libusb-dev libncurses5-dev gcc-arm-none-eabi
23    ```
24
251.  Sync the cros-ec git repo:
26
27    ```bash
28    git clone https://chromium.googlesource.com/chromiumos/platform/ec
29    ```
30
311.  Build your EC image:
32
33    ```bash
34    HOSTCC=x86_64-linux-gnu-gcc make BOARD=$board
35    ```
36
37## External Dependencies
38
39Most boards are buildable, but some will fail due to dependencies on external
40binaries (such as [`futility`](#building-futility)). Also, some related tools
41(such as `flash_ec` and `servod`) must be run from the Chromium OS chroot. Here
42is a set of steps to setup a minimal development environment to build EC images
43from the Chromium OS chroot:
44
451.  Create a folder for your chroot:
46
47    ```bash
48    mkdir cros-src; cd cros-src
49    ```
50
511.  Run
52
53    ```bash
54    repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git -g minilayout
55    ```
56
571.  Edit `.repo/manifest.xml`, and add `groups="minilayout"` to the platform/ec
58    project, so the line becomes:
59
60    ```
61    <project path="src/platform/ec" name="chromiumos/platform/ec" groups="minilayout" />
62    ```
63
641.  Run `repo sync`:
65
66    ```bash
67    repo sync -j <number of cores on your workstatsion>
68    ```
69
701.  Enter the chroot and enter your password for `sudo` if prompted:
71
72    ```bash
73    ./chromite/bin/cros_sdk
74    ```
75
761.  Set up your board:
77
78    ```bash
79    ./setup_board --board=$BOARD
80    ```
81
82    (ex. `./setup_board --board=glados`)
83
841.  Build EC:
85
86    ```bash
87    ./build_packages --board=$BOARD chromeos-ec
88    ```
89
901.  Now, EC images for any board can be built with:
91
92    ```bash
93    cd ~/trunk/src/platform/ec; make BOARD=$board -j
94    ```
95
96## Building `futility` outside the chroot {#building-futility}
97
98If you want to build the `futility` host tool outside the normal Chrome OS
99chroot self-contained environment, you can try the following
100
1011.  Install futility build dependencies:
102
103    ```bash
104    sudo apt-get install uuid-dev liblzma-dev libyaml-dev libssl-dev
105    ```
106
1071.  Get the vboot reference sources:
108
109    ```bash
110    git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference
111    ```
112
1131.  Build it:
114
115    ```bash
116    cd vboot_reference ; make
117    ```
118
1191.  Install it in `/usr/local/bin`:
120
121    ```bash
122    sudo make install
123    ```
124
1251.  Add `/usr/local/bin` to your default `PATH`:
126
127    ```bash
128    export PATH="${PATH}:/usr/local/bin"
129    ```
130