summaryrefslogtreecommitdiff
path: root/docs/zephyr/zephyr_build.md
blob: 8668c50e11083714a823d8836713a4ca132d5497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Building Zephyr OS

[TOC]

Chromium OS EC uses the `zmake` tool to build Zephyr.

This section describes how to build and use zmake.

## Environment Setup

Follow the [Chromium OS Developer Guide] to sync the source and get
the chroot setup.

It is also possible to build without a Chromium OS chroot, albeit with
additional setup steps.  See [out-of-chroot building] if this
interests you.

### A Note on Syncing the Source

The Legacy EC required only a single repository, and thus, it was common
for developers to sync just the EC repository using `repo sync .`.

Since the Zephyr build relies on multiple repositories, doing so will
likely end you up in a broken state.  Please be sure to do a complete
sync when updating the source.

## Building

To build the EC for a single project, run:

``` shellsession
(chroot) $ zmake build "${PROJECT}"
```

For example, to build the EC for `skyrim`, run:

``` shellsession
(chroot) $ zmake build skyrim
```

The output binary will then be located at `build/zephyr/skyrim/output/zephyr.bin`.

Additional output files you may find useful:

*   `build/zephyr/skyrim/output/zephyr.ro.elf` - read-only ELF for debugging
*   `build/zephyr/skyrim/output/zephyr.rw.elf` - read-write ELF for debugging

You might also find these files useful (using read-only as an example):

*   `build/zephyr/skyrim/build-ro/zephyr/.config` - Kconfig options selected
*   `build/zephyr/skyrim/build-ro/zephyr/include/generated/devicetree_unfixed.h` - the (large)
    header file that zephyr uses to provide devicetree information to the C code
*   `build/zephyr/skyrim/build-ro/zephyr/zephyr.dts` - devicetree that is used
*   `build/zephyr/skyrim/build-ro/zephyr/zephyr.dts` - map of image

For a complete list of `zmake` commands and options, see the
[Zmake Documentation].

Googlers may be interested in setting up [building with Goma](../goma.md)
as well.

### Building from Portage

There is also a [an ebuild] for integration into the larger Chromium
OS build system.

To build using this flow, run:

``` shellsession
(chroot) $ emerge-${BOARD} chromeos-base/chromeos-zephyr
```

### Looking at the Kconfig

It should be possible to do this with:

```bash
ninja -C /tmp/z/volteer/build-ro menuconfig
```

However at present this does not work [b/184662866](http://b/184662866).


[Chromium OS Developer Guide]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/developer_guide.md
[Zmake Documentation]: ../../zephyr/zmake/README.md
[an ebuild]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/HEAD/chromeos-base/chromeos-zephyr/chromeos-zephyr-9999.ebuild
[out-of-chroot building]: ./out_of_chroot.md