Skip to content

Commit dc5c11e

Browse files
committed
Add non-Chrome SDK Ubuntu build Github actions file
1 parent ffe224c commit dc5c11e

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Build EC firmware (standalone)
2+
3+
on:
4+
push:
5+
branches:
6+
- sunflower*
7+
- marigold*
8+
- lotus*
9+
- azalea*
10+
- fwk*
11+
- pr-*
12+
- framework*
13+
workflow_dispatch:
14+
15+
env:
16+
ZEPHYR_SDK_VERSION: "0.17.0"
17+
# CrOS Zephyr commit known to work with this EC (Zephyr 3.7.0-rc2)
18+
CROS_ZEPHYR_REF: "769e32e27318e91e90cc91496552ca4154a07ccc"
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-24.04
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
platform:
28+
- { name: sunflower, ver: "3.0.6" }
29+
- { name: marigold, ver: "0.0.0" }
30+
- { name: lotus, ver: "0.0.0" }
31+
- { name: azalea, ver: "0.0.0" }
32+
33+
steps:
34+
- name: Checkout EC source
35+
uses: actions/checkout@v4
36+
37+
- name: Install build dependencies
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y --no-install-recommends \
41+
cmake ninja-build gcc-multilib g++-multilib \
42+
python3-pip python3-setuptools python3-pyelftools \
43+
python3-pykwalify python3-colorama python3-testfixtures \
44+
device-tree-compiler flex bison swig
45+
46+
- name: Cache Zephyr SDK
47+
uses: actions/cache@v4
48+
id: cache-sdk
49+
with:
50+
path: ~/zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}
51+
key: zephyr-sdk-${{ env.ZEPHYR_SDK_VERSION }}-arm
52+
53+
- name: Install Zephyr SDK
54+
if: steps.cache-sdk.outputs.cache-hit != 'true'
55+
run: |
56+
cd ~
57+
wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
58+
tar xf zephyr-sdk-${ZEPHYR_SDK_VERSION}_linux-x86_64_minimal.tar.xz
59+
cd zephyr-sdk-${ZEPHYR_SDK_VERSION}
60+
# Only install the ARM toolchain needed for NPCX
61+
wget -q https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v${ZEPHYR_SDK_VERSION}/toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz
62+
tar xf toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz
63+
rm toolchain_linux-x86_64_arm-zephyr-eabi.tar.xz
64+
65+
- name: Clone CrOS Zephyr
66+
run: |
67+
git clone --depth 500 \
68+
https://chromium.googlesource.com/chromiumos/third_party/zephyr \
69+
~/cros-zephyr
70+
cd ~/cros-zephyr
71+
git checkout ${{ env.CROS_ZEPHYR_REF }}
72+
73+
- name: Clone CrOS CMSIS module
74+
run: |
75+
git clone --depth 1 -b chromeos-main \
76+
https://chromium.googlesource.com/chromiumos/third_party/zephyr/cmsis \
77+
~/modules/cmsis
78+
79+
- name: Set up modules directory
80+
run: ln -s $GITHUB_WORKSPACE ~/modules/ec
81+
82+
- name: Patch Zephyr for out-of-tree build
83+
run: |
84+
cd ~/cros-zephyr
85+
86+
# 1. Don't treat Kconfig warnings as errors
87+
# (undefined ESPI_PERIPHERAL_ACPI_SHM_REGION_WRITE_PROTECT_ENABLE
88+
# and choice symbol select warnings)
89+
sed -i 's/error_out = True/error_out = False/' \
90+
scripts/kconfig/kconfig.py
91+
92+
# 2. Add E8042_CLEAR_IBF opcode (Framework custom addition)
93+
sed -i '/E8042_CLEAR_OBF,/a\\tE8042_CLEAR_IBF,' \
94+
include/zephyr/drivers/espi.h
95+
96+
# 3. Add E8042_CLEAR_IBF handler in NPCX eSPI driver
97+
sed -i '/case E8042_READ_KB_STS:/i\\t\tcase E8042_CLEAR_IBF:\n\t\t\t/* Clear IBF by reading the data register */\n\t\t\t*data = inst_kbc->HIKMDI;\n\t\t\tbreak;' \
98+
drivers/espi/host_subs_npcx.c
99+
100+
- name: Patch EC for Zephyr compatibility
101+
run: |
102+
# 1. Guard IS_BIT_SET macro (conflicts with Zephyr's definition)
103+
sed -i 's/^#define IS_BIT_SET(reg, bit)/#ifndef IS_BIT_SET\n#define IS_BIT_SET(reg, bit)/' \
104+
zephyr/shim/chip/npcx/npcx_monitor/registers.h
105+
sed -i '/^#define IS_BIT_SET/,/^#define/{/^#define IS_BIT_SET/a\#endif
106+
}' zephyr/shim/chip/npcx/npcx_monitor/registers.h
107+
108+
# 2. Remove extra U suffix from CONFIG_PROGRAM_MEMORY_BASE
109+
# (DT_REG_ADDR already returns UINT32_C())
110+
sed -i 's/_CONCAT(DT_REG_ADDR(DT_CHOSEN(zephyr_flash)), U)/DT_REG_ADDR(DT_CHOSEN(zephyr_flash))/' \
111+
zephyr/shim/include/config_chip.h
112+
113+
- name: Install zmake
114+
run: pip install --break-system-packages -e zephyr/zmake
115+
116+
- name: Build ${{ matrix.platform.name }}
117+
run: |
118+
ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-${ZEPHYR_SDK_VERSION} \
119+
zmake \
120+
--modules-dir ~/modules \
121+
--zephyr-base ~/cros-zephyr \
122+
build -v ${{ matrix.platform.ver }} \
123+
${{ matrix.platform.name }}
124+
125+
- name: Show build info
126+
run: |
127+
echo "=== Binary size ==="
128+
ls -la build/zephyr/${{ matrix.platform.name }}/output/ec.bin
129+
echo "=== SHA256 ==="
130+
sha256sum build/zephyr/${{ matrix.platform.name }}/output/ec.bin
131+
echo "=== Version string ==="
132+
strings build/zephyr/${{ matrix.platform.name }}/output/ec.bin | grep ${{ matrix.platform.name }} || true
133+
echo "=== Git SHA ==="
134+
SHA_SHORT=$(echo "$GITHUB_SHA" | cut -c1-7)
135+
strings build/zephyr/${{ matrix.platform.name }}/output/ec.bin | grep "$SHA_SHORT" || echo "SHA not found in binary"
136+
137+
- name: Upload firmware artifact
138+
uses: actions/upload-artifact@v4
139+
with:
140+
name: ${{ matrix.platform.name }}-ec-${{ github.sha }}
141+
path: build/zephyr/${{ matrix.platform.name }}/output/

0 commit comments

Comments
 (0)